PlaybooksScreenshot a Webpage
Request a screenshot
Call the capture endpoint with a URL and viewport options.
Call GET /v1/capture with the url parameter. Other parameters set the format, the viewport (viewport_width, viewport_height) and full-page capture. The answer is the image file itself, not JSON.
import os
import requests
API_KEY = os.environ["CAPTUREKIT_API_KEY"]
def get(path, params):
response = requests.get(f"https://api.capturekit.dev{path}", headers={"x-api-key": API_KEY}, params=params)
if not response.ok:
raise SystemExit(f"Error {response.status_code}: {response.text}")
return response
response = get("/v1/capture", {
"url": "https://stripe.com",
"format": "png",
"full_page": "true",
"viewport_width": "1440",
"viewport_height": "900",
})
image = response.content
print(f"Received {len(image)} bytes")