Get up and running with Operyn.ai in under 5 minutes
Base URL: https://html2pdf.operyn.ai
curl -X POST https://html2pdf.operyn.ai/api/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com"
}'
{
"success": true,
"downloadUrl": "https://cdn.operyn.ai/files/abc123.pdf",
"filename": "pdf_abc123.pdf",
"size": 245678
}
All API requests require authentication using your API key
Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
⚠️ Keep your API key secure! Never expose it in client-side code or public repositories.
Convert any URL or HTML to a pixel-perfect PDF
POST /api/v1/pdf
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The URL to convert to PDF |
format |
string | No | Paper format: A4, Letter, Legal (default: A4) |
options |
object | No | Additional PDF options (see below) |
{
"url": "https://example.com/invoice",
"format": "A4",
"options": {
"printBackground": true,
"margin": {
"top": "20mm",
"right": "20mm",
"bottom": "20mm",
"left": "20mm"
},
"displayHeaderFooter": false,
"landscape": false
}
}
{
"success": true,
"downloadUrl": "/files/pdf_abc123.pdf",
"filename": "pdf_abc123.pdf",
"size": 245678
}
Capture high-quality screenshots of any webpage
POST /api/v1/screenshot
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The URL to screenshot |
width |
number | No | Viewport width (default: 2560) |
fullPage |
boolean | No | Capture full page (default: true) |
format |
string | No | png or jpeg (default: png) |
{
"url": "https://example.com",
"width": 1920,
"fullPage": true,
"format": "png"
}
Implementation examples in popular languages
const response = await fetch('https://html2pdf.operyn.ai/api/v1/pdf', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com/invoice',
format: 'A4'
})
});
const data = await response.json();
console.log('PDF URL:', data.downloadUrl);
import requests
response = requests.post(
'https://html2pdf.operyn.ai/api/v1/pdf',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'url': 'https://example.com/invoice',
'format': 'A4'
}
)
data = response.json()
print(f"PDF URL: {data['downloadUrl']}")
$ch = curl_init('https://html2pdf.operyn.ai/api/v1/pdf');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'url' => 'https://example.com/invoice',
'format' => 'A4'
]));
$response = curl_exec($ch);
$data = json_decode($response);
echo "PDF URL: " . $data->downloadUrl;
Understanding and handling API errors
| Code | Meaning |
|---|---|
200 |
Success - File generated |
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid API key |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Server Error - Something went wrong |
{
"error": "Invalid API key",
"message": "The provided API key is invalid or expired"
}