Docs / Search Items
Search Items
Keyword search over clean items, English and Chinese.
- 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.jsonanddocs/API.md§12
Keyword search over clean published items, in English and Chinese.
| Parameter | Notes |
|---|---|
q | Required. 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, category | Same validation as /v1/items |
since, until | RFC3339; since > until is 400 |
limit | Default 50; values above 200 are clamped to 200; < 1 or non-integer is 400 |
cursor | Bound 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.
- Only
compliance_status = 'clean'rows are reachable; the index never holds a withheld document. itemsare the same item objects as/v1/items:author,ai_generated,ai_labelandtranslationsare added on read, exactly as on every other item route, so a search hit renders its byline and can switch language without a round trip to the feed.- Conditional GET: a strong
ETagand a304on an unchanged body, exactly like the other readable routes;Cache-Control: public, max-age=30. 503when the SQLite build has no FTS5; every other route keeps working.- Metered per delivered item id.
Description: docs/API.md §12
Parameters
| Name | In | Required | Type | Example | Notes |
|---|---|---|---|---|---|
q | query | no | string | inflation | Keyword query, at least 2 characters |
locale | query | no | string | en | A well-formed locale tag. Read the supported set from GET /v1/meta → locales. |
category | query | no | string | central_banks | One of GET /v1/meta → categories; anything else is 400. |
since | query | no | string | 2026-11-01T00:00:00Z | RFC3339 lower bound (inclusive). |
until | query | no | string | 2026-11-07T00:00:00Z | RFC3339 upper bound (inclusive); since > until is 400. |
limit | query | no | string | 2 | Page size. /v1/items is 1..200 (default 50); /v1/search clamps a larger value; /v1/items/{id}/related is 1..50. |
cursor | query | no | string | <next_cursor> | Opaque keyset cursor from the previous page's next_cursor. An empty string is treated as absent. |
include | query | no | string |
Following next_cursor is a loop; see Pagination for the walk in curl, Python and TypeScript.
Example request
curl -sS \
'https://vg.tempproject.online/v1/search?q=inflation&limit=2' \
-H "Authorization: Bearer $NEWS_KEY"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])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
{
"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.