Skip to main content

API reference

Every provision of the Code, at every release point, as JSON or as the source USLM XML. Version 0.1.0.

The same reference is available as Swagger UI, which can send requests from the browser, as ReDoc, or as the raw OpenAPI schema this page is built from.

Any provision of the US Code, at any release point, addressed by a URL that mirrors the USLM @identifier.

The bare citation URL — /us/usc/t16/s45f/c/5 — is not documented here because it is not a machine route: it is a 307 redirect to whichever surface the caller can read (/app for HTML, /api/v1 otherwise), so curl it with -L or address /api/v1 directly. ADR-0010.

Release points are named for the last public law they incorporate, and not in a label means a law that was skipped: at 119-102not101 the text is current through 07/12/2026 except for Public Law 119-101. Responses carry that caveat rather than only a date.

Provisions

GET /api/v1/releases

All release points

Every known release point, newest first.

titles_affected is what OLRC says the release point changed; ingested_titles is what this database actually holds for it. The two differ for as long as the backfill is incomplete, and conflating them would make an empty answer look like a missing law — which is why they are two parameters and not one.

Parameters for GET /api/v1/releases
Parameter In Type Description
title query string | null Only release points that changed this title.
ingested_title query string | null Only release points this database actually holds this title at — what a release picker can offer without offering empty answers.

Returns 200 ReleaseOut[].

GET /api/v1/status

How current this mirror is, and when it last checked

What this deployment holds, and when it last asked OLRC what exists.

A versioned mirror of a living source has two ways of being wrong and only one of them is visible from the text: it can be missing a release point that was published last week, or it can have stopped asking altogether. The second is the dangerous one, because a corpus that has quietly stopped updating is indistinguishable from a corpus with nothing to update — every page still renders, every date still looks authoritative. So the answer here is two facts side by side: the newest release point loaded, and the timestamp of the last poll of uscode.house.gov.

Polled daily; stale goes true after a week without a successful check (storage.SOURCE_CHECK_STALE_AFTER).

Returns 200 StatusOut.

GET /api/v1/titles

Ingested titles

Every ingested title, in the Code's own order — 1, 2, … 5, 5a, 6, … 11, 11a, 12, … (ADR-0025). The ordering is the Repository's contract, not this handler's, so the same list arrives sorted from any implementation.

Returns 200 TitleOut[].

GET /api/v1/citation

A typed citation, resolved to an identifier

11 usc 523(a)(1)/us/usc/t11/s523/a/1, and whether it is there.

Parsing is citeparse.parse_citation, which is pure — it knows what string a citation names and nothing about what exists. Existence is answered here, with the batched labels() lookup already built for citation hover text, so this costs one query and needs no new Repository method (architecture rule 1).

A string that cannot be parsed is a 422: the request was malformed. A string that parses but names nothing loaded is a **200 with exists: false** — it is a well-formed question with the answer "not here", and telling the reader which part was wrong beats an error page.

Parameters for GET /api/v1/citation
Parameter In Type Description
q * query string A citation in more or less any written form.
release query string | null Release-point label, e.g. `119-102not101`. A bare `119-102` resolves to it with a note.
date query string | null Resolve to the newest release point on or before this date. `YYYY-MM-DD` or `MM/DD/YYYY`.

Returns 200 CitationOut.

GET /api/v1/sections/{identifier}/neighbors

Previous and next section in reading order

Reading order at one release point, skipping nothing: repealed, omitted and transferred sections keep their place and arrive badged (gotcha 9).

Parameters for GET /api/v1/sections/{identifier}/neighbors
Parameter In Type Description
identifier * path string
release query string | null Release-point label, e.g. `119-102not101`. A bare `119-102` resolves to it with a note.
date query string | null Resolve to the newest release point on or before this date. `YYYY-MM-DD` or `MM/DD/YYYY`.

Returns 200 NeighborsOut.

GET /api/v1/labels

Num and heading for many identifiers at once

What a list of citations say, in one request.

A section's text can carry forty cross references, and a reader that labels them — hover text, so a citation is legible without following it — has to ask once, not forty times.

Parameters for GET /api/v1/labels
Parameter In Type Description
identifier * query string[] Repeat once per identifier. Unknown ones are absent from the answer rather than an error.
release query string | null Release-point label, e.g. `119-102not101`. A bare `119-102` resolves to it with a note.
date query string | null Resolve to the newest release point on or before this date. `YYYY-MM-DD` or `MM/DD/YYYY`.

Returns 200 object.

GET /api/v1/sections/{identifier}/versions

Release points at which a section changed

The section's change timeline — one entry per distinct text, not one per release point, since most release points leave most sections untouched.

Parameters for GET /api/v1/sections/{identifier}/versions
Parameter In Type Description
identifier * path string

Returns 200 VersionsOut.

GET /api/v1/sections/{identifier}/diff

A redline between two release points of a section

Diffs the two release points' verbatim XML (docs/adr/0016): a generic text diff, computed here because it needs no USLM vocabulary at all — presentation (wrapping ops in <ins>/<del>) is frontend/src/lib's job, same as the section renderer itself.

Parameters for GET /api/v1/sections/{identifier}/diff
Parameter In Type Description
identifier * path string
from * query string Release point label to diff from.
to * query string Release point label to diff to.

Returns 200 DiffOut.

GET /api/v1/us/usc/

Look a provision up by its XML @id

No release parameter, by design: a guid identifies (provision, release point) on its own, which makes it the stable citation for this exact text at this exact moment (ADR-0003).

Parameters for GET /api/v1/us/usc/
Parameter In Type Description
id * query string An `@id` guid from the USLM, e.g. `id0b32dff7-810c-11f1-b7ce-bdea3d14cbdd`.

Returns 200 GuidOut.

GET /api/v1/us/usc/{identifier}

A provision, section, or table-of-contents node by identifier

Resolve a US Code identifier at a release point.

Longest-prefix match means /us/usc/t16/s45f/c/5 returns section 45f with paragraph (c)(5) extracted and anchored, rather than the paragraph alone — sub-section provisions are cut from the section at request time (ADR-0001), so the reader never loses context.

If the identifier names no section, it is tried as a structural node, and a table of contents comes back instead.

Parameters for GET /api/v1/us/usc/{identifier}
Parameter In Type Description
identifier * path string
release query string | null Release-point label, e.g. `119-102not101`. A bare `119-102` resolves to it with a note.
date query string | null Resolve to the newest release point on or before this date. `YYYY-MM-DD` or `MM/DD/YYYY`.
format query "json" | "xml" | "html" | null Response format. Defaults to content negotiation on Accept.

Returns 200 any.

Accounts

POST /api/v1/auth/signup

Signup

Accepts SignupIn. Returns 201 UserOut.

POST /api/v1/auth/login

Login

Accepts LoginIn. Returns 200 UserOut.

POST /api/v1/auth/logout

Logout

Parameters for POST /api/v1/auth/logout
Parameter In Type Description
x-csrf-token header string | null
usc_session cookie string | null

Returns 204 no content.

GET /api/v1/auth/me

Me

Parameters for GET /api/v1/auth/me
Parameter In Type Description
usc_session cookie string | null

Returns 200 UserOut.

Watchlists

GET /api/v1/watchlists

List Watchlists

Parameters for GET /api/v1/watchlists
Parameter In Type Description
usc_session cookie string | null

Returns 200 WatchlistSummaryOut[].

POST /api/v1/watchlists

Create Watchlist

Parameters for POST /api/v1/watchlists
Parameter In Type Description
x-csrf-token header string | null
usc_session cookie string | null

Accepts WatchlistCreateIn. Returns 201 WatchlistSummaryOut.

DELETE /api/v1/watchlists/{watchlist_id}

Delete Watchlist

Parameters for DELETE /api/v1/watchlists/{watchlist_id}
Parameter In Type Description
watchlist_id * path integer
x-csrf-token header string | null
usc_session cookie string | null

Returns 204 no content.

GET /api/v1/watchlists/{watchlist_id}/items

List Items

Parameters for GET /api/v1/watchlists/{watchlist_id}/items
Parameter In Type Description
watchlist_id * path integer
usc_session cookie string | null

Returns 200 WatchlistOut.

POST /api/v1/watchlists/{watchlist_id}/items

Add Item

Parameters for POST /api/v1/watchlists/{watchlist_id}/items
Parameter In Type Description
watchlist_id * path integer
x-csrf-token header string | null
usc_session cookie string | null

Accepts WatchlistItemCreateIn. Returns 201 WatchlistItemOut.

PATCH /api/v1/watchlists/{watchlist_id}/items/{item_id}

Update Item

Parameters for PATCH /api/v1/watchlists/{watchlist_id}/items/{item_id}
Parameter In Type Description
watchlist_id * path integer
item_id * path integer
x-csrf-token header string | null
usc_session cookie string | null

Accepts WatchlistItemUpdateIn. Returns 200 WatchlistItemOut.

DELETE /api/v1/watchlists/{watchlist_id}/items/{item_id}

Delete Item

Parameters for DELETE /api/v1/watchlists/{watchlist_id}/items/{item_id}
Parameter In Type Description
watchlist_id * path integer
item_id * path integer
x-csrf-token header string | null
usc_session cookie string | null

Returns 204 no content.

GET /api/v1/watchlist

Get Default Watchlist

"My Provisions": the current user's first watchlist, auto-created.

Parameters for GET /api/v1/watchlist
Parameter In Type Description
usc_session cookie string | null

Returns 200 WatchlistOut.

POST /api/v1/watchlist/items

Add To Default Watchlist

Parameters for POST /api/v1/watchlist/items
Parameter In Type Description
x-csrf-token header string | null
usc_session cookie string | null

Accepts WatchlistItemCreateIn. Returns 201 WatchlistItemOut.

DELETE /api/v1/watchlist/items/{item_id}

Remove From Default Watchlist

Parameters for DELETE /api/v1/watchlist/items/{item_id}
Parameter In Type Description
item_id * path integer
x-csrf-token header string | null
usc_session cookie string | null

Returns 204 no content.

Settings

GET /api/v1/settings

Get Settings

Defaults for a user who has never saved a preference — get_settings does not write, so reading this costs no row (storage/accounts.py).

Parameters for GET /api/v1/settings
Parameter In Type Description
usc_session cookie string | null

Returns 200 SettingsOut.

PUT /api/v1/settings

Update Settings

Parameters for PUT /api/v1/settings
Parameter In Type Description
x-csrf-token header string | null
usc_session cookie string | null

Accepts SettingsUpdateIn. Returns 200 SettingsOut.

Ops

GET /health

Health

Returns 200 object.