Authentication

Secure access to SearchHive APIs using API keys. Learn about authentication methods, security best practices, and troubleshooting common issues.

API Key Based
Simple header authentication
TLS Encrypted
All requests over HTTPS
Rotate Anytime
Generate new keys instantly

Getting Your API Key

1
Create Account

Sign up for a free SearchHive account

Get 5,000 free credits to start

2
Generate API Key

Navigate to your dashboard and create a new API key

Keys start with sk_live_

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

cURL
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
You can also use Authorization: Bearer your_key_here if your HTTP client doesn't support custom headers easily.

Security Best Practices

Environment Variables

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
What NOT to do

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.

Additional Security

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.

401
Unauthorized

Invalid or missing API key

JSON
{
  "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.

403
Forbidden

Insufficient plan access

JSON
{
  "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.

429
Rate Limited

Too many requests

JSON
{
  "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
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}'
Expected successful response
You should receive a 200 status code with search results and your remaining credit count.

Still having authentication issues?

Our support team can help you troubleshoot authentication problems.