Displaying generated documents through document IDs

You can have your customers view documents generated through Inkit in your own applications. The most secure way of doing this (and the way we strongly recommend), is by keeping the documents themselves in Inkit storage while storing the IDs of the documents in your own datastore. Then when one of your users wants to view a particular document, make the following API call:

# Import the Inkit Python package
import inkit
from inkit.exceptions import InkitResponseException

# Replace the string below with your API key
inkit.api_token = "ENTER YOUR API KEY"

try:
   # Specify the ID of the document
   doc_id = "ENTER YOUR DOCUMENT ID",
   # Get a generated PDF document
   resp = inkit.Document.download(doc_id)
except InkitResponseException as err:
   # Print any error
   print(err.response.data)
// Import the Inkit Node.js package
const Inkit = require("inkit");

// Replace the string below with your API key
Inkit.apiToken = "ENTER YOUR API KEY";

// Call PDF download
downloadDocument();

// Download a PDF document
async function downloadDocument() {
    try {
        const result = await Inkit.Document.download('ENTER YOUR DOCUMENT ID');
        // Print the JSON response of the API call
        console.log(JSON.stringify(result.data, null, 3));
    } catch (error) {
        // Print any error
        console.error(error.response.status, error.response.statusText);
    }
}
curl --request GET \
     --url https://api.inkit.com/v1/download/ENTER_YOUR_DOCUMENT_ID \
     --header 'X-Inkit-API-Token: ENTER YOUR API KEY' \
     --header 'accept: application/pdf'

After executing the above call, you will have the raw contents of the generated document, which you can then display in your application using a PDF viewer of your choice.