Cabinhub News API v1.0.0

Docs / Pagination

Pagination

/v1/items and /v1/search are keyset paginated: one opaque cursor, followed until it is null. Here is the walk in curl, Python and TypeScript, and the bounds that apply.

Keyset, not page numbers

Follow next_cursor until it is null. There is no total count and no page number. A cursor is opaque: send it back exactly as received.

A cursor walk in three languages

The same loop: request a page, keep its items, repeat with next_cursor until it comes back null. The cursor below is the one in the contract's own example, so the snippets and the documentation cannot drift apart.

curl - two explicit pages
Shell
# page 1: no cursor
curl -sS "https://vg.tempproject.online/v1/items?limit=2" \
  -H "Authorization: Bearer $NEWS_KEY"

# page 2: the next_cursor from page 1
curl -sS "https://vg.tempproject.online/v1/items?limit=2&cursor=eyJwIjoiMjAyNi0xMS0wM1QxODowMDowMC4wMDAwMDBaIiwiaSI6IjExMTExMTExLTExMTEtNTExMS05MTExLTExMTExMTExMTExMSJ9" \
  -H "Authorization: Bearer $NEWS_KEY"
Python, standard library only
Python
import json
import os
import urllib.parse
import urllib.request

BASE = "https://vg.tempproject.online"
KEY = os.environ["NEWS_KEY"]


def walk(locale: str) -> list[dict]:
    items: list[dict] = []
    cursor: str | None = None
    while True:
        query = {"limit": "200", "locale": locale}
        if cursor:
            query["cursor"] = cursor
        url = BASE + "/v1/items?" + urllib.parse.urlencode(query)
        req = urllib.request.Request(url, headers={"Authorization": f"Bearer {KEY}"})
        with urllib.request.urlopen(req, timeout=15) as res:
            page = json.loads(res.read().decode("utf-8"))
        items.extend(page["items"])
        cursor = page["next_cursor"]
        if not cursor:
            return items


if __name__ == "__main__":
    print(len(walk("en")), "items")
TypeScript, Node 18+, no dependencies
TypeScript
const BASE = "https://vg.tempproject.online";
const KEY = process.env.NEWS_KEY!;

export async function walk(locale: string): Promise {
  const items: unknown[] = [];
  let cursor: string | null = null;
  do {
    const url = new URL(`${BASE}/v1/items`);
    url.searchParams.set("limit", "200");
    url.searchParams.set("locale", locale);
    if (cursor) url.searchParams.set("cursor", cursor);
    const res = await fetch(url, { headers: { authorization: `Bearer ${KEY}` } });
    if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
    const page = await res.json();
    items.push(...page.items);
    cursor = page.next_cursor;
  } while (cursor);
  return items;
}

Both clients in clients/ ship this loop as an iterator (iterateItems / iter_items); the loop above is the same protocol with no dependency.

Cursor rules and bounds

Source: docs/API.md §6.

/v1/items, /v1/search and /v1/feed/{locale} use keyset pagination; the cursor is opaque base64url JSON. /v1/digest/* does not paginate.

ParameterTypeDefaultBounds / notes
limit (/v1/items)int501..200; outside is 400
limit (/v1/search)int501..200; a larger value is clamped to 200 (not rejected); < 1 or non-integer is 400
cursorstringnoneOpaque base64url JSON. An empty string is treated as absent
localestringnoneWell-formed locale tag; not restricted to the policy locales
categorystringnoneOne of the categories from /v1/meta, else 400
since / untilRFC3339nonesince > until is 400
min_importance (/v1/items)floatnone0.0..1.0

/v1/items response envelope (measured, limit=2):

JSON
{
  "items": [ ... ],
  "next_cursor": "eyJwIjoiMjAyNi0xMS0wM1QxODowMDowMC4wMDAwMDBaIiwiaSI6IjExMTExMTExLTExMTEtNTExMS05MTExLTExMTExMTExMTExMSJ9",
  "count": 2,
  "disclaimers": {"en": "...", "zh-Hans": "..."}
}

One route is paged by NUMBER instead of a cursor: GET /v1/site/topics/{slug} takes page (1-based, page 1 is the clean request) with limit as the page size (default 24, capped at

  1. and reports pagination. It is the public subject archive, whose ordering is the store's

own keyset order (published_at newest first, id as the tie-break), so walking page=1,2,… visits every story exactly once. A page past the last one is a 200 with items: [] and out_of_range: true (a document answers 404); page=0 or a non-number is a 400. pagination.total is the measured matched, not a corpus claim — coverage.complete says whether that count is a lower bound of a bounded scan.