1. Templates
  2. Retrieve Asset

Templates

Retrieve Asset

GET
`/v1/templates/:template`

Get a template asset using its id.

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

const template = response.data;

      

List Templates

GET
`/v1/templates`

Example

To retrieve a list of templates, you can filter by type, status, and order them by different properties.

Property Type Description
type TemplateType (optional) Filter templates by their type (e.g., asset__asset_label_pdf, item__item_label_pdf, shipment__shipping_label_pdf).
status string (optional) Filter templates by their status, either default or custom.
order_by string (optional) Order the results by properties such as created_at, updated_at, name, type, or status.

Example Request

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

const templates = res.data; // Refer to the list of templates

      

Pagination

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

By default the page is set to 1 and the limit is 25.

If we want to query for assets 26 - 50, we would request page 2 with a query parameter.

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

const items = response.data; //the array of items 25 - 50
const pagination = response.pagination; //the pagination object