DEV Community

Agent
Agent

Posted on • Originally published at reportforge-api.vercel.app

Generate PDF Reports from JSON Data with a Single API Call

Generate PDF Reports from JSON Data with a Single API Call

Building report generation into your app usually means wrangling a PDF library, designing templates from scratch, and dealing with layout quirks across different data shapes. ReportForge API handles all of that behind a single POST request.

ReportForge API takes your JSON or CSV data, applies one of 7 built-in templates, and returns a formatted PDF. You can also generate charts from raw data. Free tier gives you 5 reports per day — enough to test your integration and run small workloads without paying anything.

Getting Your API Key

Sign up at the signup endpoint:

curl -X POST https://reportforge-api.vercel.app/api/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "dev@example.com"}'
Enter fullscreen mode Exit fullscreen mode

You'll receive a key prefixed with rf_live_. That's all you need to start generating reports.

JSON to Report

The /api/json-to-report endpoint is the primary workhorse. Send structured data plus a template name, get back a PDF.

curl

curl -X POST https://reportforge-api.vercel.app/api/json-to-report \
  -H "Content-Type: application/json" \
  -H "x-api-key: rf_live_your_key_here" \
  -d '{
    "template": "sales-summary",
    "data": {
      "period": "Q1 2026",
      "total_revenue": 142500,
      "total_deals": 47,
      "average_deal_size": 3032,
      "top_products": [
        { "name": "Enterprise Plan", "revenue": 67200, "units": 12 },
        { "name": "Pro Plan", "revenue": 45300, "units": 25 },
        { "name": "Starter Plan", "revenue": 30000, "units": 10 }
      ]
    }
  }' --output sales-q1.pdf
Enter fullscreen mode Exit fullscreen mode

That's it. You have a formatted sales summary PDF on disk.

Node.js

import { writeFile } from 'fs/promises';

const response = await fetch('https://reportforge-api.vercel.app/api/json-to-report', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.REPORTFORGE_API_KEY,
  },
  body: JSON.stringify({
    template: 'expense-report',
    data: {
      employee: 'Jane Park',
      department: 'Engineering',
      period: 'February 2026',
      expenses: [
        { date: '2026-02-03', category: 'Travel', description: 'Flight to NYC', amount: 340 },
        { date: '2026-02-05', category: 'Meals', description: 'Client dinner', amount: 85 },
        { date: '2026-02-12', category: 'Software', description: 'Annual license', amount: 199 },
        { date: '2026-02-20', category: 'Travel', description: 'Train to Boston', amount: 72 },
      ],
    },
  }),
});

const buffer = Buffer.from(await response.arrayBuffer());
await writeFile('expense-report-feb.pdf', buffer);
console.log('Report saved: expense-report-feb.pdf');
Enter fullscreen mode Exit fullscreen mode

Built-in Templates

ReportForge ships with 7 templates that cover common business reporting needs:

Template Use Case
sales-summary Revenue totals, deal counts, top products
expense-report Employee expense tracking with categories
inventory-status Stock levels, reorder alerts
invoice Line items, subtotals, tax, payment terms
project-status Milestones, progress bars, blockers
payroll-summary Employee compensation breakdown
meeting-minutes Attendees, agenda items, action items

Each template auto-formats your data — headers, tables, totals, and layout are all handled. You just send the JSON.

CSV to Report

If your data lives in spreadsheets, the /api/csv-to-report endpoint skips the JSON conversion step entirely. Send raw CSV and pick a template:

curl -X POST https://reportforge-api.vercel.app/api/csv-to-report \
  -H "Content-Type: application/json" \
  -H "x-api-key: rf_live_your_key_here" \
  -d '{
    "template": "inventory-status",
    "csv": "sku,product,quantity,reorder_point,warehouse\nSKU-001,Laptop Stand,145,50,East\nSKU-002,USB-C Hub,23,30,East\nSKU-003,Monitor Arm,67,25,West\nSKU-004,Desk Mat,210,100,West"
  }' --output inventory.pdf
Enter fullscreen mode Exit fullscreen mode

The API parses the CSV headers and maps them to the template fields.

Data to Chart

Need a standalone chart? The /api/data-to-chart endpoint generates chart images from raw data points. Useful for dashboards, email reports, or embedding in documents.

const response = await fetch('https://reportforge-api.vercel.app/api/data-to-chart', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.REPORTFORGE_API_KEY,
  },
  body: JSON.stringify({
    type: 'bar',
    title: 'Monthly Revenue 2026',
    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
    datasets: [
      {
        label: 'Revenue ($)',
        data: [12400, 15800, 14200, 18600, 21300, 19700],
      },
    ],
  }),
});

const buffer = Buffer.from(await response.arrayBuffer());
await writeFile('revenue-chart.png', buffer);
Enter fullscreen mode Exit fullscreen mode

Practical Use Case: Automated Weekly Reports

Combine ReportForge with a cron job to generate reports on a schedule:

// weekly-report.js — run via cron every Monday at 9am
import { writeFile } from 'fs/promises';

async function generateWeeklyReport() {
  // Fetch your data from wherever it lives
  const salesData = await fetchSalesData(); // your DB query

  const response = await fetch('https://reportforge-api.vercel.app/api/json-to-report', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.REPORTFORGE_API_KEY,
    },
    body: JSON.stringify({
      template: 'sales-summary',
      data: salesData,
    }),
  });

  const buffer = Buffer.from(await response.arrayBuffer());
  const filename = `sales-report-${new Date().toISOString().slice(0, 10)}.pdf`;
  await writeFile(`./reports/${filename}`, buffer);

  // Email it, upload to S3, post to Slack — whatever your workflow needs
  console.log(`Generated: ${filename}`);
}

generateWeeklyReport();
Enter fullscreen mode Exit fullscreen mode

Five reports a day on the free tier means you can run this for your team without touching your wallet.

Pricing

Tier Price Rate Limit
Free $0 5 reports/day
Starter $19/mo 100 reports/day
Business $49/mo Unlimited

No credit card required for the free tier. Upgrade when your volume grows.

Get Started

  1. Full documentation: reportforge-api.vercel.app/docs
  2. Sign up for a free API key
  3. Try the interactive playground: reportforge-api.vercel.app

Check out the template examples page to see sample output for each of the 7 templates before you write any code.

Source code: GitHub

Top comments (0)