Authentication
Screenshot API uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard.
Getting Your API Key
- Sign up for an account at Screenshot API
- Navigate to the API Keys section
- Create a new API key for your project
Using Your API Key
Include your API key in the Authorization
header of all API requests:
javascript
01fetch('https://api.screenshotapi.io/v1/capture', {02 method: 'POST',03 headers: {04 'Content-Type': 'application/json',05 'Authorization': 'Bearer your_api_key'06 },07 body: JSON.stringify({08 url: 'https://example.com'09 })10});
Or using our client library:
javascript
01import { ScreenshotClient } from '@screenshot/client';0203const client = new ScreenshotClient('your_api_key');
API Key Best Practices
Security
- Keep Keys Secret: Never expose your API keys in client-side code or public repositories
- Use Environment Variables: Store API keys in environment variables
- Rotate Regularly: Rotate your API keys periodically for enhanced security
Example using environment variables:
javascript
01// Load API key from environment variable02const apiKey = process.env.SCREENSHOT_API_KEY;0304const client = new ScreenshotClient(apiKey);
Key Management
- Multiple Keys: Use different API keys for development and production
- Key Permissions: Create keys with minimal required permissions
- Monitor Usage: Track API key usage in the dashboard
Rate Limiting
API requests are rate-limited based on your plan:
Plan | Rate Limit |
---|---|
Free | 10 requests/minute |
Pro | 100 requests/minute |
Max | 500 requests/minute |
When you exceed the rate limit, the API returns a 429 Too Many Requests
response.
Handling Rate Limits
javascript
01try {02 const screenshot = await client.capture({03 url: 'https://example.com'04 });05} catch (error) {06 if (error.status === 429) {07 // Implement exponential backoff08 await delay(1000);09 // Retry request10 }11}
Error Responses
Authentication errors return standard HTTP status codes:
Status Code | Description |
---|---|
401 | Invalid API key |
403 | API key lacks permission |
429 | Rate limit exceeded |
Example error response:
json
01{02 "error": "Invalid API key provided",03 "code": "invalid_key",04 "status": 40105}
Next Steps
- Learn about Rate Limiting in detail
- Explore Error Handling
- Check out the API Reference
Ready to Get Started?
Get your API key now and start capturing screenshots in minutes.