Security
Protect Your API Key
- Never expose in public source code
- Use environment variables
- Don’t include in logs
Use HTTPS
- Always use HTTPS for requests
- Verify SSL certificates
- Don’t accept invalid certificates
Set Expiration
- Configure expiration dates for keys
- Rotate keys periodically
- Revoke compromised keys immediately
Least Privilege Principle
- Create keys with minimum necessary permissions
- Use different keys for different environments
- Delete unused keys
Error Handling
1
Always Check HTTP Status
Don’t assume success - check the status code in every request.
2
Implement Retry Logic
For temporary errors (5xx, 429), implement retry with exponential backoff.
3
Use Appropriate Timeouts
Configure timeouts to avoid hanging requests.
4
Handle Specific Errors
Implement handlers for different error types.
Performance
Avoid Unnecessary Requests
Avoid Unnecessary Requests
- Implement local cache when appropriate
- Use filters to fetch only necessary data
- Batch operations when possible
Use Pagination
Use Pagination
- Always use
limitandoffsetfor large lists - Don’t try to fetch all data at once
- Process data in batches
Respect Rate Limits
Respect Rate Limits
- Monitor rate limit headers
- Implement client-side throttling
- Use queues for bulk operations
Monitor Response Times
Monitor Response Times
- Record request latencies
- Set up alerts for degradation
- Use metrics to identify issues
Webhooks
Respond Quickly
Return 200 quickly and process in background. Webhooks have timeout.
Idempotency
Process events idempotently - the same event may be sent more than once.
Validate Payloads
Always validate the payload structure before processing.
Log Events
Record all received events for debugging and auditing.