1. Imports
  2. Retrieve Imports

Imports

Retrieve Imports

This allows you to retrieve details of a specific import or list multiple imports.

Retrieve Import

Example

GET
`/v1/imports/:import`

Retrieve a single import using its id.

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

      

Query Parameters

include_upload_csv true|false (default: false)
include_upload_json true|false (default: false)
include_errors_csv true|false (default: false)
include_errors_json true|false (default: false)


List Imports

Example

GET
`/v1/imports`

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

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

const imports = response.data;
const pagination = response.pagination;

      

Pagination

If the has_more property on the pagination object is set to true, you know there are more imports 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 imports in the database.

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

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

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

const imports = response.data; // the array of imports 11 - 20
const pagination = response.pagination; // the pagination object

      

Query Parameters

order_by created_at|count_uploaded|count_success|count_errors|updated_at
Specifies the field by which results should be ordered.

resource contact|group
Filters imports based on the resource type.

upload_mode sync|async
Filters imports by the mode of upload.

action merge|overwrite|delete
Filters imports by the specified action type.

status requested|queued|processing|completed|failed|timed_out|expired
Filters imports by their current status.

has_errors boolean
Filters imports based on whether they contain errors.

location_id string
Filters imports based on a specific location ID.

js
        const response = await fetch("https://api.packagex.io/v1/imports?resource=contact&upload_mode=sync&action=merge&status=completed&order_by=count_success", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json"
  },
}).then((res) => res.json());

const imports = response.data; // the array of imports
const pagination = response.pagination; // the pagination object