Starhold Render

POST /v1/pdf

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

Examples

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

curl
curl -X POST https://render.starhold.app/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Invoice 42</h1><p>Thank you.</p>","page_size":"A4"}' \
  -o out.pdf
JavaScript (fetch)
import { writeFile } from "node:fs/promises";

const res = await fetch("https://render.starhold.app/v1/pdf", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
  body: '{"html":"<h1>Invoice 42</h1><p>Thank you.</p>","page_size":"A4"}',
});
if (!res.ok) throw new Error((await res.json()).error.message);
await writeFile("out.pdf", Buffer.from(await res.arrayBuffer()));
Python (requests)
import requests

body = '{"html":"<h1>Invoice 42</h1><p>Thank you.</p>","page_size":"A4"}'
res = requests.post("https://render.starhold.app/v1/pdf",
    headers={"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"},
    data=body.encode(), timeout=35)
res.raise_for_status()
open("out.pdf", "wb").write(res.content)
PHP (curl ext)
<?php
$body = '{"html":"<h1>Invoice 42</h1><p>Thank you.</p>","page_size":"A4"}';
$ch = curl_init("https://render.starhold.app/v1/pdf");
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("out.pdf", $out);
Go (net/http)
package main

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

func main() {
	body := `{"html":"<h1>Invoice 42</h1><p>Thank you.</p>","page_size":"A4"}`
	req, _ := http.NewRequest("POST", "https://render.starhold.app/v1/pdf", 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("out.pdf")
	io.Copy(out, res.Body)
}

Fields

FieldType and rangeDefault
url or htmlexactly one; html up to 512 KB; css goes with htmlnone
page_sizeA4, Letter, Legal, A3, A5, TabloidA4
width, heightCSS lengths, given together, instead of page_sizenone
landscapetrue or falsefalse
margintop, right, bottom, left as CSS lengths, each at most 100mm10mm each
header_html, footer_htmlup to 16 KB each; classes pageNumber, totalPages, date, title, urloff
print_backgroundtrue or falsetrue
scale0.1 to 2.01.0
page_rangesfor example 1-3,5all
mediaprint or screenprint
wait_untilload, domcontentloaded or networkidleload
wait_fora CSS selector, up to 256 charactersnone
delay_ms0 to 10,0000
cache_ttl0 to 86,400 seconds3,600 for url, 86,400 for html

A PDF may be up to 20 MB and 200 pages. More returns output_too_large.