Authentication
Secure access to SearchHive APIs using API keys. Learn about authentication methods, security best practices, and troubleshooting common issues.
Getting Your API Key
Authentication Method
SearchHive uses API key authentication. Include your API key in the Authorization: Bearer
header with every request to authenticate your application.
Header Format
Required Authentication Header
Authorization: Bearer sk_live_your_key_here
Implementation Examples
Authenticating API requests
# Your API key from the dashboard
API_KEY="sk_live_3dc31b5a3fa92ffb1d3300d9c8ce89a551f4cb156eb9c2ace27ae2a7d8419a70"
# Include API key in header
curl -X POST https://www.searchhive.dev/api/v1/swiftsearch \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "test search"}' \
--fail-with-body
# Check exit code
if [ $? -eq 0 ]; then
echo "Authentication successful!"
else
echo "Authentication failed - check your API key"
fi
Alternative header formats
Authorization: Bearer your_key_here
if your HTTP client doesn't support custom headers easily.Security Best Practices
Store your API keys in environment variables, never hardcode them in your source code.
Using environment variables for API keys
# .env file
SEARCHHIVE_API_KEY=sk_live_your_key_here
# Load in script
source .env
# Use environment variable
curl -H "Authorization: Bearer $SEARCHHIVE_API_KEY" \
https://www.searchhive.dev/api/v1/swiftsearch
Never expose API keys client-side
Don't include them in JavaScript that runs in browsers
Don't commit keys to version control
Add your .env files to .gitignore
Don't share keys in public forums
Including Stack Overflow, GitHub issues, etc.
Use separate keys for different environments
Different keys for development, staging, and production
Rotate keys regularly
Generate new keys monthly or when team members change
Monitor usage in dashboard
Watch for unexpected usage patterns that might indicate compromise
Authentication Errors
Common authentication error responses and how to handle them.
401Unauthorized
Invalid or missing API key
{
"error": "Invalid or missing API key",
"code": "UNAUTHORIZED",
"message": "Please check your Authorization Bearer header"
}
Solution: Check that your API key is correct and included in the Authorization: Bearer
header.
403Forbidden
Insufficient plan access
{
"error": "Insufficient plan access",
"code": "FORBIDDEN",
"message": "Contact extraction requires Starter plan or higher",
"upgrade_url": "/dashboard?tab=billing"
}
Solution: Upgrade your plan to access this feature, or remove the restricted parameter from your request.
429Rate Limited
Too many requests
{
"error": "Rate limit exceeded",
"code": "RATE_LIMITED",
"message": "Free plan limited to 10 requests per hour",
"retry_after": 3600,
"upgrade_url": "/dashboard?tab=billing"
}
Solution: Wait for the specified retry_after
period, or upgrade your plan for higher rate limits.
Testing Your Authentication
Use this simple test to verify your API key is working correctly.
Test authentication
curl -X POST https://www.searchhive.dev/api/v1/swiftsearch \
-H "Authorization: Bearer YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"query": "test", "max_results": 1}'