Authentication

Authentication

Learn how to authenticate your API requests with SERPII.

API Keys

All API requests require authentication using an API key. You can find your API keys in the dashboard.

Key Types

Live Keys
Prefix: sk_live_ — Use in production. Counts against your plan limits.
Test Keys
Prefix: sk_test_ — Use for development. Returns mock data, doesn't count against limits.

Authentication Methods

Bearer Token (Recommended)

Include your API key in the Authorization header using Bearer authentication:

Authorization: Bearer sk_live_your_api_key_here

Query Parameter

Alternatively, pass your API key as a query parameter (less secure):

GET https://api.serpii.com/v1/search?q=query&api_key=sk_live_your_api_key_here

Code Examples

cURL

curl -X GET "https://api.serpii.com/v1/search?q=test" \
  -H "Authorization: Bearer sk_live_your_api_key_here" \
  -H "Content-Type: application/json"

JavaScript

const response = await fetch('https://api.serpii.com/v1/search?q=test', {
  headers: {
    'Authorization': 'Bearer sk_live_your_api_key_here',
    'Content-Type': 'application/json'
  }
});

const data = await response.json();

Python

import requests

response = requests.get(
    'https://api.serpii.com/v1/search',
    params={'q': 'test'},
    headers={
        'Authorization': 'Bearer sk_live_your_api_key_here',
        'Content-Type': 'application/json'
    }
)

data = response.json()

Security Best Practices

  • Keep keys secret — Never expose API keys in client-side code or public repositories.
  • Use environment variables — Store keys in environment variables, not in code.
  • Rotate keys regularly — Generate new keys periodically and revoke old ones.
  • Use test keys for development — Only use live keys in production environments.
  • Monitor usage — Check the dashboard regularly for unexpected activity.

Authentication Errors

If authentication fails, you'll receive one of these error responses:

401 Unauthorized — Missing API Key
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key",
    "documentation": "https://docs.serpii.com/authentication"
  }
}
403 Forbidden — Invalid API Key
{
  "success": false,
  "error": {
    "code": "FORBIDDEN",
    "message": "API key is invalid or has been revoked",
    "documentation": "https://docs.serpii.com/authentication"
  }
}
View all error codes