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:

  1. Sign up for a free account
  2. Get your API key from the dashboard
  3. 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

ParameterTypeRequiredDescription
urlstringYesThe URL of the website to capture
widthintegerNoViewport width in pixels (default: 1280)
heightintegerNoViewport height in pixels (default: 800)
fullPagebooleanNoCapture full page height (default: false)
formatstringNoOutput format: png, jpeg, or pdf (default: png)
qualityintegerNoImage 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

  1. Clone the repository:
    git clone https://github.com/Hassanrkbiz/cloudflare-screenshot-api.git cd cloudflare-screenshot-api
  2. Install dependencies:
    npm install
  3. Configure your wrangler.toml and environment variables as needed.
  4. Authenticate with Cloudflare:
    npx wrangler login
  5. Deploy to Cloudflare Workers:
    npm run deploy
    This command runs 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.