⚡ REST API

PDF Conversion API
for Developers

Convert HTML, images, and documents to PDF with a single API call. Free tier included — no credit card required. Files are processed and immediately discarded.

Get Free API Key View Endpoints →

Quick Start

Get up and running in under 2 minutes. No SDK needed — just HTTP requests.

1. Get your API key

Enter your email to generate a free API key instantly:

🎉 Your API key:

⚠ Save this key now — it cannot be retrieved later. Store it as an environment variable.

2. Make your first conversion

bash
curl -X POST https://buildpdf.co/api/v1/convert \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "html": "<h1>Hello World</h1><p>My first PDF via API!</p>",
    "options": {
      "pageSize": "a4",
      "orientation": "portrait"
    }
  }'
javascript
const response = await fetch('https://buildpdf.co/api/v1/convert', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.BUILDPDF_API_KEY,
  },
  body: JSON.stringify({
    html: '<h1>Hello World</h1><p>My first PDF!</p>',
    options: { pageSize: 'a4' }
  })
});

const { pdf } = await response.json();
// pdf is a base64-encoded PDF — save it:
fs.writeFileSync('output.pdf', Buffer.from(pdf, 'base64'));
python
import requests, base64, os

response = requests.post(
    "https://buildpdf.co/api/v1/convert",
    headers={"X-API-Key": os.environ["BUILDPDF_API_KEY"]},
    json={
        "html": "<h1>Hello World</h1><p>My first PDF!</p>",
        "options": {"pageSize": "a4"}
    }
)

pdf_bytes = base64.b64decode(response.json()["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
php
<?php
$ch = curl_init('https://buildpdf.co/api/v1/convert');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'X-API-Key: ' . getenv('BUILDPDF_API_KEY'),
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'html'    => '<h1>Hello World</h1>',
        'options' => ['pageSize' => 'a4'],
    ]),
]);
$result = json_decode(curl_exec($ch), true);
file_put_contents('output.pdf', base64_decode($result['pdf']));

Endpoints

POST /api/v1/convert

Convert HTML, text, or image files to PDF. Send content directly or as base64-encoded files.

Request Body

ParameterTypeDescription
html string Raw HTML content to convert. optional
text string Plain text content. optional
file string Base64-encoded file (image or document). optional
format string File format hint when using file: image, text, html, docx. optional
options object PDF options (see below). optional

Options Object

FieldDefaultValues
pageSizea4a4, letter, a3, legal
orientationportraitportrait, landscape
margin10Margin in mm (0–50)
quality0.95Image quality 0.1–1.0
POST /api/v1/extract

Extract text or images from a PDF file. Requires Starter plan or above.

ParameterTypeDescription
file string Base64-encoded PDF file. required
output string text or images. Default: text. optional
GET /api/v1/usage

Check your current usage, remaining quota, and tier limits. Does not count as a conversion.

POST /api/v1/register

Register for a new API key. Returns a bpdf_ prefixed key.

ParameterTypeDescription
email string Your email address. required

Authentication

All API requests require an API key. Pass it via one of these methods:

headers
# Option 1: X-API-Key header (recommended)
X-API-Key: bpdf_your_key_here

# Option 2: Authorization Bearer
Authorization: Bearer bpdf_your_key_here

Live Playground

Test the API right here — enter your API key and HTML content to generate a PDF.

Try it out


Pricing

Start free. Upgrade when you need more. No credit card required for the free tier.

Free
$0/mo
100 conversions/mo
5 MB max file
10 req/min
"Powered by" watermark
HTML, Image, Text → PDF
Starter
$9/mo
1,000 conversions/mo
25 MB max file
60 req/min
No watermark
+ PDF Extraction
Business
$79/mo
50,000 conversions/mo
100 MB max file
1,000 req/min
Priority support
All features included

Error Codes

CodeMeaningWhat to do
400Bad RequestCheck your request body — a required field is missing or malformed.
401UnauthorizedAPI key is missing or invalid. Check the X-API-Key header.
403ForbiddenFeature not available on your tier. Upgrade your plan.
413File Too LargeFile exceeds your tier's size limit.
429Rate LimitedToo many requests. Wait and retry, or upgrade for higher limits.
500Server ErrorSomething went wrong on our end. Retry, or contact support.