Skip to content

APITemplate-io/apitemplateio-javascript

Repository files navigation

APITemplate.io

ApiTemplateIoApiReference - JavaScript client for APITemplate.io

Introduction

Welcome to the APITemplate.io API v2! This is the official APITemplate.io library for Javascript. For more details, see our REST API Reference.

APITemplate.io provides PDF generation services including Template-based PDF generation, HTML to PDF, and URL to PDF conversions, as well as an image generation API.

This page contains the documentation on how to use APITemplate.io through API calls. With the APITemplate.io API, you can create PDF documents and images, as well as manage your templates.

Our API is built on RESTful HTTP, so you can utilize any HTTP/REST library of your choice in your preferred programming language to interact with APITemplate.io's API.

Steps to produce PDFs/Images

  1. Design your template(s) using our intuitive drag-and-drop template editor or the HTML editor and save it.
  2. Integrate your workflow, either with platforms like Zapier, Make.com/Integromat, Bubble.io, or any programming languages that support REST API, to send us the JSON data along with the template ID/URL/or HTML content.
  3. Our REST API will then return a download URL for the images (in PNG and JPEG formats) or PDFs.

Authentication

Upon signing up for an account, an API key will be generated for you. If needed, you can reset this API key via the web console (under the "API Integration" section).

To integrate with our services, you need to authenticate with the APITemplate.io API. Provide your secret key in the request header using the X-API-KEY field.

Content Type and CORS

Request Content-Type The Content-Type for POST and GET requests is set to application/json.

Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with W3C spec. And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.

Regional API endpoint(s)

A regional API endpoint is intended for customers in the same region. The data for the request and generated PDFs/images are processed and stored within the region.

The regions are:

Region Endpoint Max Timeout (Seconds) Max Payload Size(MB)**
Default (Singapore) https://rest.apitemplate.io 100 1
Europe (Frankfurt) https://rest-de.apitemplate.io 100 1
US East (N. Virginia) https://rest-us.apitemplate.io 100 1
Australia (Sydney) https://rest-au.apitemplate.io 30 6

Alternative Regions:

Region Endpoint Max Timeout (Seconds) Max Payload Size(MB)**
Default (Singapore) https://rest-alt.apitemplate.io 30 6
Europe (Frankfurt) https://rest-alt-de.apitemplate.io 30 6
US East (N. Virginia) https://rest-alt-us.apitemplate.io 30 6

** Note:

  • Payload size applies to request and response
  • If "export_type" is set to json which output file that on AWS S3 doesn't have the limitation
  • If the "export_type" is set to file which returns binary data of the generated PDF, the file size of the generated PDF is limited to either 6MB or 1MB based on the region

Other regions are available on request, contact us at hello@apitemplate.io for more information

Rate limiting

Our API endpoints use IP-based rate limiting to ensure fair usage and prevent abuse. Users are allowed to make up to 100 requests per 10 seconds. This rate limit is designed to accommodate a reasonable volume of requests while maintaining optimal performance for all users.

However, if you exceed this limit and make additional requests, you will receive a response with HTTP code 429. This status code indicates that you have reached the rate limit and need to wait before making further requests.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: Version 2.0
  • Package version: Version 2.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen For more information, please visit https://apitemplate.io

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install APITemplate.io----save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your APITemplate.io from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID----save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var ApiTemplateIoApiReference = require('APITemplate.io');

var defaultClient = ApiTemplateIoApiReference.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
var ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix['X-API-KEY'] = "Token"

var api = new ApiTemplateIoApiReference.APIIntegrationApi()
var templateId = 00377b2b1e0ee394; // {String} Your template id, it can be obtained in the web console
var body = {key: null}; // {Object} 
var opts = {
  'outputImageType': 1, // {String} - Output image type(JPEG or PNG format), default to `all`. Options are `all`, `jpegOnly`,`pngOnly`. 
  'expiration': 5, // {Number} - Expiration of the generated PDF in minutes(default to `0`, store permanently)   - Use `0` to store on cdn permanently   - Or use the range between `1` minute and `10080` minutes(7 days) to specify the expiration of the generated PDF 
  'cloudStorage': 1, // {Number} - Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Action` to upload the PDFs/Images to your own S3, please set it to `0`. 
  'postactionS3Filekey': "postactionS3Filekey_example", // {String} - This is to specify the file name for `Post Action(S3 Storage)`. - Please do not specify the file extension - Please make sure the file name is unique - You might use slash (/) as the folder delimiter 
  'postactionS3Bucket': "postactionS3Bucket_example", // {String} - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`. 
  'meta': inv-iwj343jospig // {String} - Specify an external reference ID for your own reference. It appears in the `list-objects` API. 
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.createImage(templateId, body, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://rest.apitemplate.io

Class Method HTTP request Description
ApiTemplateIoApiReference.APIIntegrationApi createImage POST /v2/create-image Create an Image
ApiTemplateIoApiReference.APIIntegrationApi createPdf POST /v2/create-pdf Create a PDF
ApiTemplateIoApiReference.APIIntegrationApi createPdfFromHtml POST /v2/create-pdf-from-html Create a PDF from HTML
ApiTemplateIoApiReference.APIIntegrationApi createPdfFromUrl POST /v2/create-pdf-from-url Create a PDF from URL
ApiTemplateIoApiReference.APIIntegrationApi deleteObject GET /v2/delete-object Delete an Object
ApiTemplateIoApiReference.APIIntegrationApi listObjects GET /v2/list-objects List Generated Objects
ApiTemplateIoApiReference.PDFManipulationAPIApi mergePdfs POST /v2/merge-pdfs Join/Merge multiple PDFs
ApiTemplateIoApiReference.TemplateManagementApi getTemplate GET /v2/get-template Get PDF template
ApiTemplateIoApiReference.TemplateManagementApi listTemplates GET /v2/list-templates List Templates
ApiTemplateIoApiReference.TemplateManagementApi updateTemplate POST /v2/update-template Update PDF Template

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

ApiKeyAuth

  • Type: API key
  • API key parameter name: X-API-KEY
  • Location: HTTP header

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published