GET /v1/pdf/{page_id}
Generate and download a PDF rendering of a Wikipedia page.
Credit Cost: 10 credits per request
PDF generation is computationally expensive. Each request consumes 10 credits from your monthly quota.
GET https://api.wikirest.com/v1/pdf/{page_id}
GET https://api.wikirest.com/v1/pdf/{page_id}.pdf Path Parameters
| Parameter | Type | Description |
|---|---|---|
page_id | integer | Wikipedia page ID (e.g., 736 for Albert Einstein) |
Response
Returns a PDF file with the following headers:
| Header | Value |
|---|---|
Content-Type | application/pdf |
Content-Disposition | attachment; filename="Article_Title.pdf" |
X-Credit-Cost | 10 |
PDF Features
- A4 page size with proper margins
- Page numbers in footer
- Clean typography optimized for reading
- Section headings preserved from article structure
- License information included in footer
- Source attribution with Wikipedia link
Examples
Download a page as PDF
curl -H "X-API-Key: YOUR_KEY" \
"https://api.wikirest.com/v1/pdf/736" \
--output einstein.pdf Using the .pdf extension
curl -H "X-API-Key: YOUR_KEY" \
"https://api.wikirest.com/v1/pdf/736.pdf" \
--output einstein.pdf Python example
import requests
response = requests.get(
"https://api.wikirest.com/v1/pdf/736",
headers={"X-API-Key": "YOUR_KEY"}
)
if response.status_code == 200:
with open("einstein.pdf", "wb") as f:
f.write(response.content)
print("PDF saved!")
else:
print(f"Error: {response.json()}") JavaScript example
const response = await fetch('https://api.wikirest.com/v1/pdf/736', {
headers: {
'X-API-Key': 'YOUR_KEY'
}
});
if (response.ok) {
const blob = await response.blob();
const url = URL.createObjectURL(blob);
// Create download link
const a = document.createElement('a');
a.href = url;
a.download = 'article.pdf';
a.click();
} Credit Usage
PDF generation costs 10 credits per request because it:
- Fetches all chunks for the entire page
- Renders markdown to HTML
- Generates a high-quality PDF document
- Requires significant server resources
The X-Credit-Cost header in the response confirms the credits charged.
Check your remaining quota with the X-Quota-Remaining header.
Error Responses
| Status | Error | Description |
|---|---|---|
400 | page_id must be an integer | Invalid page_id format |
404 | page not found | Page ID does not exist |
401 | unauthorized | API key not provided |
429 | quota_exceeded | Monthly quota exceeded (need 10 credits available) |
500 | PDF generation failed | Server-side PDF generation error |
Server Requirements
PDF generation requires wkhtmltopdf to be installed on the server.
If you receive a "PDF generation failed" error, the server may not have the required dependencies.