Skip to content

APITemplate-io/apitemplateio-java

Repository files navigation

openapi-java-client

APITemplate.io API Reference

  • API version: Version 2.0
    • Build date: 2023-09-17T13:38:29.640715+08:00[Asia/Singapore]

Introduction

Welcome to the APITemplate.io API v2! This is the official APITemplate.io library for Java. 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.

For more information, please visit https://apitemplate.io

Automatically generated by the OpenAPI Generator

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-java-client</artifactId>
  <version>Version 2.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral()     // Needed if the 'openapi-java-client' jar has been published to maven central.
    mavenLocal()       // Needed if the 'openapi-java-client' jar has been published to the local maven repo.
  }

  dependencies {
     implementation "org.openapitools:openapi-java-client:Version 2.0"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/openapi-java-client-Version 2.0.jar
  • target/lib/*.jar

Getting Started

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

// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
import org.openapitools.client.api.ApiIntegrationApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://rest.apitemplate.io");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    ApiIntegrationApi apiInstance = new ApiIntegrationApi(defaultClient);
    String templateId = "00377b2b1e0ee394"; // String | Your template id, it can be obtained in the web console
    Object body = null; // Object | 
    String outputImageType = "1"; // String | - Output image type(JPEG or PNG format), default to `all`. Options are `all`, `jpegOnly`,`pngOnly`. 
    Integer expiration = 5; // Integer | - 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 
    Integer cloudStorage = 1; // Integer | - 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`. 
    String 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 
    String postactionS3Bucket = "postactionS3Bucket_example"; // String | - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`. 
    String meta = "inv-iwj343jospig"; // String | - Specify an external reference ID for your own reference. It appears in the `list-objects` API. 
    try {
      ResponseSuccessImageFile result = apiInstance.createImage(templateId, body, outputImageType, expiration, cloudStorage, postactionS3Filekey, postactionS3Bucket, meta);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ApiIntegrationApi#createImage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Documentation for API Endpoints

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

Class Method HTTP request Description
ApiIntegrationApi createImage POST /v2/create-image Create an Image
ApiIntegrationApi createPdf POST /v2/create-pdf Create a PDF
ApiIntegrationApi createPdfFromHtml POST /v2/create-pdf-from-html Create a PDF from HTML
ApiIntegrationApi createPdfFromUrl POST /v2/create-pdf-from-url Create a PDF from URL
ApiIntegrationApi deleteObject GET /v2/delete-object Delete an Object
ApiIntegrationApi listObjects GET /v2/list-objects List Generated Objects
PdfManipulationApiApi mergePdfs POST /v2/merge-pdfs Join/Merge multiple PDFs
TemplateManagementApi getTemplate GET /v2/get-template Get PDF template
TemplateManagementApi listTemplates GET /v2/list-templates List Templates
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

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

hello@apitemplate.io

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages