## Reading public data

Public records are readable by anyone, with no account and no sign-in. This section covers reading them from a
browser, a script or an agent: the call, the query, paging, the two views, the limits, and the other servers that
answer reads.

### Anonymous reads

The platform is `did:web:techne.computer`; its read endpoint is `https://techne.computer/xrpc/<method>`. The
generic reads take GET with the query as a JSON string:

    GET https://techne.computer/xrpc/pub.techne.draft.query.listRecords?query=<url-encoded JSON>&limit=10

    {"view":"curated",
     "where":{"all":[{"type":{"is":"pub.techne.draft.place"}},
                     {"location":{"near":{"point":"40.015,-105.27","within":"2km"}}}]}}

`/xrpc/<method>` and `/.well-known/did.json` answer CORS for any origin (`Access-Control-Allow-Origin: *`,
preflight included, never credentials), so a page on any site calls them directly with `fetch`. No other route
carries CORS (not the routes under `/xrpc/_`, which are no methods: the agent consent flow and the change stream;
not the OAuth metadata under `/.well-known/oauth-*` or the MCP server).

With the SDK, `connectAnonymous()` from `techne-sdk/connect` gives the same reads with each record's check:

    import { connectAnonymous } from 'techne-sdk/connect'
    const techne = connectAnonymous()
    const page = await techne.query(q, { limit: 10 })   // page.items, page.cursor

It resolves the platform's DID document on the first read and calls the endpoint it names. `put` on it rejects:
writes need a sign-in. `get(uri)` and `versions(uri)` work the same way.

Methods anyone may call: `pub.techne.draft.query.listRecords`, `getRecords`, `countRecords` and
`composeRecords` (a POST); `pub.techne.draft.commons.getVersions`; `pub.techne.draft.registry.listTypes` and
`getType`. An anonymous caller gets public records only.

### Query shape

A query is `{"view": …, "where": …, "order": …, "limit": …}`, or `{"any": [{"view": …, "where": …}, …], "order": …,
"limit": …}` to give each branch its own view (see the two views); the grammar is the `pub.techne.draft.query`
lexicon (`registry.getType` {nsid: "pub.techne.draft.query"}), and the building-an-app section's Read part lists
the operators.
Rules the parser enforces:

- A `where` node has exactly one property: one role (`type`, `author`, `location`, …) or one of `all`, `any`,
  `not`, `has`. Two conditions go in an `all`.
- A query holds at most 32 conditions in all.
- A role takes exactly one operator (`is`, `in`, `after`, `before`, `near`, `covers`, `matches`); on `location`,
  `in` and `covers` may add `kind` and `followed` (see Location).
- `all` takes at most 16 children, `any` at most 8, `not` exactly 1, and `in` a list of 1 to 100 values.
- `near` is `{point: "lat,lng", within: "5km"}`, at most 50km.
- `order` is one name as a plain string: `"written"` (newest first), `"start"` or `"end"` (soonest first), the
  `as` name of a `near` or `matches` measure, or `"shuffle"`. An object such as `{"start":"desc"}` is refused.
- Roles past `type`, `author` and `uri` exist only where the type's query document maps them (`registry.getType`
  answers it as `query`; a type whose query document maps none, such as `org.hypercerts.funding.receipt` (it
  names only its subject, the recipient), is filtered client-side after paging by `type` or `author`). A role the type lacks is refused (`pub.techne.draft.org declares no text role`), and a name
  that is no role is refused too (`no role <name>`). Free-text search is the `text` role with `matches`
  (`{"text":{"matches":"food pantry"}}`), on types that map it, such as `pub.techne.draft.place`;
  `pub.techne.draft.org` maps no `text`, so orgs are found by `type` and paged, or by `location` `in` an area
  (each of an org's sites counts).

`getRecords` takes `uris` as a repeated parameter (`?uris=at://…&uris=at://…`), at most 100 per call, and the
whole URL must stay under 8 KB or the CDN answers 414 before the platform sees it. 100 URL-encoded AT-URIs come to
about 9 KB, so send 50 at a time (URLSearchParams encodes them).
`countRecords` returns `{count, capped}`; it stops at 1000 (`capped: true` past it) and takes `groupBy` `type`
or `author`. `listRecords` with `count=true` adds the same two fields to the page.

### Paging

A `listRecords` page is `{records, cursor}` (plus `count` and `capped` with `count=true`). Each item is
`{uri, cid, author, collection, value, time, source, curated}` (`curated` true on a live curated record, else
false), with `space` on a
permissioned one that counts in a space, and `held`, `measures`, `signals` or `matched` when they apply: `value` is the record body, `time` the indexed time (the `written` role), `source` `public` or
`permissioned`. The SDK's `query` answers `{items, cursor, count, capped}` instead, each item
`{uri, cid, author, record, verdict, problems, curated, byline}`: the record after the SDK's own check. `getRecords`
answers `{records, withheld?}` with the same items (`withheld`: asked URIs moderation holds back), plus `handles`,
`resolved`, `curation` or `defaults` when asked for them.

`limit` is 1 to 500, default 50 (or the query's own `limit`). Pass the page's `cursor` back as it came, with the
same query and params. A page can hold fewer records than `limit` and still carry a cursor, because records that
fail the platform's check are dropped after the page is read: keep paging until no cursor comes back. The cursor
is opaque.

A `composeRecords` list step (and so the SDK's `query`) takes a `limit` up to 50000: past 500 the platform reads
the pages itself and charges every row to the caller's budget (see Limits). Keep it at 500 or less unless you mean
that.

### Location

`location` takes three operators:

- `near` `{point, within}`: records whose location lies within the radius (declared per type). It reads where
  the record says it is: a bare location, or a `locationEntry` of kind `at` (or none); one of another kind
  (`serves`, ...) is not where the record is. An area (a record stating cells, such as a county) is never a
  `near` result: the coordinate it states is its centre. Ask `covers` for the areas holding a point.
- `in`: a list of up to 8 areas, each the AT-URI of an area record (a `pub.techne.draft.placeV2` with `kind: area`)
  or a `$param`: records with a stated location whose centre lies in one of them.
- `covers`: a point (`"lat,lng"`, an H3 cell or a `$param`): records that state an area holding it, such as the
  area an org serves.

`in` and `covers` read every stated location: the record's own, and claims about it (a
`pub.techne.draft.statement` with `#locations`). They are allowed only at the top of a branch and match public
records only. `kind` picks the kind of stated location (`serves`, `registered`, ...; default `at`, "is at"), and
`followed: true` also matches a record through its subject, one hop (a receipt through its recipient). Each record
found this way carries `matched`: the stated locations that matched, each `{entry, kind, asserter, source}`, at
most 8. In the curated view only the author's own locations and claims by writers the commons root endorses count;
as written, every claim is weighed. A curated `in` or `covers` is checked on the page already read, so its pages
are often short, even empty, with a cursor: keep paging until none comes back.

A point or area this server does not serve is answered with `notServedHere`: `{reason, message}`, `reason`
`outsideCoverage` (a `near` or `covers` point outside the areas served) or `areaNotHeld` (an `in` area this server
does not hold, or one outside its areas). An empty list or a zero count with `notServedHere` set means "not
served here", not "nothing there": ask a server that serves the place.

### The two views

Every list and count names the view each of its branches reads. A query that names no view at all gets the old
default until 2027-03-01 (below) and is refused from 2027-03-02; one that names a view on some branches only is
refused now.

- **`"view": "curated"`**: the commons' merged record for one thing (a place, an event), one per thing. A curator
  the commons root trusts for the type composes it from every source that describes it, ranking the versions
  (`commons.getVersions` {uri} lists them and says which version gave each field); moderation applies, hidden
  records are left out, and an event is listed only inside the supported areas. Its author is the curator
  account. A type no curator covers (a community type, `pub.techne.draft.sameAs`, an app's own records) is
  refused with `400 NotCurated`, whose message names the type: read it as written.
- **`"view": "asWritten"`**: every public record as its author wrote it, unmerged: each source copy, and the
  curator's merged record too (it is a record), not hidden and not superseded. Read a type no curator covers
  this way, and anything scoped to its author (your own records, one person's posts).

A permissioned record (one in a space the caller may read) reads the same in both views; it is never curated.
`"view"` beside `"where"` covers every branch of the `where`, each child of a top-level `any` included. To mix
views in one list, give each branch its own: `{"any": [{"view": "curated", "where": {"type": {"is":
"community.lexicon.calendar.event"}}}, {"view": "asWritten", "where": {"author": {"is": "$viewer"}}}]}`. From
2027-03-02 a query that names no view is refused with `400 ViewRequired` (`curated: false` alone does not name
one; it is accepted beside a `view` it agrees with). Every record says `curated` (true or false) and its `author`.

Counts differ per view. A total across all authors as written (the registry's `recordCount`, the commons API's
`listRecords` without `author`, an `asWritten` count) counts a thing once per source plus once curated; a
`curated` count counts it once. Filter on `curated` or on `author` before summing as-written records.

Until 2027-03-01 (the last day) the platform answers every query that names no view the old way, whoever sends
it: curated, except a branch scoped to named authors, subjects or URIs, or a query with `curated: false`, read
as written, and a type no curator covers answers no records rather than `NotCurated`. Name the view anyway: from
2027-03-02 a query without one is refused.

### Limits

- Every database statement has a 5 s timeout. A `listRecords`, `getRecords` or `countRecords` that runs past it
  answers 500 with a message starting `query read:`; in `composeRecords` the step's entry in `errors` says the
  same (the SDK's `query` throws it as a `ComposeStepError`). A `near` over a dense area can approach it: on 2026-11-24 a `near` of places within 2km of
  central Boulder timed out once at 20 a page and later answered 20 a page in 1.3 s. Page small for `near`,
  narrow the area, or add conditions.
- `composeRecords` (the SDK's `query` sends it too): at most 12 steps (4 run at once) and 3000 records in all from the one-page steps. Rows read
  are charged to a budget of 20000 that refills at 500 a second, per signed-in DID. Anonymous callers get one
  such budget per client IP only where the server is set up to know the client's IP; where it is not, all
  anonymous callers share one budget ten times that size, so another anonymous reader can use up yours. Past it the call answers 429 `RateLimitExceeded`, with no `Retry-After`: wait a few seconds
  and retry.
- `listRecords`, `getRecords` and `countRecords` have no per-caller budget today. Keep a bulk download to one
  request at a time.
- `registry.listTypes` takes `limit` up to 100.

### Other servers that answer reads

- **The commons API**, `https://commons.techne.computer/xrpc/<method>`: its `listRecords` {collection, author,
  limit (1-100), cursor} lists indexed public records by collection or author, ordered by AT-URI, and its
  `getRecord` reads one (its MCP server's `list_methods`
  names them). Both are anonymous. It has no other filters; for place, time or
  text use the platform's `query.listRecords`. It lists every copy (the as-written view): a thing comes back
  once per source plus once as the curator's merged record, and a record carries no `curated` field. For merged
  records only, pass `author` = the curator account (on production `did:plc:rkpvr7i2duytruuoj2bngdho`,
  `rule-curator.techne.town`; today every record the platform answers with `curated: true` names it as
  `author`). Unlike the platform's lists it takes no `view` yet.
- **The commons MCP server**, `https://commons.techne.computer/mcp`: `list_methods`, `describe_method` and `call`
  over the commons' methods. Reads need no sign-in.
- **The analytics MCP server** (SQL over the platform's data, OAuth sign-in): it is not open to everyone; the
  Techne team grants access per account. Its address today is `https://data.scenius.social/mcp`.

### Field meanings people ask about

- `org.hypercerts.funding.receipt` `occurredAt`: when the payment occurred, not when the record was written. Nearly
  all of the commons' receipts are read from IRS Form 990 Schedule I, which gives no payment date, so for those
  `occurredAt` is the end of the funder's tax year (mostly 12-31 or 06-30): a year of them is a fiscal year.
- Which tax years the IRS receipts cover (they are grants to Boulder County recipients only): the commons reads the Form 990, 990-EZ and 990-PF e-files the IRS
  processed in the last three filing years (2024-2026 today, refreshed monthly; a filing year is when the IRS
  processed a return, not its tax year). Receipts come from 990 Schedule I and 990-PF Part XV. Funders file up to about ten and a half months after their year ends, so
  the latest tax years are incomplete. On 2026-11-24 the receipts by `occurredAt` year were 2021: 48, 2022: 352,
  2023: 5,181, 2024: 4,840, 2025: 3,035, 2026: 268. Fiscal years ending in 2023 and 2024 are the fullest; 2025
  is partial (many of its returns are not filed yet) and so is everything before 2023 (only late filers). A
  funder with no receipt for a year may simply not have filed it yet, or (on a 990) gave no single recipient more
  than $5,000, the floor for Schedule I. When a filing year leaves the window its returns' receipts are withdrawn,
  so the years covered move forward each January.
