Skip to main content
When a request fails, the API returns an error response with an HTTP status code and a JSON body describing the problem.

Error response format

All errors return both an error field and a message field:
{
  "error": "Unauthorized",
  "message": "Invalid API key"
}

Status codes

CodeErrorDescription
400VariesMissing or invalid parameters. Check the error field for details.
401UnauthorizedMissing or invalid API key.
402Insufficient CreditsAccount balance depleted.
429Too Many RequestsRate limit exceeded.
500Internal server errorSomething went wrong on our end.
Causes: Missing q parameter, invalid parameter values, malformed JSON array in q.Example messages:
  • Missing required parameter: q
  • Invalid value for depth parameter
Fix: Check your query string parameters against the parameter reference.
Causes: Missing x-api-key header, invalid or revoked API key.Example messages:
  • Missing x-api-key header
  • Invalid API key
Fix: Verify your API key in the API Console. Make sure you’re passing it in the x-api-key header (not as a query parameter or in the Authorization header).
Cause: Your account has no remaining credits.Message: Your account has insufficient credits. Please add credits to continue.Fix: Add credits to your account.
Cause: Too many requests in the current time window.Message: Rate limit of N requests per second exceededFix: Back off and retry after the period specified in the Retry-After header. See rate limits for monitoring usage.
Cause: An unexpected error on our side.Fix: Retry with exponential backoff. If it persists, contact support.

Handling errors in code

Check the HTTP status code before parsing the response body:
response=$(curl -s -w "\n%{http_code}" \
  "https://search-api.andisearch.com/api/v1/search?q=test" \
  -H "x-api-key: $ANDI_API_KEY")

http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | sed '$d')

case $http_code in
  200) echo "$body" | jq '.results[:3]' ;;
  429) echo "Rate limited. Retry after $(echo "$body" | jq -r '.message')" ;;
  402) echo "Out of credits. Visit console.andiai.com" ;;
  *)   echo "Error $http_code: $(echo "$body" | jq -r '.error')" ;;
esac

Retry with exponential backoff

For transient errors (429, 500), retry with increasing delays:
import time
import requests


def search_with_retry(query: str, max_retries: int = 5) -> dict:
    """Search with exponential backoff on transient errors."""
    delay = 1

    for attempt in range(max_retries + 1):
        response = requests.get(
            "https://search-api.andisearch.com/api/v1/search",
            params={"q": query},
            headers={"x-api-key": "YOUR_API_KEY"},
        )

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

        if response.status_code in (429, 500) and attempt < max_retries:
            wait = int(response.headers.get("Retry-After", delay))
            time.sleep(wait)
            delay = min(delay * 2, 60)
            continue

        response.raise_for_status()
Do not retry 400, 401, or 402 errors — these indicate problems that won’t resolve by retrying. Fix the request or account issue first.

Troubleshooting

SymptomLikely causeFix
Missing x-api-key headerHeader not sentAdd -H "x-api-key: YOUR_KEY" to your request
Invalid API keyWrong or revoked keyCheck the key in the API Console
Missing required parameter: qNo query providedAdd ?q=your+query to the URL
Slow responsesUsing depth=deep or metadata=fullSwitch to depth=fast or metadata=basic if speed matters
Empty results arrayNo matches for query/filtersBroaden your query or loosen filters

Next steps

Rate limits

Rate limit headers and monitoring.

Authentication

API key management and security.