A production-ready REST API that generates professional PDFs from JSON data, HTML, or tabular data. Built with FastAPI + ReportLab. Designed for deployment on Railway/Render and monetization on RapidAPI, Zyla, and APILayer.
| Method | Endpoint | Description |
|---|---|---|
| POST | /generate/invoice |
JSON → Professional Invoice PDF |
| POST | /generate/from-html |
HTML string → PDF |
| POST | /generate/report |
Tabular data → Report PDF |
| GET | /health |
Health check |
git clone https://github.com/yourusername/pdf-generator-api
cd pdf-generator-api
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reloadAPI docs available at: http://localhost:8000/docs
All endpoints require an X-API-Key header:
curl -X POST http://localhost:8000/generate/invoice \
-H "X-API-Key: demo-key-123" \
-H "Content-Type: application/json" \
-d @payload.json \
--output invoice.pdfPOST /generate/invoice
{
"invoice_number": "INV-2025-042",
"issue_date": "2025-05-08",
"due_date": "2025-06-08",
"company": {
"name": "Acme Corp",
"address": "123 Main St",
"city": "Mexico City, MX",
"email": "billing@acme.com"
},
"client": {
"name": "John Doe",
"address": "456 Oak Ave, NY",
"email": "john@example.com"
},
"items": [
{"description": "Web Development", "quantity": 10, "unit_price": 150.00},
{"description": "UI Design", "quantity": 5, "unit_price": 80.00}
],
"tax_rate": 16.0,
"notes": "Payment via bank transfer. Net 30."
}docker build -t pdf-generator-api .
docker run -p 8000:8000 --env-file .env pdf-generator-api- Push to GitHub
- Go to railway.app → New Project → Deploy from GitHub
- Add environment variables from
.env.example - Railway auto-detects Dockerfile and deploys
- RapidAPI — 20% commission, 4M+ developers
- Zyla API Hub — curated, strong marketing support
- APILayer — 15% commission, quality-focused
| Plan | Requests/month | Price |
|---|---|---|
| Free | 50 | $0 |
| Basic | 500 | $9/mo |
| Pro | 5,000 | $29/mo |
| Ultra | 50,000 | $79/mo |
- 10 Basic + 5 Pro = $90 + $145 = $235/mo
- 20 Basic + 15 Pro + 3 Ultra = $180 + $435 + $237 = $852/mo
- WeasyPrint for full CSS/HTML support
- PDF templates (contracts, receipts, certificates)
- Async batch generation
- Webhook callback on completion
- Database usage tracking per API key
Pablo Cueto Gatica — AI Automation & Backend Development — LATAM