API Overview
Overview of the PDF API endpoints and conventions.
API Overview
The PDF API is organized around REST principles. It uses standard HTTP methods, returns JSON-encoded responses, and uses standard HTTP response codes.
Base URL
All API requests should be made to:
https://api.pdfapi.dev/v1
Endpoints
PDF Conversion
| Method | Endpoint | Description |
|---|---|---|
| POST | /pdf/markdown | Convert Markdown to PDF |
| POST | /pdf/html | Convert HTML to PDF |
| POST | /pdf/url | Convert URL to PDF |
| POST | /pdf/template | Render template to PDF |
Resources
| Method | Endpoint | Description |
|---|---|---|
| GET | /themes | List available themes |
| GET | /templates | List available templates |
Account Management
| Method | Endpoint | Description |
|---|---|---|
| POST | /keys | Create API key |
| GET | /keys | List API keys |
| DELETE | /keys/:id | Delete API key |
| GET | /usage | Get usage statistics |
Request Format
All POST requests should include:
Content-Type: application/json
Authorization: Bearer sk_live_xxx
Request body should be valid JSON.
Response Format
Success Response
PDF generation endpoints return the PDF file directly:
Content-Type: application/pdf
Other endpoints return JSON:
{
"data": { ... }
}
Error Response
{
"error": {
"code": "ERROR_CODE",
"message": "Human-readable message",
"details": { ... }
}
}
See Error Codes for a complete reference.
HTTP Status Codes
| Code | Description |
|---|---|
200 | Success |
201 | Created |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Feature not available on your plan |
404 | Not Found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Common Request Options
All PDF generation endpoints accept these optional parameters in the options object:
{
"options": {
"format": "A4",
"landscape": false,
"margin": {
"top": "20mm",
"bottom": "20mm",
"left": "15mm",
"right": "15mm"
},
"print_background": true,
"scale": 1.0,
"wait_for": 0,
"header": "<div>Header HTML</div>",
"footer": "<div>Footer HTML</div>"
}
}
See PDF Options for detailed documentation.
Paper Formats
Supported formats: A4, A3, A5, Letter, Legal, Tabloid
See Page Formats for dimensions and use cases.
Margins
Margins can be specified in various units:
| Unit | Example | Description |
|---|---|---|
mm | 20mm | Millimeters |
cm | 2cm | Centimeters |
in | 0.5in | Inches |
px | 50px | Pixels |
Rate Limits
API requests are rate-limited based on your plan:
| Plan | Requests/Minute | Monthly PDFs |
|---|---|---|
| Free | 3 | 10 |
| Pro | 30 | 3,000 |
| Business | 60 | 15,000 |
| Enterprise | 120 | Unlimited |
See Rate Limits for more details.
Next Steps
- Quickstart Guide - Generate your first PDF
- Authentication - API key management
- Code Examples - Ready-to-use examples in multiple languages