Listing and Pagination

The orders endpoint allows you to retrieve your orders with support for pagination using an offset. This enables you to efficiently navigate through large sets of orders. The endpoint supports per_page and offset query parameters. To retrieve orders with pagination, you must provide a valid API key.

Retrieving a list of orders with a set per page limit

const apiKey = "YOUR_API_KEY";
const perPage = 16;

const getOrders = async (perPage, apiKey) => {
    const getOrdersResponse = await fetch(
      `https://api.autoenhance.ai/v3/orders?per_page=${perPage}`,
      { 
        method: "GET",
        headers:{
          "x-api-key": apiKey,  
        }
      }
    );

    const { orders, pagination } = await getOrdersResponse.json();
}

As you can see, the response returns an orders, and pagination object. The orders object contains the list of your orders, and pagination contains two values: per_page, and next_offset.

Retrieving a paginated list of orders

If you want to load more orders with a pagination (next batch of orders without the initial orders that you've already fetched), you will need to use the next_offset value in your next request.

The value next_offset is returned from in the object that is returned from retrieving a list of orders with a set per page limit

const apiKey = "YOUR_API_KEY";
const pagination = { per_page:16, next_offset:"string" };

const loadMoreOrders = async (perPage, nextOffset, apiKey) => {
    const loadMoreOrdersResponse = await fetch(
      `https://api.autoenhance.ai/v3/orders?per_page=${perPage}&offset=${nextOffset}`,
      { 
        method: "GET",
        headers:{
          "x-api-key": apiKey,  
        }
      }
    );

    const { orders, pagination } = await getOrdersResponse.json();
}

Important note The response will always return pagination object with values that will enable you to fetch next batch of orders if you still have more orders to fetch.

Specification

Last updated