Pagination

You don't want 400,000 items all at once? Paginate!

All our Building Blocks have support for bulk fetches via “list” API methods, e.g. you can list Orders, Users, Payments, Subscriptions, etc. They all share a common structure, taking at least two parameters: size and page.

We use pagination based on a page size and current page. With these parameters, you can retrieve the data the way you want and display it using your own pagination scheme. The return of a response header contains the total count, e.g.: X-Pagination-Total: 212.

Example request using size and page:

HTTP
Core SDK & Node SDK
Python SDK
HTTP
GET /orders?size=10&page=1 HTTP/1.1
Content-Type: application/json
Authorization: Bearer <jwt>
X-Builton-Api-Key: <builton-api-key>
Host: api.builton.dev
Core SDK & Node SDK
builton.products.get({ size: 10, page: 0 }).then(pageProduct => {
// pageProduct.current contains the first page.
// pageProduct.page contains the current page number.
// pageProduct.paginationTotal contains the total number of item you can paginate through.
// pageProduct.next() will update `pageProduct.current` and `pageProduct.page` with the next page.
// pageProduct.previous() will update `pageProduct.current` and `pageProduct.page` with the previous page.
// pageProduct.goToPage(pageNumber) will update `pageProduct.current` and `pageProduct.page` with a specified page.
// The `next`, `previous`, and `goToPage` functions accept a callback and return a Promise.
});
Python SDK
orders = builton.order().search(size=10, page=0)
print(orders)

You can find an example on using pagination with the Core SDK and the Node SDK here.

The more items you fetch at once, the slowest the response will be.