Screenshot a Webpage
Capture a full-page or viewport screenshot of any URL as a PNG or JPEG file using the CaptureKit API — no headless browser to maintain.
Overview
This playbook shows how to take a screenshot of any public URL and save it to disk. A common use case is visual regression testing or generating OG image thumbnails for a link-preview service.
Prerequisites
- A CaptureKit API key — get one at app.capturekit.dev
- Install dependencies for your language:
pip install requestsSteps
Request a screenshot
Call GET /v1/capture with the url parameter. Additional options control the viewport, format, and full-page capture.
import requests
API_KEY = "YOUR_API_KEY"
response = requests.get(
"https://api.capturekit.dev/v1/capture",
headers={"x-api-key": API_KEY},
params={
"url": "https://stripe.com",
"format": "png",
"full_page": "true",
"width": "1440",
"height": "900",
},
)
data = response.json()
print(data)Get the image URL from the response
The API returns a screenshot_url with the hosted image — or a base64-encoded image field if you set response_type=base64.
screenshot_url = data.get("screenshot_url")
print(f"Screenshot ready: {screenshot_url}")Download and save the image
Fetch the image bytes from the URL and write them to disk.
filename = "screenshot.png"
with requests.get(screenshot_url, stream=True) as r:
r.raise_for_status()
with open(filename, "wb") as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Saved to {filename}")Use full_page=false to capture only the above-the-fold viewport — ideal for social media preview thumbnails where a fixed-height 630×1200 px crop is required.
Model Context Protocol
Connectez CaptureKit à Claude Code, Cursor, Gemini CLI, OpenAI Developer Mode et d’autres clients MCP avec votre clé API.
Extract Content as Markdown
Convert any webpage to clean Markdown text using the CaptureKit content API — strip ads and boilerplate to get the pure article or documentation content.