Skip to content

Quickstart

Website screenshots in Node.js

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

Ironfang Render uses a standard HTTPS API, so Node.js can call it with fetch 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.

Take a screenshot

import { writeFile } from 'node:fs/promises';

const resp = await fetch('https://api.ironfang.uk/renderwolf/v1/screenshot', {
    method: 'POST',
    headers: {
        Authorization: `Bearer ${KEY}`,
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({ url: 'https://example.com', width: 1280 }),
});

if (!resp.ok) {
    const { error } = await resp.json();
    throw new Error(`${error.code}: ${error.message}`);
}

await writeFile('shot.png', Buffer.from(await resp.arrayBuffer()));

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.

// fetch does not throw for 4xx or 5xx responses. Check resp.ok
// before writing the response body to an image file.

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