curl https://api.dynamicdocumentapi.com/v1/pdf/from-url \
-H "Authorization: Bearer $DYNAMIC_DOCUMENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/pricing",
"pdf": {
"paper": { "size": "Letter" },
"wait": { "until": "networkidle", "timeout_ms": 20000 }
},
"delivery": "binary"
}' \
--output page.pdf
// Node.js 18+ (built-in fetch)
const res = await fetch("https://api.dynamicdocumentapi.com/v1/pdf/from-url", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DYNAMIC_DOCUMENT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com/pricing",
pdf: {
paper: { size: "Letter" },
wait: { until: "networkidle", timeout_ms: 20000 },
},
}),
});
const render = await res.json();
console.log(render.files[0].url); // signed URL, valid for 1 hour
import os
import requests
res = requests.post(
"https://api.dynamicdocumentapi.com/v1/pdf/from-url",
headers={"Authorization": f"Bearer {os.environ['DYNAMIC_DOCUMENT_API_KEY']}"},
json={
"url": "https://example.com/pricing",
"pdf": {
"paper": {"size": "Letter"},
"wait": {"until": "networkidle", "timeout_ms": 20000},
},
"delivery": "binary",
},
timeout=60,
)
res.raise_for_status()
with open("page.pdf", "wb") as f:
f.write(res.content)
<?php
$payload = [
'url' => 'https://example.com/pricing',
'pdf' => [
'paper' => ['size' => 'Letter'],
'wait' => ['until' => 'networkidle', 'timeout_ms' => 20000],
],
];
$ch = curl_init('https://api.dynamicdocumentapi.com/v1/pdf/from-url');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('DYNAMIC_DOCUMENT_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$render = json_decode(curl_exec($ch), true);
echo $render['files'][0]['url'];