Get instant access to our hosted Screenshot API on RapidAPI for just 1Β’ per screenshot!
β
No monthly commitment - Pay only for what you use
β
No subscription fees - Simple, transparent pricing
β
Instant setup - Start taking screenshots in seconds
β
99.9% uptime - Production-ready infrastructure
π₯ Get Started on RapidAPI β
Want to self-host instead? Continue reading for deployment instructions.
A serverless screenshot API built with Rust and Chromium, designed to run on AWS Lambda.
- Take screenshots of any website
- Configurable viewport dimensions
- Adjustable wait times for page loading
- PNG format support
- Base64 encoded response for easy integration
- CORS enabled for web applications
- Optimized for AWS Lambda environment
GET /?url=<URL>&width=<WIDTH>&height=<HEIGHT>&wait=<WAIT_TIME>
POST /?url=<URL>&width=<WIDTH>&height=<HEIGHT>&wait=<WAIT_TIME>
url(required): The URL of the website to screenshotwidth(optional): Viewport width in pixels (default: 1920, min: 320, max: 3840)height(optional): Viewport height in pixels (default: 1080, min: 320, max: 3840)wait(optional): Additional wait time in milliseconds after page load (default: 1000)
Note: The format parameter is not currently implemented - all screenshots are returned as PNG.
# Basic screenshot (uses default 1920x1080)
curl "https://your-api-gateway-url/?url=https://example.com"
# Custom dimensions and wait time
curl "https://your-api-gateway-url/?url=https://example.com&width=1280&height=720&wait=2000"
# Mobile viewport
curl "https://your-api-gateway-url/?url=https://example.com&width=375&height=667"
# Large desktop viewport
curl "https://your-api-gateway-url/?url=https://example.com&width=2560&height=1440"{
"success": true,
"data": "iVBORw0KGgoAAAANSUhEUgAA...", // Base64 encoded image
"content_type": "image/png"
}{
"error": "ERROR_CODE",
"message": "Detailed error message"
}- Rust 1.70+
- AWS CLI configured
- Docker (for Lambda deployment)
# Install dependencies
cargo build
# Run tests
cargo test
# Check code
cargo check# Build and deploy in one command
./deploy.sh
# Or with custom IAM role name
./deploy.sh my-lambda-roleThis script will:
- Install cargo-lambda if needed
- Create IAM role if it doesn't exist
- Build the project
- Deploy to Lambda with optimal settings
# Install cargo-lambda
cargo install cargo-lambda
# Build for Lambda
cargo lambda build --release
# Deploy with cargo lambda
cargo lambda deploy --iam-role arn:aws:iam::YOUR_ACCOUNT:role/lambda-execution-rolecargo lambda deploy \
--iam-role arn:aws:iam::YOUR_ACCOUNT:role/lambda-execution-role \
--memory 1024 \
--timeout 30 \
--env-var RUST_LOG=infoAfter deploying the Lambda function, you'll need to set up API Gateway to expose it as an HTTP endpoint:
# Enable Lambda Function URL (AWS CLI)
aws lambda create-function-url-config \
--function-name screenshotapi \
--auth-type NONE \
--cors '{"AllowCredentials": false, "AllowMethods": ["GET", "POST"], "AllowOrigins": ["*"]}'- Create a new REST API in AWS API Gateway
- Create a resource and method (GET/POST)
- Set up Lambda proxy integration
- Enable CORS if needed
- Deploy the API
# Create HTTP API with Lambda integration
aws apigatewayv2 create-api \
--name screenshot-api \
--protocol-type HTTP \
--target "arn:aws:lambda:REGION:ACCOUNT:function:screenshotapi"The function works out of the box but you can configure:
RUST_LOG: Set logging level (e.g., "info", "debug")API_KEY: Optional. If set, every request must provide this value either in thex-api-keyHTTP header or as thekeyquery-string parameter. Omit the variable to disable authentication (useful for local testing).
Once the Lambda function exists you can set / change the key at any time:
# one-off update (keeps existing image & config)
aws lambda update-function-configuration \
--function-name screenshotapi \
--environment "Variables={API_KEY=your-secret-value}" \
--region eu-central-1The key persists for the lifetime of the function. However: the sample deploy-working.sh script currently deletes and recreates the function on each deploy. If you use that script you have two options:
- Add
--environment "Variables={API_KEY=your-secret-value}"to theaws lambda create-functioncall inside the script so the key is applied on every deploy. - Stop deleting the function (remove the
aws lambda delete-functioncall). Updating an existing function keeps its environment variables intact.
# Header style
curl -H "x-api-key: your-secret-value" "${FUNCTION_URL}?url=https://example.com" | jq .
# Query-string style (handy for quick browser tests)
curl "${FUNCTION_URL}?url=https://example.com&key=your-secret-value" | jq .Requests without the correct key receive:
HTTP/1.1 401 Unauthorized
{
"error": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}- Memory: 1024 MB minimum (Chromium requires significant memory)
- Timeout: 30 seconds (for complex pages)
- Runtime:
provided.al2
The API consists of three main components:
- HTTP Handler (
src/http_handler.rs): Processes incoming requests and responses - Screenshot Service (
src/screenshot.rs): Manages Chromium browser and captures screenshots - Main (
src/main.rs): Lambda runtime entry point
The API handles various error scenarios:
- Invalid URLs
- Browser launch failures
- Navigation timeouts
- Screenshot capture errors
- Invalid parameters
- The browser runs in no-sandbox mode (required for Lambda)
- Input URL validation is performed
- CORS is enabled for web integration
- No persistent storage of screenshots
- Cold start time: ~2-3 seconds (includes Chromium initialization)
- Warm execution: ~1-2 seconds per screenshot
- Memory usage: ~200-500 MB depending on page complexity
- Maximum execution time limited by Lambda timeout (15 minutes max)
- Memory limited by Lambda configuration
- No support for authenticated pages (yet)
- PNG format only (JPEG planned)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
Why spend hours setting up infrastructure when you can start immediately?
Our hosted Screenshot API on RapidAPI gives you:
- Instant access - No deployment, no configuration
- Only 1Β’ per screenshot - The most affordable solution
- No monthly fees - Pay as you go
- Enterprise-grade reliability - 99.9% uptime
