TidyTools

Web page to PDF

POST https://tools.yukai.uk/api/v1/pdf

Print a web page to PDF. Returns the PDF bytes by default (response=pdf), or JSON with the PDF as base64.

Cost

Credits: 23 ($0.0023) per successful call. Failed calls are free. Source price: website-screenshot-pdf-markdown/pdf.

Input

Send a JSON body (POST) or the same fields as a query string (GET).

Required: url.

FieldTypeDefaultDescription
url requiredstringPage URL. A bare domain such as example.com is accepted (https is assumed). Private, local and cloud-metadata addresses are refused.
paperstring"A4"Paper size.
landscapebooleanfalseLandscape orientation.
printBackgroundbooleantruePrint background colours and images.
responsestring"pdf"pdf returns the bytes; json returns metadata plus base64.
devicestring"custom"Viewport preset. custom uses width/height.
waitUntilstring"networkidle2"When the page counts as loaded.
timeoutMsinteger20000Page-load timeout in milliseconds.
delayMsinteger0Extra wait after load (animations, late content).
darkModebooleanfalseEmulate prefers-color-scheme: dark.
hideCookieBannersbooleantrueRemove common cookie/consent banners before capturing.
blockAdsbooleanfalseBlock common ad, analytics and tracking hosts.
lazyLoadbooleanfalseScroll through the page first so lazy-loaded images appear.
waitForSelectorstringWait for this CSS selector before capturing (captures anyway on timeout).
hideSelectorsstringComma-separated CSS selectors removed before capturing.

Examples

Replace tt_live_XXXX with your key from the pricing page.

curl

curl -i -X POST "https://tools.yukai.uk/api/v1/pdf" \
  -H "Authorization: Bearer tt_live_XXXX" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","response":"json"}'

JavaScript (fetch)

const res = await fetch("https://tools.yukai.uk/api/v1/pdf", {
  method: "POST",
  headers: { "Authorization": "Bearer tt_live_XXXX", "Content-Type": "application/json" },
  body: JSON.stringify({"url":"https://example.com","response":"json"}),
});
console.log(res.status, res.headers.get("x-credits-charged"), res.headers.get("x-credits-balance"));
console.log(await res.json());

Python (requests)

import requests

r = requests.post(
    "https://tools.yukai.uk/api/v1/pdf",
    headers={"Authorization": "Bearer tt_live_XXXX"},
    json={"url": "https://example.com", "response": "json"},
    timeout=120,
)
print(r.status_code, r.headers.get("x-credits-charged"), r.headers.get("x-credits-balance"))
print(r.json())

Response

JSON with "success": true and the result fields; on failure {"success": false, "error": {"code", "message", "retryable"}} and no credits are used. Every answer carries x-credits-charged (credits used) and x-credits-balance (balance after the call); check the balance any time with GET https://tools.yukai.uk/v1/billing/balance.

Full field list and response schema: OpenAPI spec website-screenshot (its servers entry is the marketplace gateway; call https://tools.yukai.uk with your key).

← All routes · Pricing