API Documentation

Everything you need to integrate the RichAPI API into your product.

Error Handling

HTTP status codes and error responses

HTTP Status Codes

CodeMeaningBilled?
200SuccessYes
201CreatedYes
400Bad Request -- invalid parametersNo
401Unauthorized -- missing API keyNo
403Forbidden -- invalid API keyNo
404Not Found -- unknown endpoint or resourceNo
429Too Many Requests -- monthly quota exceededNo
500Internal Server ErrorNo
502Bad Gateway -- upstream service errorNo
504Gateway Timeout -- upstream service timed outNo

Error Response Format

All errors return a JSON object with an <code>error</code> field:

json
{
  "error": "Description of what went wrong"
}

Common Errors

Missing API Key (401)

json
{
  "message": "Forbidden"
}

Fix: Add the <code>x-api-key</code> header to every request.

Unknown Endpoint (404)

json
{
  "error": "Unknown API: nonexistent",
  "available_apis": ["enrich_profile", "enrich_company", ...]
}

Fix: Check the endpoint name. The <code>available_apis</code> list shows all valid endpoints.

Quota Exceeded (429)

json
{
  "error": "Monthly quota exceeded",
  "api": "enrich_profile",
  "limit": 100000,
  "current": 100000
}

Fix: Wait until the next month or contact us for a higher limit.

Upstream Error (502)

json
{
  "error": "Authentication with provider failed"
}

Fix: This is a server-side issue. Retry your request. If the problem persists, contact support.

Timeout (504)

json
{
  "error": "Provider timeout or connection error",
  "detail": "..."
}

Fix: The request took too long. Retry with a smaller batch size or try again later.

Retry Strategy

We recommend exponential backoff for retries:

python
import time
import requests

def call_api(url, data, api_key, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(
            url,
            json=data,
            headers={
                "x-api-key": api_key,
                "Content-Type": "application/json"
            }
        )

        if response.status_code == 200:
            return response.json()

        if response.status_code in (429, 502, 504):
            wait = 2 ** attempt  # 1s, 2s, 4s
            time.sleep(wait)
            continue

        # Non-retryable error
        response.raise_for_status()

    raise Exception("Max retries exceeded")