Pagination
Some Sofia Space API lists can grow without limit — tasks in a project, a task’s comments, search results — so they come a page at a time. You ask for a page size with limit and continue with the nextCursor the previous page gave you. Smaller lists (projects, statuses, spaces, a space’s pages) come back whole.
Who this is for: developers calling the Sofia Space API.
How paging works
Section titled “How paging works”- Call the list without a cursor. Add
limitto choose the page size, or leave it out for the default. - Read
hasMoreandnextCursorin the response. - While
hasMoreistrue, call again with the same parameters pluscursor=<nextCursor>.
{ "items": [ { "id": "7c3e9a15-2d4f-4b6a-9e8c-1f3a5b7d9e20", "taskNumber": 42, "title": "Prepare quote for deal #1042" } ], "nextCursor": "eyJuIjo0Mn0", "hasMore": true}nextCursorisnullon the last page.- A cursor is opaque: don’t build or change it. A damaged cursor gives
400 CURSOR_INVALID. - Keep every other parameter the same while paging. A cursor remembers the sort it was made for: sending it with a different
sort(or, for tasks, a different sort field) gives400 INVALID_ARGUMENT— start again from the first page. Changing a filter isn’t detected: you just get a page of a different list, so don’t. limitabove the maximum is lowered to the maximum, not refused.limit=0or nolimitmeans the default.
Which endpoints page
Section titled “Which endpoints page”| Endpoint | List key | Default | Maximum |
|---|---|---|---|
GET /api/v1/projects/{projectId}/tasks |
items |
100 | 100 |
GET /api/v1/tasks/{taskId}/comments |
comments |
50 | 100 |
GET /api/v1/search |
items |
20 | 50 |
The task comments list keeps its older key, comments, instead of items; the paging fields are the same. A page of comments holds up to limit top-level comments plus their replies, so it can be longer than limit — always page on nextCursor, never on the count.
Every other list in this reference returns everything in one response, under a named key such as projects, statuses, spaces or pages.
Read every page: example
Section titled “Read every page: example”#!/usr/bin/env bash# Print every task in a project, 100 at a time.BASE=https://acme.sofiaspace.uz/api/v1PROJECT=9d2e7a10-4b6c-4e8f-a1d3-5c7e9b2f4a68CURSOR=""while : ; do PAGE=$(curl -s -G "$BASE/projects/$PROJECT/tasks" \ -H "Authorization: Bearer $SOFIA_TOKEN" \ --data-urlencode "limit=100" \ --data-urlencode "description=false" \ ${CURSOR:+--data-urlencode "cursor=$CURSOR"}) echo "$PAGE" | jq -r '.items[] | "\(.taskNumber)\t\(.title)"' [ "$(echo "$PAGE" | jq -r .hasMore)" = "true" ] || break CURSOR=$(echo "$PAGE" | jq -r .nextCursor)doneThe same loop in Python:
import os, requests
BASE = "https://acme.sofiaspace.uz/api/v1"HEADERS = {"Authorization": f"Bearer {os.environ['SOFIA_TOKEN']}"}
def all_tasks(project_id): params = {"limit": 100, "description": "false"} while True: page = requests.get(f"{BASE}/projects/{project_id}/tasks", headers=HEADERS, params=params, timeout=30) page.raise_for_status() body = page.json() yield from body["items"] if not body["hasMore"]: return params["cursor"] = body["nextCursor"]description=false leaves task descriptions out of the list, which makes big exports much faster. Read one task’s description with GET /api/v1/tasks/{taskId}.
What you can’t do
Section titled “What you can’t do”- You can’t jump to page N or get a total count of tasks; only “next page”.
- You can’t page backwards.