Tutorial: How to Integrate with DynamicDocs API and Generate High-Quality PDF Documents

July 2021 ADVICEment Team
The information in this tutorial is outdated. DynamicDocs API is no longer available on RapidAPI.com and available directly via ADVICEment.io. For more information on how to use the DynamicDocs API, please consult the documentation section.

This tutorial article will demonstrate how you can integrate with DynamicDocs API through RapidAPI.com and create PDF documents from dynamic templates. Our aim is to create a walkthrough tutorial (in less than 1000 words) to enable anyone to integrate with DynamicDocs API in less than 10 minutes. Without wasting any further time, let's go!

What is DynamicDocs API?

DynamicDocs created by ADVICEment is a publicly available API that allows users to generate dynamic PDF documents in a matter of seconds. The document templates are written in LaTeX, a mark-up style language that separates formatting and content. LaTeX consistently applies user-defined style throughout the documents and has become very popular in academic circles due to its ability to create high-quality, complex documents. The template files are stored under the user’s ADVICEment account, where they can be tested and compiled online. The files utilise special commands that can create dynamic text with logic statements, tables spanning multiple pages, great-looking headers & footers and custom charts based on the underlying data. For more information on writing templates visit the DynamicDocs documentation page. Once the templates are set up and published, users can call the DynamicDocs API with document data in the JSON format and receive the PDF document in a matter of seconds.

What information is needed to create the first PDF document?

The following bits of information is required to create your first API call:

  • ADVICEment API Key (known as Adv-Security-Token header parameter)
  • RapidAPI API Key (known as X-RapidAPI-Key header parameter)
  • Template Identifier (known as template-token query parameter)

Get ready to write these down in the next few steps.

Step 1: Create your account on ADVICEment.io and publish your first template.

You will need to create an account on ADVICEment by simply going to the signup page. There you will be asked some basic details regarding the user and their organisation. Once registered, you will receive an automated email with confirmation instructions.

ADVICEment Sign Up page
DynamicDocs Sign Up page

Once you have accessed your account, you can generate your ADVICEment API Key (Adv-Security-Token) by going to the ‘Dashboard’ -> ‘Account Details’ -> ‘Edit’ and then under Security Settings, clicking on ‘Generate Account Security Token’. Be prepared to write it down or copy it into your password store. Note that you cannot access it again, and for security reasons, should you lose it, you will have to generate a new one which will mean having to change your existing API calls.

ADVICEment Dashboard page
In the DynamicDocs Dashboard, under Account Details, you will be able to see if you have generated your Adv-Security-Token.
ADVICEment Account Details page
By clicking Edit under Account Details and clicking Generate Account Security Token, you will get your Adv-Security-Token.

Now let’s create our document template, which can be done by going to the ‘My Templates’ page and clicking on the ‘Create New Templates’ button. You will then be presented with various document templates to get you started. For the purpose of this tutorial, select ‘Simple Contract’ while keeping the default options. You can then open the ‘Simple Contract’ template on the ‘My Templates’ page. Once opened, you will be able to edit the template files, add images and compile them with the data.json payload. Simply click the blue ‘Publish’ button at the top of the page and get your template-token, which can be found in your template’s ‘Settings’ page.

ADVICEment Edit Template page
In your Edit Template page, you can publish your template.
ADVICEment Template Settings page
Once published, you will be able to get your template-token in the Settings page for your template.

Step 2: Create an account on RapidAPI.com.

To make use of the DynamicDocs API and subscribe to the Basic plan, which gives you 200 free requests every month, you will need to register an account with RapidAPI.com. This step can be skipped if you already have an account with RapidAPI and have your X-RapidAPI-Key. If not, then simply visit the RapidAPI.com signup page, verify your email address with a code and go to ‘My Apps’ -> ‘Default Application’ -> ‘Security’ section of your account. There you will find the X-Rapid-API-Key token, also known as ‘Application Key’. Finally, visit the DynamicDocs plans page and subscribe to the Basic plan to get notified of the latest API news.

RapidAPI.com DynamicDocs page
Follow DynamicDocs on RapidAPI.com for updates and news.

Step 3: Make your first API call.

You are now all set to make your first API call and make your first dynamic PDF document. The table below lists all the information you will need with the double brackets representing the actual parameter:

API End Point:
https://dynamicdocs.p.rapidapi.com/templates/{{template-token}}/compile
Header Parameters:
content-type “application/json”
adv-security-token {{Adv-Security-Token}}
x-rapidapi-key {{X-Rapid-API-Key}}
x-rapidapi-host “dynamicdocs.p.rapidapi.com”
JSON Body:
{
 "client": {
   "firstName": "John",
   "lastName": "Smith",
   "company": "ABC Company Pty Ltd",
   "location": "Cape Town, South Africa",
   "address": "xx Long Street"
 },
 "consultant": {
   "firstName": "Kobus",
   "lastName": "van der Merwe",
   "company": "XYZ Company Pty Ltd",
   "location": "Sandton, South Africa",
   "address": "xx Rivonia Road"
 },
 "servicesDescription": "perform analysis on the company's clients and identify existing market segments",
 "effectiveDate": "1 February 2021",
 "amount": "ZAR 100 000"
}

The body of the API call is the dynamic data used in the document and can be found when opening a template in Step 1. Note that you can use a great tool like Postman to perform the API call or simply go to the DynamicDocs End Point page on RapidAPI and test it there with your parameters.

RapidAPI.com DynamicDocs Endpoint page
Test DynamicDocs API on RapidAPI.com.

Final Remarks

Now that you’re all set, go out and create your dynamic PDF documents! We hope we achieved our objective of creating an easy to follow tutorial. If you have any comments, suggestions or critiques, please do not hesitate to get in touch with us using the contact form. We will ensure to get back to you timeously.

PS. The final word count is 908; #winning.