Skip to main content

Pagination

Normal pagination

Most endpoints that return a collection are paginated. Use page and limit to paginate. Note: Pages start at 0! If no limit is given a default of 20 is used. Max limit is 60.

Product pagination (used sometimes)

Some endpoints, specifically surrounding fetching products, can have inconsistent pagination. What this means is that you cannot count the number of products returned to be consisting on every page. This is because some brands setup their products in a way where 1 product can be returned as multiple products.

note

We will mark in the API reference when product pagination is used

An example would be Product 001 which comes in 3 colors: Black, White, Blue. In Traede this is created as a single product with multiple colors. However, the brand wants this to be displayed as 3 separate products on their B2C channel. Therefore, the order channel API will return this as 3 products instead of one. This can mess up pagination. Therefore, for endpoints that uses this pagination you should fetch products using a while loop until the API does not return any more products. Here is an example of how that looks written in PHP.

note

This is pseudo-code that assumes you have a variable $client that holds some sort of class that can communicate with the Traede API

<?php

$results = [];

$currentPage = 0;
$limit = 20;
while(true) {
$result = $client->request('GET', sprintf('https://api.traede.com/3pl/products?page=%s&limit=%s', $currentPage, $limit));

if (count($result) == 0) {
break;
}

$results = array_merge($results, $result);

$currentPage++;
}