Skip to main content

Getting Started

This page will guide you through the steps required to start using the reportgen API for generating PDF reports. By the end of this guide, you will have created your first PDF report using custom data and a templating engine.

1. Sign Up and Obtain an Access Key

Before you can make any requests to the API, you'll need an access key. Here's how you can obtain one:

  • From the website: Go to the Access Keys section of your account dashboard, create a new key, and copy it.
  • Via the API: You can also generate access keys programmatically by making a POST request to /access-keys. For detailed instructions, see the Auth page.

Once you have your access key, include it in the X-API-Key header for all requests.

2. Making Your First Request

Let’s walk through a simple example where you’ll generate a PDF report with your custom data and a template.

Example: Generate a PDF Asynchronously

Here’s how to generate a PDF using the EJS templating engine, asynchronously.

Request:

curl -X POST "https://reportgen.io/api/v1/generate-pdf-async" \
-H "X-API-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"html_template": "<html><body><%= Name %></body></html>",
"data": {
"Name": "John Doe"
},
"engine": "ejs"
}'

In this example:

  • html_template: A simple EJS template that includes a placeholder for Name.
  • data: A JSON object that contains the value for the Name field.
  • engine: Specifies the EJS templating engine.

Response:

{
"report_id": "123e4567-e89b-12d3-a456-426614174000"
}

This response contains a unique report_id that you can use to retrieve the report or check its status.

3. Retrieving the Report

Once your PDF is generated, you can retrieve the download link using the report ID:

curl -X GET "https://reportgen.io/api/v1/reports/{reportID}/download" \
-H "X-API-Key: YOUR_ACCESS_KEY" | jq -r '.data'

4. Using Raw HTML to PDF

If you don’t want to use a templating engine and prefer to work with pure HTML, you can directly pass raw HTML to the API.

Request:

curl -X POST "https://reportgen.io/api/v1/generate-pdf-async" \
-H "X-API-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"html_template": "<html><body>Hello, World!</body></html>",
"engine": "raw"
}'

This will generate a PDF from the raw HTML you provide without any templating.

5. Managing Reports

You can view all your generated reports and manage them through the following endpoints:

  • List Reports: GET /reports
  • Delete a Report: DELETE /reports/{reportID}

6. Explore Use Cases

To see more detailed examples and real-world use cases, visit the Examples section, where you can find step-by-step guides on various scenarios, such as generating invoices, reports, and more.

7. Next Steps

  • Explore more endpoints in the API reference.
  • Learn about Authentication and how to manage your access keys in the Auth section.

Need Help?

For additional support, contact us via the contact form.