Overview
The AQI Predictor API uses API keys to authenticate requests. All API endpoints require authentication except for public status endpoints.Obtaining an API Key
- Sign up for an account at https://dashboard.aqipredictor.com
- Navigate to Settings → API Keys
- Click Generate New API Key
- Copy your API key immediately (it won’t be shown again)
- Store it securely in your application’s environment variables
Authentication Method
Include your API key in theX-API-Key header with every request:
Header Format
Your unique API key. Format:
aqp_ followed by 32 alphanumeric characters.Example: aqp_1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6pAPI Key Types
The AQI Predictor platform supports two types of API keys:Production Keys
Production Keys
Production Keys are used for live applications and are subject to your account’s rate limits and billing.
- Prefix:
aqp_prod_ - Environment: Production API (
https://api.aqipredictor.com) - Rate limits: Based on your subscription tier
- Usage is billed according to your plan
Test Keys
Test Keys
Test Keys are used for development and testing environments with relaxed constraints.
- Prefix:
aqp_test_ - Environment: Sandbox API (
https://sandbox-api.aqipredictor.com) - Rate limits: 100 requests per hour
- Returns synthetic predictions for testing
- No billing charges
Authentication Example
Authentication Errors
Missing API Key
If you don’t include theX-API-Key header:
401 Unauthorized
Invalid API Key
If your API key is invalid, expired, or revoked:401 Unauthorized
Insufficient Permissions
If your API key doesn’t have permission for the requested operation:403 Forbidden
Security Best Practices
Follow these security guidelines to protect your API keys and data.
Store Keys Securely
Use environment variables or secure secret management:.env
Python
Rotate Keys Regularly
- Generate a new API key in the dashboard
- Update your application with the new key
- Test thoroughly in your staging environment
- Revoke the old key once migration is complete
Use Different Keys for Different Environments
- Development: Test keys only
- Staging: Separate production key
- Production: Primary production key
- CI/CD: Dedicated key with monitoring
Monitor API Key Usage
Track your API key usage in the dashboard:- Request volume and patterns
- Error rates
- Geographic distribution
- Unusual activity alerts
Revoke Compromised Keys
If you suspect a key has been compromised:- Immediately revoke it in the dashboard
- Generate a new key
- Update your applications
- Review access logs for suspicious activity
- Contact support if you detect unauthorized usage
Rate Limiting by API Key
Each API key has rate limits based on your subscription tier:Response Headers
Maximum number of requests allowed per minute for your API key.
Number of requests remaining in the current rate limit window.
Unix timestamp when the rate limit window resets.
429 Too Many Requests