Ironfang Render uses a standard HTTPS API, so PHP can call it with cURL 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
<?php
$ch = curl_init('https://api.ironfang.uk/renderwolf/v1/screenshot');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com',
'width' => 1280,
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
$err = json_decode($body, true)['error'];
throw new RuntimeException("{$err['code']}: {$err['message']}");
}
file_put_contents('shot.png', $body);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.
// CURLOPT_RETURNTRANSFER keeps the binary response in $body
// instead of writing it directly to stdout.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.
