Pagination
Lists come a page at a time; follow the cursor for the next.
On this page
Every list comes in pages of 25. Ask for up to 100 with limit, then pass meta.next_cursor as cursor for the
next page, until it's null.
curl "$NIFTY_URL/api/v1/tags?limit=100" -H "Authorization: Bearer $NIFTY_TOKEN"
{
"data": [ … ],
"meta": { "limit": 100, "next_cursor": "eyJsIjoidDFyaEdhQTJZZ0ZNIiwiayI6WyJiaXJ0aGRheS1pZGVhcyJdfQ" }
}
| Parameter | |
|---|---|
limit |
Items per page: 1 to 100, default 25. More is treated as 100 |
cursor |
meta.next_cursor from the previous page |
count=true |
Adds meta.total_count: how many there are in all, with any filters |
- The
Linkheader holds the next page's full URL (rel="next"). The last page has noLinkandnext_cursor: null. - A cursor works only for the list that gave it: keep the same filters and order. Otherwise it's
400 invalid_parameter. - The order is stable: records that tie (the same name or date) are ordered by
id.
Every page, in a script
base=$NIFTY_URL/api/v1
url="$base/tags?limit=100"
while [ -n "$url" ]; do
page=$(curl -fsS "$url" -H "Authorization: Bearer $NIFTY_TOKEN")
echo "$page" | jq -r '.data[].name'
cursor=$(echo "$page" | jq -r '.meta.next_cursor // empty | @uri')
url=${cursor:+$base/tags?limit=100&cursor=$cursor}
done