Skip to main content
GET
/
v1
/
credits
Check Credits
curl --request GET \
  --url https://api.leadmagic.io/v1/credits \
  --header 'X-API-Key: <api-key>'
{
  "credits": 2200
}

Credit Balance

Monitor your credit balance programmatically. Use this endpoint to:
  • Track usage across your applications
  • Set up alerts before running low
  • Build internal dashboards
This endpoint is FREE - no credits consumed and no rate limiting applied.

Quick Example

curl 'https://api.leadmagic.io/v1/credits' \
  -H 'X-API-Key: YOUR_API_KEY'

Response

{
  "credits": 15432.50
}

Response Fields

FieldTypeDescription
creditsnumberYour current credit balance

Additional Endpoints

EndpointMethodDescription
GET /v1/creditsGETGet current credit balance
POST /v1/credits/refreshPOSTForce refresh credits from database (use if balance seems stale)
GET /v1/credits/healthGETValidate API key and check authentication status

Best Practices

Don’t call this endpoint before every API request. Cache the balance and refresh periodically (e.g., every 5 minutes).
let cachedCredits = null;
let lastFetch = 0;
const CACHE_TTL = 60000; // 1 minute

async function getCredits() {
  if (cachedCredits && Date.now() - lastFetch < CACHE_TTL) {
    return cachedCredits;
  }

  const response = await fetch('https://api.leadmagic.io/v1/credits', {
    headers: { 'X-API-Key': apiKey }
  });

  const { credits } = await response.json();
  cachedCredits = credits;
  lastFetch = Date.now();
  return credits;
}
Every API response includes X-Credits-Remaining header - use this instead of making a separate call:
const response = await fetch(endpoint, options);
const creditsRemaining = response.headers.get('X-Credits-Remaining');
console.log(`Credits after request: ${creditsRemaining}`);
Implement alerts when credits fall below a threshold to avoid service interruptions.
const { credits } = await checkCredits();

if (credits < 100) {
  sendCriticalAlert('CRITICAL: Credits below 100!');
} else if (credits < 1000) {
  sendWarning('Low credit balance: ' + credits);
}

Need More Analytics?

For comprehensive usage analytics, see our Analytics API which includes:
  • Real-time dashboard with rate limits and usage stats
  • Daily and monthly credit consumption history
  • Per-product breakdown with success rates
  • Latency percentiles and error tracking

Analytics API

Get detailed insights into your API usage with our comprehensive analytics suite.

Authorizations

X-API-Key
string
header
required

Your LeadMagic API key. Header name is case-insensitive (X-API-Key, X-API-KEY, x-api-key all work).

Response

Successful credits retrieval

credits
number
Example:

2200