Skip to content

Pagination

Lists that can grow without bound come a page at a time: hosts, proposals, the audit log and a host’s events, at most 50 to a page.

A page carries next when there is more. Pass it back unchanged as ?after= for the following page; when next is absent, you have everything.

Terminal window
after=
while :; do
page=$(curl -fsS -H "Authorization: Bearer $UPDAWG_TOKEN" \
"https://api.updawg.net/v1/orgs/acme/hosts?after=$after")
echo "$page" | jq -r '.hosts[].hostname'
after=$(echo "$page" | jq -r '.next // empty')
[ -n "$after" ] || break
done

Treat next as opaque: pass it back, don’t build it. Keep the same filters and sort on every page; next continues the list you asked for, not another one. Where a list has total, it counts everything matching the filter, not the current page.

A job’s log is read the same way, by line rather than by page: each answer has lines, and more when there are further lines to fetch. Ask again with after set to the last line’s seq. While the job is still running, poll; once finished is true and more is false, the log is complete.