The PDFGate API offers straightforward HTTP endpoints for generating high-quality PDF files from either raw HTML content or public URLs. This page contains all the information you need to get started and integrate PDF generation into your application quickly and reliably.
All API requests to PDFGate must be authenticated using an API key. Authentication is handled via the Authorization
header in your HTTP requests.
To get started, log in to your PDFGate account and create an API key from the Settings page in the dashboard. Ensure the key is active before using it in your code.
Include the API key in your request headers like this:
Authorization: Bearer YOUR_API_KEY
PDFGate supports two types of API keys:
Use sandbox keys for testing purposes and production keys in your live environment.
The PDFGate API uses different rate limits for each account type in the production environment. In the sandbox environment, the rate limits are the same for all account types.
Endpoint | Production | Sandbox |
---|---|---|
POST /generate/pdf | Per account type:
| Per account type:
|
GET /document | 40 concurrent requests | 10 concurrent requests |
GET /file | 40 concurrent requests | 10 concurrent requests |
Code | Error |
---|---|
400 | Bad request |
401 | Unauthorized |
404 | Not found |
422 | Unprocessable entity |
429 | Too many requests |
500 | Internal server error |
To create a PDF document, send either a URL or raw HTML in the request body. Include your API key in the headers and set the appropriate Content-Type
.
By default, the endpoint returns a raw PDF file. If you prefer a structured response, you can include the jsonResponse
field in your request to receive a JSON payload with metadata about the generated document.
Endpoint
Examples
const fetch = require("node-fetch");
const fs = require("fs");
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
url: "https://en.wikipedia.org/wiki/PDF",
pageSizeType: "a4",
}),
};
fetch("https://api.pdfgate.com/v1/generate/pdf", options).then( async (result) => {
if (result.status === 201) {
result.body.pipe(fs.createWriteStream("file_name.pdf"));
} else {
const error = await result.json();
console.log(error);
}
});
Request body fields
Available responses
Retrieves a generated document object containing metadata and file details.
Endpoint
Examples
const fetch = require("node-fetch");
const options = {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
};
fetch("https://api.pdfgate.com/document/{documentId}", options).then( async (result) => {
const data = await result.json();
});
Response
Retrieves a raw PDF file previously generated.
Note: To access a generated file, the “Save files for one month” option must be enabled in your Dashboard's settings. This option is disabled by default.
Endpoint
Examples
const fetch = require("node-fetch");
const fs = require("fs");
const options = {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
};
fetch("https://api.pdfgate.com/file/{documentId}", options).then( async (result) => {
result.body.pipe(fs.createWriteStream("file_name.pdf"));
});
Response