API Authentication

All API requests require authentication using an API key.

Types of Keys

AI Search Index uses two types of keys for different purposes:

API Key

Used for: Querying analytics data, managing websites, accessing metrics

Prefix: api_

Bot Tracking Key

Used for: CDN log integrations and log ingestion

Prefix: bot_

Getting Your API Key

  1. 1
  2. 2

    Go to AccountAPI Keys

  3. 3

    Click Create API Key

  4. 4

    Copy your new API key (it will only be shown once)

Using Your API Key

Include your API key in the x-api-key header:

cURL
curl -X GET https://aisearchindex.com/api/v1/websites \
  -H "x-api-key: api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
JavaScript (fetch)
const response = await fetch('https://aisearchindex.com/api/v1/websites', {
  headers: {
    'x-api-key': 'api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  }
});
const data = await response.json();
Python (requests)
import requests

response = requests.get(
    'https://aisearchindex.com/api/v1/websites',
    headers={'x-api-key': 'api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
)
data = response.json()

Security Best Practices

Keep Your API Key Secret

Never expose your API key in client-side code, public repositories, or logs.

  • Store API keys in environment variables
  • Use server-side code to make API requests
  • Rotate keys periodically
  • Use different keys for different environments
  • Never include API keys in client-side JavaScript
  • Never commit API keys to version control

Authentication Errors

StatusCodeDescription
401UNAUTHORIZEDMissing or invalid API key
403FORBIDDENAPI key doesn't have permission
429RATE_LIMITEDToo many requests