1. Threads And Channels
  2. Retrieve

Threads And Channels

Retrieve

Typically you will be retrieving a thread related to a specific resource. Because the thread has a predictable ID (the resource's ID prefixed with thrd_), you'll typically just retrieve a single thread.

Channels on the other hand are not tied to a specific resource. Instead, you'll typically query the channel based on the third party subscribers on a resource.

Retrieve Thread

GET
`/v1/threads/:thread`

Get a single thread using its id.

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

const thread = response.data;

      

List Threads

Example

GET
`/v1/threads`

When you want to retrieve multiple threads, your data property on the result will always be an array even if you don't have any threads.

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

const threads = 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 threads 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 threads in the database.

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

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

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

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

      

Filter

You can filter threads by the following query parameters:

  • location_id - Filter threads by location ID. Only threads associated with the specified location will be returned.