How does it work?
This page contains information about how pagination works in Factorial's API
Pagination default is set to 100 items
It is important to note that pagination is applied by default for every request, with a set limit of 100 items per request when no pagination limit parameter is present. This limit of 100 is also the max limit per request.
The public API provides two methods of pagination - offset and cursor.
Offset Pagination
This type of pagination is based on page numbers and a page limit. In order to request this kind of pagination, the request must contain the following parameters:
- limit: This is the page limit or page size. It's equivalent to saying "Fetch me only {{limit}} items". It is of type
Integer
. If it is above the max limit or absent, we would default to using the max limit. - page: This is the page whose data is being requested. eg. page
2
. It is of typeInteger
.
A typical offset pagination request would look something like this
GET `.../users?limit=10&page=2
The query result would have meta information required to make subsequent requests:
{
"meta": {
"has_next_page": true,
"has_previous_page": false,
"total": 85,
"limit": 10
},
"data": [...]
}
The total
value in the metadata makes it possible to compute the number of pages required to totally showcase the data, based on the limit
.
Cursor Pagination
This is the default pagination type for our API. This type of pagination moves to and from a page via the use of a cursor. The following terms are worthy of note:
- limit: This is the page limit or page size. It's equivalent to saying "Fetch me only {{limit}} items". It is of type
Integer
. If it is above the max limit or absent, we would default to using the max limit. - after_id: This is the id that serves as the pointer for a request. Only items after this
id
would be fetched. - before_id: This is also an id that serves as the pointer for a request. Only items before this
id
would be fetched.
A typical cursor pagination request would look something like this
GET `.../users?limit=10&after_id=MTY=
The query result would have meta information required to make subsequent requests:
{
"meta": {
"has_next_page": true,
"has_previous_page": false,
"start_cursor":"MTc=",
"end_cursor":"Mjc="
"total": 85,
"limit": 10
},
"data": [...]
}
You can choose to go either forward or backward on a page, by indicating an after_id
or a before_id
. The first request, however, just requires thelimit
(ie. how many items you intend to fetch).
Updated 16 days ago