Renderwolf is a plain HTTPS API, so Go needs no SDK - net/http 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.
Take a screenshot
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"url": "https://example.com",
"width": 1280,
})
req, _ := http.NewRequest("POST",
"https://api.ironfang.uk/renderwolf/v1/screenshot",
bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
var e struct {
Error struct{ Code, Message string } `json:"error"`
}
json.NewDecoder(resp.Body).Decode(&e)
panic(fmt.Sprintf("%s: %s", e.Error.Code, e.Error.Message))
}
out, _ := os.Create("shot.png")
defer out.Close()
io.Copy(out, resp.Body)
}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.
// io.Copy streams the response straight to disk rather than
// buffering it. A full-page screenshot of a long page can be several
// megabytes, and there is no reason for it to pass through memory.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.
