Close
logo

Api Data Exports

Git RepositoryEdit on Github
Last update: 2 years ago by luigi mangaReading time: 2 min

The Onport API allows you to export data in JSON format. However, if you need to export a significant amount of data, you'll need to paginate through the API and implement handling for rate limiting.

As an alternative, certain endpoints support the exporting of data asynchronously via CSV and JSON. To set this up, you'll first need to set up an API template within the setup area.

The available types of exportable data are:

  • Sales
  • Sale Items
  • Dropship Purchases
  • Dropship Purchase Items

Once the format and data mapping has been setup, you'll then need to select the webhook option for delivery. A URL should be provided to send the completed data export. This will be done via a POST request with the following body:

{
"file": "https://....."
}

The file will link to a generated JSON or CSV file you can then download. From there, you can use this data to populate external BI tools or databases.

Triggering the export via the UI

The exports can be triggered from the Onport dashboard. For example, under the purchases list you can trigger the webhook from the Export button. As with the other exports, filtering the data on the page (e.g. specifying a date range) will also filter the exported data.

Triggering the export via the API

You can also trigger the exports via API. To do this, you'll need to know the template id. This can usually be found in the URL in the UI. Or, by querying the /api/templates.json endpoint.

To trigger the webhook / email export, you'll need to send a JSON payload detailing any data filtering to POST /api/templates/:id/export.json. As an example, if you wanted to filter based upon date range, dropship provider and purchase type, you can send:

{
"where": {
"purchaseType": {
"$in": ["dropship", "automated_dropship", "adjusted_dropship"]
},
"dropshipProviderId": 4230
},
"dateFrom": "2018-01-01T00:00:00Z",
"dateTo": "2019-01-01T00:00:00Z"
}
๐Ÿ’ป Vendor Integration โ€” Previous
Importing Shipment Details
Next โ€” ๐Ÿ“‚ Exports
Exporting Invoices