Pagination
Learn how pagination works with WriftAI's API
Many WriftAI API endpoints return lists of resources. To avoid returning too much data in a single response, these endpoints return results in pages.
Instead of page numbers, WriftAI's API uses continuation cursors to paginate through a result set.
What is a cursor?
A cursor is a token returned by the API that represents your current position in a list. You don’t need to understand or modify it — just pass it back to the API to fetch the next or previous page.
Cursor-based pagination is more reliable than page numbers when data changes while you’re paging through results.
Request parameters
Most list endpoints accept:
-
page_size
The number of items to return (defaults and limits are documented per endpoint). -
cursor
A cursor token returned from a previous response. Omit this parameter to fetch the first page.
Response shape
Paginated responses include:
items— the current page of resultsnext_cursor/next_url— where to go next (ornullif you’re at the end)previous_cursor/previous_url— where to go back (ornullif you’re at the beginning)
Pagination walkthrough
This example calls the list predictions endpoint using cURL and jq, and intentionally paginates forward to the end of the list, then paginates backward to the beginning using cursors returned by the API.
# Fetch the first page
response=$(curl -s \
"https://api.wrift.ai/v1/predictions" \
-H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN")
echo "$response" | jq '.items[]'
# Paginate forward to the last page
cursor=$(echo "$response" | jq -r '.next_cursor // empty')
while [ -n "$cursor" ]; do
response=$(curl -s \
"https://api.wrift.ai/v1/predictions?cursor=$cursor" \
-H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN")
echo "$response" | jq '.items[]'
cursor=$(echo "$response" | jq -r '.next_cursor // empty')
done
# Paginate backward from the last page to the first page
cursor=$(echo "$response" | jq -r '.previous_cursor // empty')
while [ -n "$cursor" ]; do
response=$(curl -s \
"https://api.wrift.ai/v1/predictions?cursor=$cursor" \
-H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN")
echo "$response" | jq '.items[]'
cursor=$(echo "$response" | jq -r '.previous_cursor // empty')
donePaginate with Official Clients
See the reference for each WriftAI client to learn how to paginate with it.