DEV Community

Luca
Luca

Posted on

Catalog Automation with InDesign Templates and Pagination APIs

Introduction

In today's interconnected digital landscape, the seamless flow of data and functionality between different software systems is crucial for maximizing efficiency and productivity. This is where APIs play a pivotal role. APIs streamline workflows by eliminating manual processes, reducing errors, and enhancing interoperability.

At our company, we specialize in catalog software: transforming “raw” data into polished catalogs and price lists, serving as the final touch before a company's offerings reach its audience.
Our software accepts input data from a variety of sources such as PIM, ERP, CRM, e-commerce, or data management software and generates rich PDFs complete with images and tables showcasing the company's product offerings. Because of the nature of our service, it is often found in the middle of a company’s marketing workflow. Our service is positioned within the marketing workflow of many companies. This prompted us to develop APIs to further enhance integration and workflow efficiency.
This article explores how our APIs streamline integration, offering insights into their role in enhancing workflow efficiency and interoperability across different systems.
Find our API usage guide here

The Role of APIs in Streamlining Integration:

APIs serve as the backbone of software integration, offering a standardized conduit for communication across diverse systems and programming languages.
Our service relies heavily on AWS infrastructure, employing key components like API Gateway, Lambda, and S3, all orchestrated via Node.js.
Through APIs, clients utilizing platforms such as NetSuite, PimCore, or ODOO effortlessly interact with our system.
But APIs aren't just about communication—they facilitate robust data exchange and access as well. In our data-centric operations, APIs play a pivotal role in optimizing workflows and eliminating manual intervention.
Practically speaking, our API empowers users to effortlessly configure connectors that automate data transmission for processing, triggered by updates or scheduled intervals. With our pagination process operating asynchronously, users can effortlessly track progress and retrieve final outputs.
In essence, APIs represent more than mere tools—they represent a transformative force. They streamline integration, enhance efficiency, and open up boundless opportunities within software ecosystems.

Challenges and Solutions:

Embarking on the journey of API development presented us with many challenges, but with the strategic utilization of AWS architecture, we were able to overcome them.
Scalability was the first obstacle. Cloud services demand the ability to accommodate vast user bases and fluctuating workloads without sacrificing performance. Leveraging AWS's serverless infrastructure, particularly Lambda functions, empowered us to seamlessly manage the influx of requests, ensuring smooth scalability as our user base expands.
Find more about AWS Lambda functions here
Reliability and availability emerged as another critical concern. In the realm of cloud services, downtime is not an option. Our APIs had to be meticulously designed with fault tolerance and redundancy mechanisms to guarantee uninterrupted access. Thanks to AWS's serverless architecture, we boast the capability to process requests promptly, minimizing any potential service disruptions.
Interoperability presented its own set of challenges. In an interconnected digital landscape, APIs must seamlessly integrate with diverse systems and services, both within and beyond the cloud environment. Leveraging various AWS services within our infrastructure facilitated smooth integration, effortlessly adhering to industry standards and protocols.
In essence, our journey through API development underscored the importance of adaptability, innovation, and strategic utilization of cutting-edge technologies. We refined our APIs and fortified our commitment to delivering seamless, reliable, and interoperable solutions for our users.

Success Story Highlights:

One of our notable success stories involves a global shoe and clothing retailer that successfully integrated Pagination’s API into its workflow. By providing agents with a tool to filter and select products and export ready-to-share documents, our API flawlessly fit into their tool, and streamlined their operations, enabling swift access to critical information and accelerating decision-making processes.

API Description:

Our APIs serve as the bridge between our cloud service and client workflows, offering seamless integration without disrupting existing processes.

Find our APIs technical documentation here.

Key concepts include projects and pagination processes, where projects encompass page layouts, custom features, and settings, while pagination processes handle data processing requests.
Endpoints available include:
Launch Project: Initiate pagination processes with project and user IDs, data files, and optional settings.

Snippet description: An example snippet to use the Launch Project endpoint in Node.js using the axios package to make the request

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('datafile', fs.createReadStream('/C:/Users/Michele Pagination/Downloads/catalogue short api.xlsx'));
data.append('project_id', 'XXXX');


let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.pagination.com/vpc/projects',
  headers: { 
    'user_id': 'XXXX', 
    'x-api-key': 'XXXX', 
    ...data.getHeaders()
  },
  data : data
};


axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
Response sample
[
  {
    "companyLogo": "<link goes here>"
  },
  {
    "coverColor": "#0067B9"
  },
  {
    "tocTitle": "Table of contents"
  },
  {
    "datafile": "<file goes here>",
    "format": "binary"
  },
  {
    "coverSubtitle": "Subtitle1"
  },
  {
    "project_id": "projectName_pro3Test_pro3_id-1"
  },
  {
    "coverTitle": "Title1"
  },
  {
    "doOnlyValidation": false
  }
]


Enter fullscreen mode Exit fullscreen mode

Get Process Status: Retrieve process status and download links based on request IDs or project IDs.

Snippet Description: An example snippet to use the Get Process Status endpoint in Node.js using the axios package to make the request

Code:

const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();


let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://api.pagination.com/vpc/operations',
  headers: { 
    'x-api-key': 'XXXXX', 
    'user_id': 'YYYYY', 
    'project_id': 'ZZZZZ', 
    'reqId': 'KKKKK', 
    ...data.getHeaders()
  },
  data : data
};


axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

Enter fullscreen mode Exit fullscreen mode

Response sample:

{
"reqId": "36051ef0-982a-4ab0-a948-5495a1955ec7",
"status": "pagination complete",
"origin": "<file path>/data_file.xlsx",
"paginationDate": "Thu Feb 29 2024 15:48:38 GMT+0000 (Coordinated Universal Time)",
"signedUrl": "<URL pdf export>",
"expireDate": "Mon Apr 29 2024 15:26:46 GMT+0000 (Coordinated Universal Time)",
"project_id": "projectName_pro3Test_pro3_id-1"
    }

Enter fullscreen mode Exit fullscreen mode

Delete Process: Halt ongoing processes by request IDs.

Snippet Description: An example snippet to use the Delete Process endpoint in Node.js using the axios package to make the request

Code:

```const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();

let config = {
method: 'delete',
maxBodyLength: Infinity,
url: 'https://api.pagination.com/vpc/operations',
headers: {
'x-api-key': 'XXXXX',
'user_id': 'YYYYY',
'project_id': 'ZZZZZ',
'reqId': 'KKKKK',
...data.getHeaders()
},
data : data
};

axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});




Response Sample



Enter fullscreen mode Exit fullscreen mode

{
"message": "Process stopped."
}




**Notifications: **
Upon launch, owners receive an email notification (and a message to the webhook URL if provided during project creation), signaling the initiation of the pagination process. As the process unfolds asynchronously, customers receive a notification (via email and webhook if provided) upon completion. The "pagination-complete" notification includes a public URL to the exported document, valid for 7 days (renewable through the get Status endpoint).


—


## Conclusion:
In conclusion, APIs play a crucial role in enhancing workflow efficiency, empowering businesses to streamline processes, enhance productivity, and drive innovation. By leveraging the capabilities of APIs, organizations can unlock new opportunities, strengthen collaboration, and deliver exceptional value to their stakeholders. As we continue to refine and expand our API offerings, we remain committed to simplifying workflow integration and driving meaningful outcomes for our clients.


Enter fullscreen mode Exit fullscreen mode

Top comments (0)