Starhold Render

POST /v1/screenshot

Docs · OG · PDF · Screenshot · Signed URLs · Errors · Limits

Examples

Exactly one of url or html is required. The response is the image.

curl
curl -X POST https://render.starhold.app/v1/screenshot \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","viewport":{"width":1280,"height":800},"format":"png"}' \
  -o shot.png
JavaScript (fetch)
import { writeFile } from "node:fs/promises";

const res = await fetch("https://render.starhold.app/v1/screenshot", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: '{"url":"https://example.com","viewport":{"width":1280,"height":800},"format":"png"}',
});
if (!res.ok) throw new Error((await res.json()).error.message);
await writeFile("shot.png", Buffer.from(await res.arrayBuffer()));
Python (requests)
import requests

body = '{"url":"https://example.com","viewport":{"width":1280,"height":800},"format":"png"}'
res = requests.post("https://render.starhold.app/v1/screenshot",
    headers={"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"},
    data=body.encode(), timeout=35)
res.raise_for_status()
open("shot.png", "wb").write(res.content)
PHP (curl ext)
<?php
$body = '{"url":"https://example.com","viewport":{"width":1280,"height":800},"format":"png"}';
$ch = curl_init("https://render.starhold.app/v1/screenshot");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 35,
]);
$out = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) { die($out); }
file_put_contents("shot.png", $out);
Go (net/http)
package main

import (
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	body := `{"url":"https://example.com","viewport":{"width":1280,"height":800},"format":"png"}`
	req, _ := http.NewRequest("POST", "https://render.starhold.app/v1/screenshot", strings.NewReader(body))
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	res, err := (&http.Client{Timeout: 35 * time.Second}).Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	if res.StatusCode != 200 {
		io.Copy(os.Stderr, res.Body)
		os.Exit(1)
	}
	out, _ := os.Create("shot.png")
	io.Copy(out, res.Body)
}

Fields

FieldType and rangeDefault
url or htmlexactly onenone
viewportwidth 320 to 3840, height 240 to 21601280 by 800
device_scale_factor1, 2 or 3; width times factor at most 7,6801
full_pagetrue or false. Captured height is capped at 16,384 CSS px and captured width at 7,680 device px (7,680 divided by device_scale_factor CSS px); a longer or wider page is cut at the bottom or the right edge and the response has X-Render-Truncated: true. The whole image must also fit the 32 Mpx output limit (32,000,000 pixels after device_scale_factor), or the call fails with output_too_largefalse
format, qualitypng, jpeg or webp; 1 to 100png, 90
wait_until, wait_for, delay_msas for PDFload, none, 0
dark_modetrue asks the page for its dark colour schemefalse
block_cookie_bannerstrue or falsetrue
block_adstrue or falsefalse
hide_selectorsup to 20 CSS selectors, each up to 256 characters, hidden with display:nonenone
cache_ttl0 to 86,400 seconds3,600 for url, 86,400 for html

An image may be up to 10 MB. More returns output_too_large.