Skip to content

APITemplate-io/apitemplateio-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APITemplateio - the C# library for the APITemplate.io API Reference

Introduction

Welcome to the APITemplate.io API v2! This is the official APITemplate.io library for C#. 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 C# SDK is automatically generated by the OpenAPI Generator project:

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

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using APITemplateio.Api;
using APITemplateio.Client;
using APITemplateio.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out APITemplateio.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using APITemplateio.Api;
using APITemplateio.Client;
using APITemplateio.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://rest.apitemplate.io";
            // Configure API key authorization: ApiKeyAuth
            config.ApiKey.Add("X-API-KEY", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("X-API-KEY", "Bearer");

            var apiInstance = new APIIntegrationApi(config);
            var templateId = 00377b2b1e0ee394;  // string | Your template id, it can be obtained in the web console
            var body = null;  // Object | 
            var outputImageType = 1;  // string? | - Output image type(JPEG or PNG format), default to `all`. Options are `all`, `jpegOnly`,`pngOnly`.  (optional) 
            var expiration = 5;  // int? | - 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  (optional) 
            var cloudStorage = 1;  // int? | - 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`.  (optional) 
            var 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  (optional) 
            var postactionS3Bucket = "postactionS3Bucket_example";  // string? | - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.  (optional) 
            var meta = inv-iwj343jospig;  // string? | - Specify an external reference ID for your own reference. It appears in the `list-objects` API.  (optional) 

            try
            {
                // Create an Image
                ResponseSuccessImageFile result = apiInstance.CreateImage(templateId, body, outputImageType, expiration, cloudStorage, postactionS3Filekey, postactionS3Bucket, meta);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling APIIntegrationApi.CreateImage: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published