ressource.socialbetadocumentation

Pagination

Cursor-based pagination for every list, with limits and a complete shell loop.

Lists take ?limit= (1–100, default 25; out-of-range values are clamped, never refused) and ?cursor=. Pass back the nextCursor you were given until hasMore is false.

{ "items": [], "nextCursor": "…", "hasMore": true }

The cursor is opaque: do not build or edit one. A tampered cursor is a 400.

Walk every page

cursor=""
while :; do
  page=$(curl -s -H "Authorization: Bearer $TOKEN" "$BASE/sources?limit=50${cursor:+&cursor=$cursor}")
  echo "$page" | jq -r '.items[] | "\(.short_id)\t\(.url)"'
  [ "$(echo "$page" | jq -r .hasMore)" = true ] || break
  cursor=$(echo "$page" | jq -r .nextCursor)
done

Why cursors

A page is keyed on the last row's sort value, never an offset, so a source saved while you page through does not shift or repeat what you see. Keep the same filters and sort for every page of one walk.

Search is split into sections: sources, folders, tags, community-sources, public-sources, public-communities and people. GET /search?q= answers the first page of every section at once, each in its own envelope with a count:

{
  "sections": {
    "sources": { "items": [], "count": 42, "nextCursor": "…", "hasMore": true },
    "folders": { "items": [], "count": 0, "nextCursor": null, "hasMore": false }
  }
}

Its ?limit= is rows per section: 5 by default, 50 at most. To read further into one section, call GET /search/sections/{id}?q= with that section's nextCursor (pages of 20 by default, 50 at most).

  • count is counted up to 100: 100 means "99 or more". Below that it is exactly the number of rows you can page through. It comes with a first page only (no cursor); limit=0 without a cursor returns the count and no rows.
  • A search cursor belongs to its section and its query. Sending it with another q or to another section is a 400, like a tampered one. Start over without a cursor when the query changes.
  • Results are ranked best match first, and the order is stable: equal ranks never repeat or skip a row between pages.
  • If sources, folders, tags, community-sources or public-sources fails, the whole GET /search fails. public-communities and people come back empty instead.
cursor=""
while :; do
  page=$(curl -s -H "Authorization: Bearer $TOKEN" "$BASE/search/sections/sources?q=rust&limit=50${cursor:+&cursor=$cursor}")
  echo "$page" | jq -r '.items[] | "\(.result_short_id)\t\(.result_url)"'
  [ "$(echo "$page" | jq -r .hasMore)" = true ] || break
  cursor=$(echo "$page" | jq -r .nextCursor)
done

Reads that are not paginated

A few reads deliberately return everything at once, and say so in the API reference:

  • the folder tree (GET /folders)
  • every saved URL (GET /sources/urls), meant for a local "is this saved?" cache
  • tag suggestions (GET /tags/suggest), a ranked top-N
  • reactions on a source

On this page