Skip to main content

Response Format

All agntdata API responses follow a consistent format. Successful responses:
{
  "success": true,
  "data": {
    // Response data
  },
  "meta": {
    "costCents": 1,
    "purchasedBalanceCents": 950,
    "subscriptionRemainingCents": 0,
    "cached": false,
    "latencyMs": 245
  }
}
Error responses:
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error description",
    "retryAfter": 30
  }
}

HTTP Status Codes

StatusMeaning
200Success
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
404Not Found — Resource or endpoint doesn’t exist
429Too Many Requests — Rate limit exceeded
500Internal Server Error — Something went wrong

Error Codes

Authentication Errors

CodeDescriptionSolution
UNAUTHORIZEDInvalid or missing API keyCheck your API key is correct
INSUFFICIENT_CREDITSNot enough creditsTop up your credit balance

Request Errors

CodeDescriptionSolution
VALIDATION_ERRORRequired parameter missing or invalidCheck the API reference for required params
ENDPOINT_NOT_FOUNDEndpoint doesn’t existVerify the endpoint path
PROVIDER_NOT_FOUNDPlatform not availableCheck available platforms

Rate Limit Errors

CodeDescriptionSolution
RATE_LIMITEDToo many requestsWait and retry with backoff

Data Errors

CodeDescriptionSolution
NOT_FOUNDResource doesn’t existVerify the username/ID is correct
PROVIDER_ERRORUpstream platform errorRetry later
PROVIDER_UNAVAILABLEPlatform temporarily unavailableRetry later

Server Errors

CodeDescriptionSolution
INTERNAL_ERRORUnexpected server errorRetry, contact support if persistent
CONFLICTResource conflictCheck for duplicate resources

Handling Errors

JavaScript/TypeScript

async function fetchProfile(username: string) {
  const response = await fetch(
    `https://api.agntdata.dev/v1/linkedin/get-profile?username=${username}`,
    {
      headers: {
        'Authorization': `Bearer ${process.env.AGNTDATA_API_KEY}`
      }
    }
  );

  const data = await response.json();

  if (!data.success) {
    switch (data.error.code) {
      case 'NOT_FOUND':
        throw new Error(`Profile not found: ${username}`);
      case 'RATE_LIMITED':
        const retryAfter = data.error.retryAfter || 30;
        await sleep(retryAfter * 1000);
        return fetchProfile(username);
      case 'INSUFFICIENT_CREDITS':
        throw new Error('Please top up your credits');
      default:
        throw new Error(data.error.message);
    }
  }

  return data.data;
}

Python

import requests
import time
import os

def fetch_profile(username: str) -> dict:
    response = requests.get(
        f"https://api.agntdata.dev/v1/linkedin/get-profile",
        params={"username": username},
        headers={"Authorization": f"Bearer {os.environ['AGNTDATA_API_KEY']}"}
    )
    
    data = response.json()
    
    if not data.get("success"):
        error = data.get("error", {})
        code = error.get("code")
        
        if code == "NOT_FOUND":
            raise ValueError(f"Profile not found: {username}")
        elif code == "RATE_LIMITED":
            retry_after = error.get("retryAfter", 30)
            time.sleep(retry_after)
            return fetch_profile(username)
        elif code == "INSUFFICIENT_CREDITS":
            raise Exception("Please top up your credits")
        else:
            raise Exception(error.get("message", "Unknown error"))
    
    return data["data"]

Retry Strategy

For transient errors, implement exponential backoff:
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url, options);
      const data = await response.json();
      
      if (data.success) {
        return data;
      }
      
      // Don't retry client errors (4xx except 429)
      if (response.status >= 400 && response.status < 500 && response.status !== 429) {
        throw new Error(data.error.message);
      }
      
      // Retry with backoff for rate limits and server errors
      const delay = Math.pow(2, attempt) * 1000;
      await sleep(delay);
      
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;
    }
  }
}

Next Steps

Rate Limits

Understand rate limits and how to stay within them.

API Reference

Browse endpoint documentation.