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)
When true, returns _upload_csv_url, a signed URL to download the original payload as a CSV.

include_upload_json true|false (default: false)
When true, returns _upload_json_url, a signed URL to download the original payload as a JSON file.

include_errors_csv true|false (default: false)
When true, returns _errors_csv_url, a signed URL to download the error rows as a CSV.

include_errors_json true|false (default: false)
When true, returns _errors_json_url, a signed URL to download the error rows as a JSON file.

The upload files are only available if the import was created with save_upload: true. Requesting include_upload_csv or include_upload_json on an import whose upload was not saved returns a 400 error: No saved upload file exists since file was not specified to be saved during import creation.

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

      

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|item|asset|location
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.

name string
Filters imports by their exact name.

search string (max 127)
Full-text search across imports.

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