Skip to main content

Customer Excel from your JSON via API

The simplest way to integrate with Zparse

This workflow streamlines the process of transforming your internal JSON data into polished, customer-ready Excel files. It's designed to automate the conversion of your structured JSON records into a universally accessible spreadsheet format, perfect for reporting, sharing, or direct delivery to your clients.

TL;DR Give me the formula

Overview

For this workflow you will send the data you want to export from your system to a JSON endpoint into Zparse. Zparse will generate the excel file and return it to you.

1. Create mapping

First thing we need to do is to create a mapping that will generate an Excel file from a JSON payload. For this tutorial we will suppose that your data look like:

{
"products": [
{ "name": "Product 1", "reference": 21, "description": "Desc p1" },
{ "name": "Product 2", "reference": 42, "description": "Desc p2" }
]
}

In Zparse go to Mapping > New mapping and create a new blank mapping.

For this tutorial we will have the following functions in our mapping graph:

  • Source: JSON Elements reader (JSON Path: $.products.*)
  • Destination: Excel Line writer

This mean that for each elements of our products array we will have a line in our excel file.

Now build a mapping that will extract data from your JSON and add it to an Excel file. It should look like (see platform guides to learn about mappings):

_mapping_

We now have a mapping that can take our JSON payload as input and return an Excel file, now we will connect it :)

2. Create workflow

Now we will create a workflow to allow communication from your system to Zparse.

In Zparse go to Workflow > Create new workflow and create a new blank workflow.

For this tutorial we will have the following functions in our graph:

  • Web Server > JSON Endpoint our entry point which you will be able to POST JSON data from your system
  • Mapping > Mapping where we will forward our data to the mapping created in previous point
  • Web Server > File Response where we will send back the generated excel file

Now build the workflow, it should look like this (see platform guides to learn more about workflows):

_workflow_

If you edit the Web Server > JSON Endpoint node you will note an url that should look like:

https://api.zparse.io/workflow/e/j/40ae9c38-bfa6-4990-879b-65ad964960c8/bf659760-7be2-4f49-b268-ebe81a8b3bc5

Calling this URL with a POST request will execute the workflow

3. Call Zparse from your system

In your own code handler responding to user request for export, fetch the JSON data you want to export and send it to Zparse URL. Zparse will generate the file and send it back to you.

To get your secret key see Authentication

Simple example how it could work with python:

import requests

ACCESS_KEY = 'wkt-YOUR_SECRET_KEY'


def fetch_data():
return {
"products": [
{"name": "Product 1", "reference": 21, "description": "Desc p1"},
{"name": "Product 2", "reference": 42, "description": "Desc p2"}
]
}


def my_handler():
data = fetch_data()
response = requests.post(
'https://api.zparse.io/workflow/e/j/40ae9c38-bfa6-4990-879b-65ad964960c8/bf659760-7be2-4f49-b268-ebe81a8b3bc5',
json=data,
headers={
'Authorization': ACCESS_KEY,
'Content-Type': 'application/json'
}
)
response.raise_for_status()
with open("output_file.xlsx", 'wb') as f:
f.write(response.content)

my_handler()

Of course you can directly stream back the file to your customer to avoid keeping it to disk

Let your operational team complete the mapping

Now that you have completed the wiring to update the exporter, your operational team can be provided with the Zparse mapping link and handle all future change themselve without any code modification.

Upon completion, these updates will be automatically propagated to your clients.

Idea to go further

  • Keep a copy of generated Excel file in the store (easier support)
  • Send a message to your company slack when a customer generate an Excel file