Screenshot API Documentation
Welcome to the Screenshot API documentation. This guide will help you get started with our free and open-source screenshot API service.
What is Screenshot API?
Screenshot API is a free, open-source API service that allows you to capture screenshots of any website with a simple API call. It's designed to be easy to use, reliable, and completely free for everyone.
Key Features
- Completely free with no usage limits
- Open-source codebase you can contribute to or self-host on cloudflare worker
- Simple REST API with comprehensive documentation
- Support for custom viewport sizes, device emulation, and more
- Ability to capture full-page screenshots or specific elements
- Multiple output formats (PNG, JPEG, PDF)
Getting Started
To start using Screenshot API, you'll need to:
- Sign up for a free account
- Get your API key from the dashboard
- Make your first API request
Basic Example
curl -X GET "https://<your-worker-domain>/take?url=https://example.com&width=1280&height=800" \
-o screenshot.png
API Endpoints
Take a Screenshot
GET /take
This endpoint captures a screenshot of the specified URL.
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Yes | The URL of the website to capture |
width | integer | No | Viewport width in pixels (default: 1280) |
height | integer | No | Viewport height in pixels (default: 800) |
fullPage | boolean | No | Capture full page height (default: false) |
format | string | No | Output format: png, jpeg, or pdf (default: png) |
quality | integer | No | Image quality for JPEG (1-100, default: 80) |
Error Handling
All error responses will be returned in JSON format with an error
message. Some errors may include additional details:
Validation Error Example
{
"error": "Invalid input"
}
Screenshot Failure Example
{
"error": "Screenshot failed"
}
Deploying to Cloudflare Workers
You can deploy Screenshot API to Cloudflare Workers for global, serverless performance. This is the recommended way to run the API in production.
Prerequisites
- Cloudflare account
- Cloudflare Wrangler CLI installed (
npm install -g wrangler
) - Cloudflare API Token with Worker deployment permissions
Deployment Steps
- Clone the repository:
git clone https://github.com/Hassanrkbiz/cloudflare-screenshot-api.git cd cloudflare-screenshot-api
- Install dependencies:
npm install
- Configure your
wrangler.toml
and environment variables as needed. - Authenticate with Cloudflare:
npx wrangler login
- Deploy to Cloudflare Workers:
This command runsnpm run deploy
npx wrangler deploy
for you. After a successful deploy, your API will be available at your assigned Cloudflare Worker domain.
For more details, see the GitHub README.