webcapture Get a free key

Convert a URL to PDF in Python with requests

requests posts the url and parses the receipt; a second authenticated GET brings back the bytes, and Path.write_bytes puts them on disk.

The endpoint holds the connection until the render finishes, so the script is linear: POST, read the receipt, GET the download, write the file. The 60 second client timeout matches the endpoint's own render budget, and json= sets the request's Content-Type for you.

The recipe

import requests
from pathlib import Path

ORIGIN = "https://webcapture.io"

receipt = requests.post(
    f"{ORIGIN}/v1/convert",
    headers={"Authorization": "Bearer wc_your_key", "Content-Type": "application/json"},
    json={"url": "https://example.com/"},
    timeout=60,
).json()

# receipt["download"] names /v1/conversions/<id>.pdf at the serving origin
# and only answers to your key: send the same header
pdf = requests.get(
    receipt["download"],
    headers={"Authorization": "Bearer wc_your_key"},
    timeout=60,
)
pdf.raise_for_status()
Path("page.pdf").write_bytes(pdf.content)

The receipt carries id, bytes, attempts, remaining, sourceUrl, sourceType, and download, and remaining is the count left on the account's monthly quota after this render. raise_for_status turns a failed render (502 for a page that would not load) or an exhausted quota (429) into an exception instead of writing an error body to disk. The download GET repeats the Authorization header because the endpoint is key-scoped, as every recipe here repeats it.

Same-key GET: 401 without it; 404 for another key.

The fields this recipe uses

Related

Method

Source: convert field reference, checked 2026-10-05. Corrections.