Skip to main content
GET
/
v1
/
credits
curl --request GET \
  --url https://api.sociavault.com/v1/credits \
  --header 'X-API-Key: YOUR_API_KEY'
{
  "credits": 950,
  "subscriptionStatus": "active",
  "subscriptionId": "sub_1234567890"
}

Description

Use this endpoint to check your remaining credits and subscription status. This is useful for:
  • Monitoring your credit usage
  • Checking if you need to purchase more credits
  • Verifying your subscription status
  • Building credit balance displays in your application

Authentication

This endpoint requires authentication using your API key in the X-API-Key header.

Response

credits
integer
required
Remaining credits available
subscriptionStatus
string
required
Current subscription status. Possible values: active, inactive, cancelled, past_due
subscriptionId
string
Subscription ID if you have an active subscription
curl --request GET \
  --url https://api.sociavault.com/v1/credits \
  --header 'X-API-Key: YOUR_API_KEY'
{
  "credits": 950,
  "subscriptionStatus": "active",
  "subscriptionId": "sub_1234567890"
}

Use Cases

Display Credit Balance in Your App

async function displayCredits() {
  const response = await fetch('/v1/credits', {
    headers: { 'X-API-Key': process.env.SOCIAVAULT_API_KEY }
  });
  
  const { credits, subscriptionStatus } = await response.json();
  
  console.log(`You have ${credits} credits remaining`);
  
  if (credits < 100) {
    console.log('⚠️  Low credits! Consider purchasing more.');
  }
}

Check Before Making API Calls

async function scrapeWithCheck(handle) {
  // Check credits first
  const creditsResponse = await fetch('/v1/credits', {
    headers: { 'X-API-Key': process.env.SOCIAVAULT_API_KEY }
  });
  
  const { credits } = await creditsResponse.json();
  
  if (credits < 10) {
    throw new Error('Insufficient credits. Please purchase more.');
  }
  
  // Proceed with scraping
  const response = await fetch(`/v1/scrape/tiktok/profile?handle=${handle}`, {
    headers: { 'X-API-Key': process.env.SOCIAVAULT_API_KEY }
  });
  
  return response.json();
}

Monitor Credit Usage

async function monitorUsage() {
  const before = await getCredits();
  
  // Make API call
  await fetch('/v1/scrape/tiktok/videos?handle=someuser', {
    headers: { 'X-API-Key': process.env.SOCIAVAULT_API_KEY }
  });
  
  const after = await getCredits();
  
  console.log(`Credits used: ${before.credits - after.credits}`);
}

async function getCredits() {
  const response = await fetch('/v1/credits', {
    headers: { 'X-API-Key': process.env.SOCIAVAULT_API_KEY }
  });
  return response.json();
}

Error Responses

401
error
Unauthorized - Invalid or missing API key
404
error
User not found
500
error
Server error

Notes

  • This endpoint does not consume any credits
  • Credit balance is updated in real-time after each API call
  • Transactions history can be viewed in your dashboard
  • If your credits run out, API calls will return a 402 Payment Required error