Authentication
Learn how to authenticate your API requests. CaptchaKings API uses API keys for authentication.
Getting Your API Key
To use the API, you need an API key:
- Register an account at captchakings.com/register
- Login to your Dashboard
- Navigate to API Settings
- Copy your API key (format:
ck_......)
⚠️ Keep Your API Key Secret!
Never expose your API key in frontend code, public repositories, or client-side applications.
Never expose your API key in frontend code, public repositories, or client-side applications.
Authentication Methods
We support 3 ways to authenticate your requests:
Method 1: Authorization Header (Recommended) ⭐
Pass your API key in the Authorization header as a Bearer token:
bash
curl -X POST https://captchakings.com/api/process.php \
-H "Authorization: Bearer ck_your_api_key_here" \
-F "captcha=@captcha.jpg"
php
$headers = [
'Authorization: Bearer ' . $apiKey
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
Method 2: X-API-Key Header
Alternatively, use the X-API-Key header:
bash
curl -X POST https://captchakings.com/api/process.php \
-H "X-API-Key: ck_your_api_key_here" \
-F "captcha=@captcha.jpg"
Method 3: POST Parameter (Fallback)
You can also send the API key as a POST parameter:
bash
curl -X POST https://captchakings.com/api/process.php \
-F "api_key=ck_your_api_key_here" \
-F "captcha=@captcha.jpg"
💡 Best Practice: Use Method 1 (Authorization header) for better security and standard compliance.
Free Trial Mode
You can test the API without an API key using Free Trial Mode:
bash
curl -X POST https://captchakings.com/api/process.php \
-F "captcha=@captcha.jpg"
⚠️ Free Trial Mode Limitations:
- No credits deducted (unlimited)
- Lower priority processing
- No usage tracking
- Best for testing only
- No credits deducted (unlimited)
- Lower priority processing
- No usage tracking
- Best for testing only
Testing Your API Key
Verify your API key is working with this test request:
bash
# Replace with your actual API key
API_KEY="ck_your_api_key_here"
# Test request
curl -X POST https://captchakings.com/api/process.php \
-H "Authorization: Bearer $API_KEY" \
-F "captcha=@test_captcha.jpg"
Expected Response:
json
{
"success": true,
"data": {
"prediction": "ABC123",
"confidence": "98.5%"
},
"credits": {
"credits_deducted": 1,
"credits_remaining": 999,
"plan": "free_trial"
},
"mode": "api_key"
}
Common Authentication Errors
| Error | Cause | Solution |
|---|---|---|
Invalid API key or account inactive |
API key is wrong or account is disabled | Check your API key in the dashboard |
Insufficient credits |
You've run out of credits | Top up credits or upgrade your plan |
API authentication failed |
API key format is incorrect | Ensure API key starts with ck_ |
Security Best Practices
🔒 Security Tips:
- Never commit API keys to Git - Use environment variables instead
- Rotate keys regularly - Generate new keys every 3-6 months
- Use HTTPS only - Never send requests over HTTP
- Keep keys server-side - Don't expose keys in frontend JavaScript
- Monitor usage - Check dashboard for suspicious activity
Example: Using Environment Variables
php
// .env file
CAPTCHAKINGS_API_KEY=ck_your_api_key_here
// In your PHP code
$apiKey = getenv('CAPTCHAKINGS_API_KEY');
// Or use $_ENV
$apiKey = $_ENV['CAPTCHAKINGS_API_KEY'];
python
# .env file
CAPTCHAKINGS_API_KEY=ck_your_api_key_here
# In your Python code
import os
api_key = os.getenv('CAPTCHAKINGS_API_KEY')
javascript
// .env file
CAPTCHAKINGS_API_KEY=ck_your_api_key_here
// In your Node.js code
require('dotenv').config();
const apiKey = process.env.CAPTCHAKINGS_API_KEY;
Next Steps
Now that you know how to authenticate, check out:
- API Endpoints - Learn about available endpoints
- Code Examples - See real implementation examples
- Rate Limits - Understand usage limits