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, WordPress plugin, log ingestion
Prefix: bot_
Getting Your API Key
- 1
Log in to your AI Search Index dashboard
- 2
Go to Account → API Keys
- 3
Click Create API Key
- 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
| Status | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 403 | FORBIDDEN | API key doesn't have permission |
| 429 | RATE_LIMITED | Too many requests |