Guide
Paging and lists
Cursors, counts, filters, sorting, choosing fields, and keeping a copy in step.
Paging with a cursor
Every list answers one page at a time:
{
"items": [ … ],
"next_cursor": "…"
}limitsets the page size: from 1 to 200, 50 when you leave it out.- When
next_cursoris a string, there is another page: send it back ascursorwith the same parameters. - When
next_cursorisnull, that was the last page.
A cursor stays correct while items are added or changed, so paging through a project of thousands of tasks never skips or repeats one, the way page numbers can. The one exception is a list sorted by the time of change (sort=-updated or ORDER BY updated): a task changed while you page moves to the other end of the order, so it can be passed over or come twice. To keep a copy in step, page in the default order (or by key) and then ask for updated_since.
cursor=""
while :; do
page=$(curl -sG "$PROJQO_API/orgs/$PROJQO_ORG/projects/$PROJECT/tasks" \
-H "Authorization: Bearer $PROJQO_TOKEN" \
--data-urlencode "limit=200" \
${cursor:+--data-urlencode "cursor=$cursor"})
echo "$page" | jq -r '.items[].key'
cursor=$(echo "$page" | jq -r '.next_cursor // empty')
[ -z "$cursor" ] && break
doneconst api = process.env.PROJQO_API;
const headers = { Authorization: `Bearer ${process.env.PROJQO_TOKEN}` };
async function* allTasks(org, project) {
let cursor = null;
do {
const url = new URL(`${api}/orgs/${org}/projects/${project}/tasks`);
url.searchParams.set("limit", "200");
if (cursor) url.searchParams.set("cursor", cursor);
const page = await (await fetch(url, { headers })).json();
yield* page.items;
cursor = page.next_cursor;
} while (cursor);
}import os
import requests
api = os.environ["PROJQO_API"]
headers = {"Authorization": f"Bearer {os.environ['PROJQO_TOKEN']}"}
def all_tasks(org, project):
params = {"limit": 200}
while True:
page = requests.get(f"{api}/orgs/{org}/projects/{project}/tasks", headers=headers, params=params).json()
yield from page["items"]
if not page["next_cursor"]:
break
params["cursor"] = page["next_cursor"]Counting
count=trueaddstotal, the number of items in the whole list, to the answer./countcalls (such asGET /tasks/count?q=…) answer the number alone, without the items.
Filtering
- Tasks are filtered with the query language of Advanced search, in
q:q=project = WEB AND status = "In review". See the query language. - Other lists take plain parameters, such as
?project=,?status=or?updated_since=. Each list's parameters are in the reference. - A saved filter:
filter={id}runs a saved filter the person may open.
Sorting
sort takes one or more field keys, separated by commas; - in front sorts that key from the highest down:
sort=-updated,keyFor tasks you can also end q with ORDER BY: q=project = WEB ORDER BY rank.
Choosing fields
fields=summary,status,assigneereturns only those fields of each item (with its id), which makes big lists smaller and faster.expand=comments,watchers,changesputs related lists inside each item: the first 20 of each, with a cursor for the rest.
Keeping a copy in step
To keep your own copy of projqo's data up to date without reading everything again:
- Read everything once, page by page.
- Afterwards, ask only for what changed: every list takes
updated_since(a date-time). - Ask for what was deleted:
GET /tasks/deleted?since=…(and the same for Docs pages).
Or subscribe to webhooks and hear about each change as it happens.