Language

cURL Screenshot API

Test and integrate the Screenshotly API from the command line with cURL. Quick access for scripting, CI/CD pipelines, shell automation, and manual testing. Includes one-liner examples for PNG capture, full-page PDF output, device mockups, and piping results to other tools.

Quick Start

1

Install dependencies

cURL comes pre-installed on macOS and most Linux distributions. On Windows, install via winget or chocolatey.

2

Get your API key

Sign up for Screenshotly and get your API key from the dashboard.

3

Copy the code example

Use our cURL code example as a starting point.

4

Customize and integrate

Modify the code to fit your specific use case and requirements.

Code Example

# cURL
curl -X POST "https://api.screenshotly.app/screenshot" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "device": "desktop",
    "format": "png"
  }' \
  --output screenshot.png

When to Use cURL with Screenshotly

Use the cURL integration for quick manual testing, shell scripts, CI/CD pipeline steps, and system administration tasks. cURL is the fastest way to test API parameters before writing code in another language, and it works in every Linux, macOS, and Windows (WSL) environment.

cURL Best Practices

Store your API key in an environment variable and reference it as $SCREENSHOTLY_API_KEY in all scripts to avoid accidental key leakage.

Use -w '\n%{http_code}' to append the HTTP status code to output — essential for scripting conditional logic.

For complex JSON payloads, store them in a file and use -d @payload.json instead of inline escaping.

Pipe output directly to other tools: curl ... | convert - -resize 50% thumbnail.png (ImageMagick) or curl ... | jq (JSON processing).

API Reference

EndpointPOST /api/screenshot
AuthenticationBearer token
Content-Typeapplication/json
View full API docs

Frequently Asked Questions

How do I capture screenshots in batch using cURL?

Create a shell script that loops through a list of URLs. Use xargs for parallel processing: cat urls.txt | xargs -P 5 -I {} curl -X POST ... -d '{"url":"{}"}' --output {}.png. The -P flag controls concurrency.

How do I pass dynamic options with cURL?

Use shell variables: URL='https://example.com' && curl -X POST ... -d "{\"url\":\"$URL\",\"format\":\"png\"}" --output screenshot.png. For complex payloads, store JSON in a file and use -d @payload.json.

How do I check if a screenshot request succeeded?

Add -w '%{http_code}' to output the status code, or use -f to make cURL fail on HTTP errors. Check for 200 status on success. 401 means invalid API key, 429 means rate limited, 400 means invalid parameters.

Can I use cURL in CI/CD pipelines?

Yes. cURL is available in all major CI environments (GitHub Actions, GitLab CI, Jenkins). Store your API key as a CI secret and reference it as an environment variable in your pipeline script.

Start building with cURL

Get your API key and start capturing screenshots in minutes.

Other Languages