Scope every query
PasscorpusType (and state for state-scoped corpora) on POST /us/statutes/search. Scoping removes off-target jurisdictions and makes your pages more predictable. An unscoped search ranks across the whole corpus, so federal or other-state matches can crowd out a state answer.
These match the
parent object on every result. Pass a hit’s parent back to search that section’s neighbors.
Choose the right matchType
UsematchType when hybrid ranking is too loose.
How search works describes each mode.
When each mode earns its place
When each mode earns its place
any ranks on intent, so a result can share no wording with the query. That suits “how long does a landlord have to return a deposit”. It does not suit “material adverse effect”, where a section that only discusses the idea is noise.all and phrase trade recall for precision and can return nothing. An empty result does not mean a coverage gap. Fall back to any and scope the query more tightly.boolean when the logic matters: one term or another, a term excluded, two terms in the same sentence.Control what a search returns
excerptChars: how much matching text each result carries (default 500, range 100 to 600, and a larger value is a 422). The excerpt can begin mid-section, so use it as a preview and do not quote it.includeBody: attaches each hit’s full text onbodyin the same call. It is billed per row that returns text, so use a smalllimit. See what a search costs.fields: returns only the named fields. A result has 40+ fields and most are null on any row, so this cuts payload size.actIdandcitationalways come back. An unknown field name returns422.
creditsConsumed on the response for what a call actually cost, instead of computing it.
It can be lower than the list price, and failed or refunded work bills 0.
To quote text, use body or GET /us/statutes/section/{actId}/body. Do not raise excerptChars.
Each result also carries a parent object: the /us/statutes/divisions query that lists the section’s siblings. Section responses include amendment fields (sourceCredit, amendmentYears, lastAmendedYear, publicLaws, federalRegisterCitations).
Treat a missing optional key as “not applicable”
Core fields are always present and arenull when the value is unknown, for example citation, state and effectiveDate.
Conditional extras are omitted when they do not apply, such as an explanatory note or a block of fields that only one corpus carries.
Each field’s description in the API reference says which kind it is.
Do not require a conditional key to be present. Read a missing key as “not applicable”.
A client generated from the OpenAPI document should mark conditional fields optional, and keep core fields required but nullable.
Discover and cache coverage
Two endpoints show what is queryable.GET /us/statutes/coverageis the corpus matrix (see Coverage). Read a jurisdiction’scorporakeys and pass one back ascorpusType. This avoids a wasted call on a corpus with no data for that state.GET /us/statutes/divisionsis the hierarchy. PasscorpusType=STATE&state=XXto list a state’s codes and theircodevalues, or drill in withtitleNumber,code,chapterandpart.
Store the actId values you care about
TheactId (for example USC_T42_C21_S1983) is the handle for a section.
Store the actId of every section your product depends on, with its citation, and call GET /us/statutes/section/{actId} or .../body on later runs.
If a stored id stops resolving, re-resolve by citation. See Section identifiers.
Handle 429 and 402
Both are expected in production.- On
429, wait and retry as Errors and rate limits describes. The official SDKs do this for you. - On
402, stop, show a clear message, resolve it in your account dashboard, then retry. The body carriescreditsRequiredandcreditsAvailablewhen known. - A refund reverses one specific charge. Refunded credits return to the bucket they came from. If that bucket has expired, they return as a new bucket that lasts 30 days.
Treat relevanceScore as a within-response rank
relevanceScore (0 to 1) orders results within one response. It is a relative rank, not a confidence score.
Do not compare scores across queries or use a fixed threshold such as 0.7. To narrow results, tighten query, corpusType, and state.
To tell whether the corpus has anything on point, read noGoodMatch on the search response:
true: nothing looks on point for this query, or no rows came back. Say so instead of presenting the rows as an answer.false: something on point was found, or the top row is an exact citation match.null: the ranking was degraded (rankingDegraded: true). Retry the query.
matchQuality. Every page of one search carries the same value.
matchQuality tiers
matchQuality tiers
Treat a value you do not recognize as
moderate.A same-topic section from the wrong jurisdiction or layer (a state statute for a federal question, a regulation for a statute) can rank first. Check citation and state before you rely on it.Link users to official sources
Each result carries source links, and any of them may be null. For user-facing links, prefer the official government link (state legislature or govinfo.gov).Related
Pagination
Page predictably with
limit, offset, and hasMore.SDKs
The official Python and TypeScript SDKs handle retries, idempotency and a spend guard for you.

