Quickstart

Website screenshots in Python

One HTTPS request, requests, and no browser of your own to keep running.

Renderwolf is a plain HTTPS API, so Python needs no SDK - requests is enough. A successful render returns the image bytes directly, with no JSON envelope and no base64, so you write the response straight to a file.

Get a key

Create one in the portal. It is shown once and stored hashed, so put it in an environment variable rather than in the file - the samples below read it from one.

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

Success is binary; every error is JSON, shaped as {"error": {"code", "message"}}. A missing or unknown key is 401 invalid_api_key, and a key without the renderwolf:render scope is 403.

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