Programmatic access to web page conversion via REST API
All API requests must include your API key in the X-API-Key header:
X-API-Key: p2d_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxxxx
Convert a web page URL to PDF, Word (DOCX), or Excel (XLSX) format.
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | Full URL of the page to convert (must start with http:// or https://) |
format |
string | Yes | Output format: pdf, docx, or xlsx |
mode |
string | No | Extraction mode: full (default), article, or tables |
clean |
boolean | No | Remove ads and popups (default: true) |
wait |
number | No | Wait time in milliseconds before capture (default: 2000, max: 10000) |
curl -X POST https://page2doc.com/api/v1/convert \
-H "Content-Type: application/json" \
-H "X-API-Key: p2d_api_your_key_here" \
-d '{
"url": "https://example.com/article",
"format": "pdf",
"mode": "article",
"clean": true
}' \
--output document.pdf
const response = await fetch('https://page2doc.com/api/v1/convert', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY_HERE'
},
body: JSON.stringify({
url: 'https://example.com/article',
format: 'docx',
mode: 'article',
clean: true
})
});
const blob = await response.blob();
const buffer = Buffer.from(await blob.arrayBuffer());
fs.writeFileSync('output.docx', buffer);
import requests
import os
response = requests.post(
'https://page2doc.com/api/v1/convert',
headers={
'Content-Type': 'application/json',
'X-API-Key': os.environ['PAGE2DOC_API_KEY']
},
json={
'url': 'https://example.com/article',
'format': 'pdf',
'mode': 'article',
'clean': True
}
)
with open('output.pdf', 'wb') as f:
f.write(response.content)
Status: 200 OK
Content-Type: application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document, or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
The response body contains the binary document file.
| Status | Error | Description |
|---|---|---|
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Pro subscription expired or API key revoked |
| 413 | Payload Too Large | Page content exceeds size limit (10MB for Pro) |
| 422 | Unprocessable Entity | Invalid URL or unsupported format |
| 429 | Too Many Requests | Rate limit exceeded (500 requests/day for Pro) |
| 500 | Internal Server Error | Conversion failed or server error |
Verify your API key and check usage statistics.
curl https://page2doc.com/api/v1/status \
-H "X-API-Key: p2d_api_your_key_here"
{
"valid": true,
"plan": "pro",
"usage": {
"today": 12,
"month": 347,
"limit": 500
},
"createdAt": "2025-02-15T10:30:00Z"
}
Rate limit headers are included in all responses:
X-RateLimit-Limit: 500
X-RateLimit-Remaining: 487
X-RateLimit-Reset: 1708041600
mode values (article for content, tables for data)wait times for JavaScript-heavy pages (3000-5000ms)/api/v1/status endpointFor API support, rate limit increases, or custom integrations, contact us at api@page2doc.com