Authentication

Screenshot API uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard.

Getting Your API Key

  1. Sign up for an account at Screenshot API
  2. Navigate to the API Keys section
  3. 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';
02
03const client = new ScreenshotClient('your_api_key');

API Key Best Practices

Security

  1. Keep Keys Secret: Never expose your API keys in client-side code or public repositories
  2. Use Environment Variables: Store API keys in environment variables
  3. Rotate Regularly: Rotate your API keys periodically for enhanced security

Example using environment variables:

javascript
01// Load API key from environment variable
02const apiKey = process.env.SCREENSHOT_API_KEY;
03
04const client = new ScreenshotClient(apiKey);

Key Management

  1. Multiple Keys: Use different API keys for development and production
  2. Key Permissions: Create keys with minimal required permissions
  3. Monitor Usage: Track API key usage in the dashboard

Rate Limiting

API requests are rate-limited based on your plan:

PlanRate Limit
Free10 requests/minute
Pro100 requests/minute
Max500 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 backoff
08 await delay(1000);
09 // Retry request
10 }
11}

Error Responses

Authentication errors return standard HTTP status codes:

Status CodeDescription
401Invalid API key
403API key lacks permission
429Rate limit exceeded

Example error response:

json
01{
02 "error": "Invalid API key provided",
03 "code": "invalid_key",
04 "status": 401
05}

Next Steps

Ready to Get Started?

Get your API key now and start capturing screenshots in minutes.