Web data API URL to PDF API
Send a page and get a PDF printed by a headless browser, with selectable text, links and your print styles.
POSThttps://api.pathclue.com/v1/web/pdfBetaCall it from your code
Set your key in the TAPCUB_API_KEY environment variable. Base URL: https://api.pathclue.com/v1.
curl -X POST https://api.pathclue.com/v1/web/pdf \
-H "Authorization: Bearer $TAPCUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/invoice/42","paper":"letter","margin":12}' \
-o result.pdfimport { writeFile } from 'node:fs/promises';
const res = await fetch('https://api.pathclue.com/v1/web/pdf', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.TAPCUB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"url": "https://example.com/invoice/42",
"paper": "letter",
"margin": 12
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
await writeFile('result.pdf', Buffer.from(await res.arrayBuffer()));import os
import requests
res = requests.post(
"https://api.pathclue.com/v1/web/pdf",
headers={"Authorization": f"Bearer {os.environ['TAPCUB_API_KEY']}"},
json={
"url": "https://example.com/invoice/42",
"paper": "letter",
"margin": 12,
},
timeout=120,
)
res.raise_for_status()
with open("result.pdf", "wb") as f:
f.write(res.content)<?php
$ch = curl_init('https://api.pathclue.com/v1/web/pdf');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('TAPCUB_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com/invoice/42',
'paper' => 'letter',
'margin' => 12,
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 300) {
throw new RuntimeException("HTTP $status: $body");
}
file_put_contents('result.pdf', $body);package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"url":"https://example.com/invoice/42","paper":"letter","margin":12}`)
req, err := http.NewRequest("POST", "https://api.pathclue.com/v1/web/pdf", bytes.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("TAPCUB_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
if res.StatusCode >= 300 {
panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, out))
}
if err := os.WriteFile("result.pdf", out, 0o644); err != nil {
panic(err)
}
}The response body is the file itself. Save it as shown in the examples.
Request parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | url | No | — | Page to print, http or https only. Send url or html, not both. |
html | string | No | — | Your own HTML document (up to 2 MB). Scripts are turned off; images, styles and fonts it links to are loaded with the same address checks as url. |
paper | enumone of: a4 | letter | legal | a3 | a5 | tabloid | long | css | No | "a4" | Paper size. long prints the whole page as one tall page; css uses the page’s own @page size. |
landscape | boolean | No | false | Landscape orientation. |
margin | integer | No | 10 | Page margin in millimetres (0–50). |
scale | integer | No | 100 | Print scale in percent (50–150). |
layout | enumone of: paper | laptop | desktop | wide | tablet | mobile | No | — | Width the page is laid out at before it is fitted to the paper: paper (the printable width), or a screen width — laptop 1024, desktop 1366, wide 1920, tablet 820, mobile 390 px. Default: laptop for url, paper for html. |
media | enumone of: screen | print | No | — | CSS media type: screen looks like the browser, print uses the page’s print styles. Default: screen for url, print for html. |
printBackground | boolean | No | true | Print background colours and images. |
pageNumbers | boolean | No | false | Add page numbers at the bottom. |
wait | integer | No | 0 | Extra seconds to wait after the page has loaded (0–5). |
output | enumone of: binary | json | No | "binary" | binary returns the PDF itself; json returns base64 plus page info. |
Example response
Successful responses carry the X-Credits-Charged and X-Credits-Balance headers. Errors return {"error":{"code","message"}} and are never charged.
HTTP/1.1 200 OK
Content-Type: application/pdf
X-Page-Status: 200
X-Final-Url: https://example.com/invoice/42
X-Blocked-Requests: 0
<application/pdf …>What it costs
| Price | 5 credits per call |
|---|---|
| In US dollars | about $0.005 · $5 / 1,000 |
| Credits | Free or paid credits |
| Rate limit | Free 10 / min · Plus 60 / min · Pro 300 / min |
| Free daily cap | 1,000 calls a day per key on free accounts |
| Charged | Only on success — errors and timeouts are free |
What people build with it
Invoices and receipts
Render an HTML template to PDF for every order.
Reports
Turn dashboards and report pages into PDFs to email or archive.
Page archives
Keep a printable copy of terms, policies or articles as they were.
Frequently asked questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
Will my print CSS be used?
Yes. The page is printed by a headless browser, so @media print rules and page-break CSS apply.
How is it different from a screenshot?
A screenshot is one image of what is on screen. A PDF keeps text selectable and splits long pages into printable pages.
How much does the URL to PDF API cost?
Each successful call costs 5 credits per call (about $0.005). 1 credit is about $0.001. Failed calls — invalid input, unreachable sites, timeouts or errors on our side — are not charged.
Can I try it for free?
Yes. New accounts get 300 credits and every account gets 30 free credits a day, and they work on this endpoint. You can also try the matching free tool on tapcub.com without a key.
What are the rate limits?
Free accounts can make 10 calls a minute and 1,000 a day per key; Plus allows 60 a minute and Pro 300. Over the limit you get HTTP 429 with a Retry-After header, and nothing is charged.
How do I get an API key?
Sign in to the TapCub console, verify your email and create a key on the Tools → API page. Keys start with tck_ and are shown once; send them in the Authorization: Bearer header.
Get your API key
Create a key in the console and make your first call in a minute. Light endpoints run on free daily credits.