1. Exports
  2. Retrieve Exports

Exports

Retrieve Exports

This allows you to retrieve details of a specific export and get the exported data/file. _json_url will contain URL to download exported data in JSON file provided that include_json is true. _csv_url will contain URL to download exported data in CSV file provided that include_csv is true. _csv_error_url will contain URL to download a file containing errors that occurred during export, if any, provided that include_csv is true. _csv_sanitized_url will contain URL to download data that was excluded from export due to data being potentially malicious, provided that include_csv is true. This data is sanitized.

Retrieve Export

Example

GET
`/v1/exports/:export_id`

Retrieve a single export using its id.

js
        const response = await fetch("https://api.packagex.io/v1/exports/exp_7xKyu1HYgPnSAXZhtdxFxk?include_csv=true&include_json=true", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY
  }
});
const export = await response.json();

const export_json_url = export._json_url;
const export_csv_url = export._csv_url;
const export_errors_url = export._csv_error_url;
const export_csv_sanitized_url = export._csv_sanitized_url;

      

Query Parameters

include_csv true|false (default: false)
include_json true|false (default: false)


List exports

Example

GET
`/v1/exports`

When you want to retrieve list of exports, your data property on the result will always be an array even if you don't have any exports. The exports are returned in chronological order by creation date.

js
        const response = await fetch("https://api.packagex.io/v1/exports", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
});

const result = await response.json();
const exports = result.data;
const pagination = result.pagination;

      

Pagination

If the has_more property on the pagination object is set to true, you know there are more exports in the database that have not been returned to you. The pagination object also has a page property indicating your current offset and a limit property. The total_count property in pagination returns the total number of exports in the database.

By default, the page is set to 1 and the limit is 10.

If we want to query for exports 11 - 20, we would request page 2 with a query parameter.

js
        const response = await fetch("https://api.packagex.io/v1/exports?page=2&limit=10", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
});

const result = await response.json();
const exports = result.data; // the array of exports 11 - 20
const pagination = result.pagination; // the pagination object

      

Query Parameters

order_by created_at|count_batches|count_total|updated_at
Specifies the field by which results should be ordered.

direction asc|desc
Can be used along with order_by to sort results in ascending or descending order. Default: asc.

resource contact|group|fulfillment|item|location|manifest|shipment|tracker|shipping_label_inference|asset
Filters exports based on the resource type.

statuses queued|processing|completed|failed|timed_out
Filters exports by status.

is_deleted true|false
Filter exports by deletion status. When true, only deleted exports are returned. When false, only non-deleted exports are returned.

search string
Search by export name.

js
        const response = await fetch(
  "https://api.packagex.io/v1/exports?resource=contact&statuses=completed,failed&order_by=count_total&direction=desc",
  {
    method: "GET",
    headers: {
      "PX-API-KEY": process.env.PX_API_KEY,
      "Content-Type": "application/json",
    },
  }
);

const result = await response.json();
const exports = result.data; // the array of exports
const pagination = result.pagination; // the pagination object