Cabinhub News API v1.0.0

Docs / Search Items

Search Items

Keyword search over clean items, English and Chinese.

GET/v1/search
Auth
client bearer + quota
Cache-Control
public, max-age=30, stale-while-revalidate=150, stale-if-error=300
Validators
ETag
Source of truth
clients/openapi.json and docs/API.md §12

Keyword search over clean published items, in English and Chinese.

ParameterNotes
qRequired. Trimmed. 2 to 256 characters, counted in characters so a two-character Chinese term is valid. Shorter is 400 q must be at least 2 characters; longer is 400 q must be at most 256 characters
locale, categorySame validation as /v1/items
since, untilRFC3339; since > until is 400
limitDefault 50; values above 200 are clamped to 200; < 1 or non-integer is 400
cursorBound to the query; see §6

Query rules. The query is split on whitespace, then into latin/digit runs and CJK runs. Every FTS5 operator, quote and punctuation mark is discarded before the match expression is built, so a query can never inject FTS syntax. Latin terms shorter than two characters are dropped; a CJK run is kept whole; duplicate terms are collapsed; at most 24 terms are used. Terms are combined with AND. A query that leaves no searchable term is not an error — it returns 200 with items: [].

Zero-result retries (first page only). Both editions index both languages, so a query the edition filter emptied is retried once without it: a reader on the en box who typed Chinese gets the story instead of an empty page. If that still matches nothing, the terms are combined with OR instead of AND and ranked by FTS relevance, so one word that appears in no story no longer zeroes the rest of the query. A page served by either retry carries next_cursor: null and is not paginated; a query with no searchable term, and a query whose every term matches nothing, still return 200 with items: [].

CJK behaviour. The index stores every CJK character surrounded by spaces (one token per character), and the query builder does the same per-character phrase for a CJK run. That is why a word-boundary tokenizer can serve Chinese: 美联储 matches 美联储, and 利率 (two characters) matches. No spaces are required in the query. Latin text is indexed normally, so English keeps ordinary word and prefix search.

Ranking. FTS relevance first, then item importance and recency.

Snippets. snippets maps item id to {"field","text"}. The text is a 160-character window sliced out of the stored field, with only an ellipsis added at a truncated edge; nothing is regenerated or paraphrased. Fields are tried in the order summary, body, title, then a single bullets entry. Snippets live on the envelope, never inside the item, so the item schema cannot drift.

Envelope (measured, ?q=inflation):

A Chinese query (?q=美联储, URL-encoded) returned the zh-Hans item with {"field":"title","text":"美联储维持利率不变,核心通胀降至2.4%"} and the same envelope (plus query and snippets). A punctuation-only query (?q=!!) returned 200 with items: [], snippets: {} and count: 0.

Description: docs/API.md §12

Parameters

NameInRequiredTypeExampleNotes
qquerynostringinflationKeyword query, at least 2 characters
localequerynostringenA well-formed locale tag. Read the supported set from GET /v1/meta → locales.
categoryquerynostringcentral_banksOne of GET /v1/meta → categories; anything else is 400.
sincequerynostring2026-11-01T00:00:00ZRFC3339 lower bound (inclusive).
untilquerynostring2026-11-07T00:00:00ZRFC3339 upper bound (inclusive); since > until is 400.
limitquerynostring2Page size. /v1/items is 1..200 (default 50); /v1/search clamps a larger value; /v1/items/{id}/related is 1..50.
cursorquerynostring<next_cursor>Opaque keyset cursor from the previous page's next_cursor. An empty string is treated as absent.
includequerynostring

Following next_cursor is a loop; see Pagination for the walk in curl, Python and TypeScript.

Example request

curl
Shell
curl -sS \
  'https://vg.tempproject.online/v1/search?q=inflation&limit=2' \
  -H "Authorization: Bearer $NEWS_KEY"
Python, standard library only
Python
import json
import os
import urllib.request

URL = "https://vg.tempproject.online/v1/search?q=inflation&limit=2"
KEY = os.environ["NEWS_KEY"]


def call() -> dict:
    req = urllib.request.Request(URL, headers={
        "Authorization": f"Bearer {KEY}",
    })
    with urllib.request.urlopen(req, timeout=15) as res:
        print(res.status, res.headers.get("ETag"))
        return json.loads(res.read().decode("utf-8"))


if __name__ == "__main__":
    body = call()
    print(json.dumps(body, indent=2, ensure_ascii=False)[:2000])
TypeScript, Node 18+, no dependencies
TypeScript
const res = await fetch(
  "https://vg.tempproject.online/v1/search?q=inflation&limit=2",
  {
    method: "GET",
    headers: {
      authorization: `Bearer ${process.env.NEWS_KEY}`,
    },
  },
);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
console.log(res.headers.get("etag"), await res.json());

The requests are generated from the path template and the parameters in clients/openapi.json, so a new parameter appears here without an edit to this site.

Example response

Response body
JSON
{
  "items": [ { "id": "11111111-1111-5111-9111-111111111111", "title": "Fed holds policy rate as core inflation cools to 2.4%", "...": "..." } ],
  "snippets": {
    "11111111-1111-5111-9111-111111111111": {
      "field": "body",
      "text": "… funds rate unchanged on Wednesday, saying that core inflation had cooled to 2.4 percent while the labour market remained firm. Policymakers repeated that furth…"
    }
  },
  "query": "inflation",
  "next_cursor": null,
  "count": 1,
  "disclaimers": {"en": "...", "zh-Hans": "..."}
}

Response example in docs/API.md §12 (GET /v1/search)

Failures

This operation can answer 200, 304, 400, 401, 422, 429, 503. The full envelope for each status, with its body, is on Errors.