Skip to content

Quickstart

Website screenshots in Python

Use requests to create a screenshot with one HTTPS request and no browser infrastructure to manage.

Ironfang Render uses a standard HTTPS API, so Python can call it with requests and does not require an SDK. A successful request returns the image bytes directly, ready to write to a file.

Get a key

Create an API key in the portal. The secret is displayed once and stored as a hash. Save it in an environment variable rather than adding it to the source file.

Install

pip install requests

Take a screenshot

import requests

resp = requests.post(
    "https://api.ironfang.uk/renderwolf/v1/screenshot",
    headers={"Authorization": "Bearer " + KEY},
    json={"url": "https://example.com", "width": 1280},
    timeout=60,
)
resp.raise_for_status()

with open("shot.png", "wb") as f:
    f.write(resp.content)

Handling errors

Successful render responses are binary. Errors use JSON in the form {"error": {"code", "message"}}. A missing or unrecognised key returns 401 invalid_api_key. A key without the renderwolf:render scope returns 403 insufficient_scope.

if resp.status_code != 200:
    # Errors are JSON even though success is binary.
    err = resp.json()["error"]
    raise RuntimeError(f"{err['code']}: {err['message']}")

PDFs and templates

The same call shape works for /v1/pdf, and for templated images at /v1/image/{id}. Only the path and the body change.

Next