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

MethodEndpointDescription
POST/pdf/markdownConvert Markdown to PDF
POST/pdf/htmlConvert HTML to PDF
POST/pdf/urlConvert URL to PDF
POST/pdf/templateRender template to PDF

Resources

MethodEndpointDescription
GET/themesList available themes
GET/templatesList available templates

Account Management

MethodEndpointDescription
POST/keysCreate API key
GET/keysList API keys
DELETE/keys/:idDelete API key
GET/usageGet 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

CodeDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Feature not available on your plan
404Not Found
429Too Many Requests - Rate limit exceeded
500Internal 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:

UnitExampleDescription
mm20mmMillimeters
cm2cmCentimeters
in0.5inInches
px50pxPixels

Rate Limits

API requests are rate-limited based on your plan:

PlanRequests/MinuteMonthly PDFs
Free310
Pro303,000
Business6015,000
Enterprise120Unlimited

See Rate Limits for more details.


Next Steps