Skip to content

PabsCueto/pdf-generator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧾 PDF Generator API

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.


🚀 Endpoints

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

🛠 Local Setup

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 --reload

API docs available at: http://localhost:8000/docs


🔑 Authentication

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.pdf

📦 Example: Generate Invoice

POST /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

docker build -t pdf-generator-api .
docker run -p 8000:8000 --env-file .env pdf-generator-api

☁️ Deploy to Railway (Free)

  1. Push to GitHub
  2. Go to railway.app → New Project → Deploy from GitHub
  3. Add environment variables from .env.example
  4. Railway auto-detects Dockerfile and deploys

💰 Monetization Strategy

Platforms (publish on all 3)

  • RapidAPI — 20% commission, 4M+ developers
  • Zyla API Hub — curated, strong marketing support
  • APILayer — 15% commission, quality-focused

Suggested Pricing Tiers

Plan Requests/month Price
Free 50 $0
Basic 500 $9/mo
Pro 5,000 $29/mo
Ultra 50,000 $79/mo

Revenue Projection

  • 10 Basic + 5 Pro = $90 + $145 = $235/mo
  • 20 Basic + 15 Pro + 3 Ultra = $180 + $435 + $237 = $852/mo

📌 Roadmap

  • WeasyPrint for full CSS/HTML support
  • PDF templates (contracts, receipts, certificates)
  • Async batch generation
  • Webhook callback on completion
  • Database usage tracking per API key

👨‍💻 Author

Pablo Cueto Gatica — AI Automation & Backend Development — LATAM

About

REST API to generate professional PDFs from JSON, HTML, and tabular data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors