The PDFGate API provides simple HTTP endpoints to generate high quality PDF files based on an HTML document or a URL resource. In this page you will find everything you need in order to use the API.
To use the API, you need to always authenticate the HTTP requests you initiate. PDFGate is using API keys for the authentication.
Firstly, you need to login to your account and create an API key. Make sure it is active and then you can use it in your source code.
In your HTTP requests you need to provide the Authorization header with the value Bearer YOUR_API_KEY.
There are two types of API keys. Production and Sandbox keys and they have the following format.
The PDFGate API is using different rate limits for each account type in Production environment for different endpoints. For 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 you need to send a URL or HTML in the request body and in the headers you should include your API key and the content type.
With this endpoint you can have two response types. By default you will get a raw PDF file and by specifying the field jsonResponse you can get a JSON response with the details of your 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/Cupcake",
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
Gets a generated document object.
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
Gets a raw PDF file.
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