mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
2.0 KiB
2.0 KiB
Authentication
Learn how to authenticate with the Hackatime API.
API Key
All API requests require authentication using your personal API key.
Getting Your API Key
Using Your API Key
Include your API key in the Authorization header:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://hackatime.hackclub.com/api/v1/stats
Alternative Authentication Methods
Query Parameter
You can also pass your API key as a query parameter:
curl "https://hackatime.hackclub.com/api/v1/stats?api_key=YOUR_API_KEY"
Note: Using the Authorization header is recommended for security.
Testing Authentication
Test your API key with a simple request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://hackatime.hackclub.com/api/v1/stats
A successful response will look like:
{
"data": {
"total_seconds": 12345,
"languages": [...],
"editors": [...]
},
"success": true
}
Error Responses
Invalid API Key
{
"error": "Invalid API key",
"success": false
}
Missing API Key
{
"error": "API key required",
"success": false
}
Rate Limiting
- Authenticated requests: 100 per minute
- Unauthenticated requests: 10 per minute
Rate limit headers are included in responses:
X-RateLimit-Limit: Your rate limitX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Unix timestamp when limit resets
Security Best Practices
- Never commit API keys to version control
- Use environment variables to store API keys
- Rotate keys regularly if they may be compromised
- Use HTTPS for all API requests
Need Help?
If you're having authentication issues, check:
- Your API key is correct
- You're using the right API endpoint
- Your request headers are properly formatted
Still stuck? Reach out in Hack Club Slack!