Skip to main content
POST /us/statutes/search accepts a terms-and-connectors expression when you send matchType: "boolean". It is the syntax used by the major legal research services: AND, OR, NOT, same-sentence and same-paragraph connectors, numeric proximity, wildcards, exact phrases and grouping.
Three guarantees hold for every Boolean search:
  1. Every result satisfies the expression, judged over the section’s full text rather than one excerpt or passage.
  2. Results are ranked by relevance among the matches. The expression decides which sections qualify, and relevance decides their order.
  3. Nothing is silently loosened or misread. A malformed expression, an unsupported operator or an out-of-bounds value is a 422 that names the problem and its character position.

When to use Boolean

Use boolean when you need to say exactly which sections qualify and be told when your expression cannot be read. Stay on any if you want the API to infer intent from a question. How search works compares every matchType. For a citation such as 42 U.S.C. § 1983, use any or GET /us/statutes/resolve. A citation resolves to rank 1 in any mode, and Boolean mode never pins a cited section.

Quick start

The response has the same shape as any search, plus parsedQuery, the paging fields and each result’s matchContexts, described under Response fields:
Paging, filters (state, corpusType, code, titleNumber, chapter, part, yearFrom, yearTo, excludeRepealed and the rest) and includeBody work exactly as they do for any search. The scope filters narrow the corpus first, and the expression is judged inside that scope. Failures and what they cost are in Failure and charging.

Examples

Requests translated into expressions. parsedQuery is identical to the expression for each of these.

Operators

Word operators are UPPERCASE. Lowercase and, or and not are ordinary words. Details that matter in practice:
  • Distance counts word positions. /1 means adjacent, and notice /3 termination matches “notice of the termination” (three positions apart) but /2 does not.
  • atleastN( ) and atmN( ) take one term, phrase or wildcard: atleast3("trust fund"), atleast2(retaliat*).
  • Matching is on whole words, case-insensitively, with no stemming and no synonyms. act never matches fact, and deposit does not match deposits (see Coming from another service for the fix).
  • Case functions read the text as printed, so allcaps(irs) matches “IRS” and not “Irs”. plural( ) adds a regular plural ending, so for an irregular plural type the plural word itself (children).
  • Punctuation inside a word splits it. § 1983 is the phrase section 1983, and rule 10b-5 is the phrase rule 10b 5.
  • A hyphenated word on its own also matches its joined form. non-compete is read as "non compete" OR noncompete, and at-will as "at will" OR atwill.
  • A slash between two words is text. and/or is the phrase and or, and 24/7 is 24 7. Anything else containing /, ~ or ^ that is not a known operator is refused, never searched as words.

Precedence

Without parentheses, operators bind in this order, tightest first:
  1. OR (and XOR)
  2. /N and +N
  3. /s and +s
  4. /p and +p
  5. AND
  6. NOT
Within one proximity level, the smaller distance binds first, and at an equal distance the ordered + form binds before the unordered / form. Otherwise operators group left to right. Legal research services use this order. Textbook Boolean binds AND tighter than OR. parsedQuery parenthesizes every group whose reading could be in doubt, so you can read back exactly how your expression was grouped, and queryWarnings flags AND and OR mixed without parentheses.
When in doubt, add parentheses. They never change a correct expression, and parsedQuery drops the ones that are redundant. Each side of a proximity connector (/N, /s, /p and their + forms) must be a term, phrase, wildcard, fuzzy term, an OR group of those, or another proximity expression. AND, NOT and the counting functions cannot sit inside one: (a AND b) /5 c is a 422.

Also accepted

You can paste a search written in another service’s syntax. Each spelling below is read as the operator shown, and parsedQuery echoes the canonical form.
A - before a word is NOT, so penalty -6672 excludes 6672 rather than searching for it. A ! before a word is refused: one family of services reads it as NOT and another as a wildcard, so we ask you to write NOT criminal or criminal! instead of guessing.

Negative proximity

NOT /N, NOT /s and NOT /p (and NOT w/N) match a section where the left side occurs at least once outside that range of the right side. landlord NOT /s tenant matches “The landlord sues. The tenant pays.” and does not match “The landlord sues the tenant.” That differs from landlord NOT (landlord /s tenant), which rejects the section the moment any one sentence holds both words.

Refused, never searched as words

A token that looks like an operator is either understood or refused by name. It is never quietly searched as ordinary words, because a misread operator returns a confident, wrong answer. These are refused with a 422:
  • a leading ! (!criminal), a doubled prefix (--x), and a double negation (NOT -x);
  • a placeholder left in a connector (w/n), a connector we do not know (s/5), and any leftover /, ~ or ^ that is not one of the operators above;
  • a distance in sentences or paragraphs (WITH2, SAME3): use /s, /p or /N;
  • regular expressions (/negligen.*/), backslash escapes, number ranges (1..5) and ranges ([2000 TO 2010]);
  • a case-sensitive phrase (^"Internal Revenue"): use the case functions in Operators;
  • title:26, which looks like a U.S. Code title number: use the titleNumber or code filters, or cite( );
  • any field a statute section does not have (see below).
The Errors table lists the exact message for each.

Field restrictions

A term normally searches the section’s body text. Wrap it in a field function to search somewhere else. Write the function name directly before the parenthesis: title (x) is a 422. Fields a statute section does not have are refused by name rather than ignored: dates, judges, courts, parties and the other case-law fields, annotations, credits and history notes, and search-engine fields such as site:. Filter by year with yearFrom and yearTo, by jurisdiction with state, and by code with code or titleNumber. For a section’s amendment history, read GET /us/statutes/section/{actId}/changes.

Sentences and paragraphs in statute text

/s and /p depend on where a sentence and a paragraph end. Statute text is not ordinary prose, so the boundaries are defined for it, and they are real boundaries rather than fixed word windows. So in “(a) The landlord may recover. (b) The tenant shall pay.”, landlord /p tenant does not match: (b) after a period starts a new paragraph.
A sentence ends at a sentence-ending period, question mark or exclamation mark followed by a new sentence. Legal abbreviations, decimals and initials do not end one: “Sec.”, “U.S.C.” and “1950.5” stay inside their sentence.A paragraph starts at any of these:
  • a blank line;
  • a subsection marker such as (a), (1), (iv), (A) or (aa) that starts a line, or follows a ., ; or :;
  • a heading line starting Sec., Section, §, Rule or Article.
A single line break is never a paragraph boundary, because much statute text is hard-wrapped mid-sentence. A marker inside a sentence (“under subsection (b) of this section”) does not start a paragraph, and a chained marker such as (2) (a) stays one paragraph rather than leaving the (2) alone. A section with none of these boundaries is one paragraph.

Wildcards and fuzzy terms

parsedQuery echoes the expression unchanged except where the table says otherwise. Rules:
  • A wildcard needs at least 3 letters or digits before the first *, !, $ or ?. ab* and *ability are refused. There are no leading wildcards.
  • A length-limited wildcard ($N, or a run of *) allows 1 to 5 extra characters. Use a single * for any number.
  • An expression can hold at most 20 wildcard and fuzzy terms, counting those inside phrases.
  • A fuzzy term allows at most 2 edits (an insertion, deletion or substitution each) and needs at least 3 letters.
  • A wildcard matches letters and digits only. It never crosses a space or punctuation.

Text pasted from Word, PDFs and the web

The expression is normalized before it is read, so a search copied out of a document behaves like one typed by hand.

Response fields

true means totalMatches is the exact number of matching sections. false means it is an upper bound: the expression uses an operator the count cannot judge exactly (phrases, /s, /p, proximity, atleastN, wildcards inside proximity), or you set a filter the count does not apply (anything other than corpusType, state, actStatus and excludeRepealed). Every result you are served still satisfies the expression; only the count is a ceiling. A section the corpus holds under two ids, such as a Federal Rule kept in two collections, is counted twice and served once.
nextOffset is usually offset plus limit. Past the relevance-ranked results a page can hold fewer rows than limit, because candidates outside your filters, or failing the expression on its full text, are left out. When full-text verification runs out of time, the page stops early and nextOffset resumes exactly where it stopped, so always page with nextOffset rather than computing the offset yourself.
To get the total without the results, send the same expression to POST /us/statutes/count with matchType: "boolean". It returns the same figure as count, with isExact in place of totalMatchesExact, for 1 credit.
matchContexts shows where a section satisfied the expression, the way research services show hits in context. Each passage is about 240 characters of the section’s text, cut on word boundaries, with whitespace runs shown as one space and soft hyphens removed. highlights lists [start, end] character offsets into that passage’s text (end exclusive), so you choose how to style them.The highlights come from the same engine that decides whether a section matches, so each one took part in the match:
  • every conjunct of an AND;
  • the OR branches that matched;
  • a whole phrase;
  • both operands of a satisfied /N, /s or /p pair (not the words between them);
  • the occurrences atleastN counted;
  • for a NOT W/N b, the a with no b in range.
A NOT never highlights anything, and a word that occurs only where it did not take part in the match is not highlighted. The first occurrence of each part of the expression is shown before a second occurrence of any. Offsets point at the text as printed, so a highlight for section can cover § and one for café can cover CAFÉ.
Unlike excerpt, which is the passage the relevance model ranked and may not contain your terms, a context always does. matchContexts is [] when the expression matched only in the heading or citation (title( ) or cite( )). It is absent on a row whose passages could not be prepared within the search’s time allowance, such as a very long section; the row is still a verified match. Contexts never change which sections are returned, their order or the price. Leaving matchContexts out of fields skips the work entirely.

Recall: what you get and what you do not

Boolean mode guarantees precision: every section returned satisfies the expression. It also pages to the end of the matches, up to the offset ceiling and the relevance-ranked count in Limits. Read totalMatches to know how many there are, and page with nextOffset until hasMore is false. Four things still bound what comes back:
  • The deepest offset is reached. When totalMatches is larger than you can page to, narrow with state, corpusType, code or titleNumber, or split the expression, to reach the rest.
  • Wildcard and fuzzy terms can miss a rare word form.
  • Very long sections can sit further down the pages than their relevance alone would put them.
  • Verification time can stop a page early.
Wildcards. Wildcard and fuzzy terms match the word forms found while searching. retaliat* matches every form that turns up in the candidate sections, which in practice is every common form, but a rare form that appears only in sections the search never reached can be missed. If one form matters, write it out: retaliat* OR retaliatory.Long sections. When the words of an AND or a proximity pair sit far apart in a long section, that section is still found, but it can sit further down the pages than its relevance alone would put it.Verification time. Multi-word phrases and proximity connectors are confirmed against each candidate’s full text within one search’s time budget. When time runs out after some matches were confirmed, those matches are served as a normal 200, and a candidate that was not confirmed is never served as a match. When it runs out before any match was confirmed, the search is a 422 (see Errors). Narrowing with state or corpusType, or using fewer /s and /p connectors, reaches the rest.
An empty Boolean result means no section in your scope that the search reached satisfies the expression. Before concluding the corpus holds nothing, loosen the expression (/s to /p, /p to AND, a phrase to its words joined by AND) or widen the scope. To count the sections that satisfy an expression, send it to POST /us/statutes/count with matchType: "boolean". To count or list every section in a body of law regardless of wording, use POST /us/statutes/count without a query and GET /us/statutes/divisions. See How search works.

Pricing

A Boolean search is priced like any search, and every page is its own call. Batch routes charge the single-call price once per item, so batching saves round trips and never gives a discount. These are the prices at the time of writing. GET /api-credits/pricing is the live list, and creditsConsumed on each response is what that call actually billed. A Boolean count on POST /us/statutes/count costs 1 credit, and a count of zero is refunded. What is charged on a failure or an empty result is in Failure and charging.

Limits

Exceeding any of the first eleven limits returns 422. Limits are refused, never truncated: a search that quietly dropped part of your expression would return a different set than the one you asked for. Two limits behave differently:
  • Verification time is one search’s time budget. When no match was confirmed in time the search is a 422 and is not charged. Matches confirmed in time are served.
  • Relevance-ranked results are not refused. Later results follow in keyword (BM25) order.

Coming from another service

If you already write terms-and-connectors searches on another service, these differences matter: AND is always written out. Two operands next to a parenthesis with no operator between them, as in landlord tenant (deposit), are a 422 that names the missing operator.

Errors

An expression we cannot read returns 422 with a detail string. It names the problem and, where there is one, the 0-based character position in your query.

Failure and charging

Common mistakes

A query over 500 characters fails schema validation instead, with the errors array and its loc described in Errors.
One 422 is about an expression’s weight, not its syntax. Every result is verified against the section’s full text, and multi-word phrases and proximity (/s, /p, /N, atleastN( ), wildcards inside a proximity pair) need that check to confirm each candidate. When the check runs out of time before confirming any match, the search returns 422 and is not charged:

For AI agents

Checklist for an expression that does what you mean on the first call:
  1. Send matchType: "boolean". Without it the operators are searched as words, and the response carries queryHint (Response fields).
  2. Write operators in UPPERCASE: AND, OR, NOT, /s, /p, /5 (Operators).
  3. Write AND between concepts, because a space makes a phrase (Coming from another service).
  4. Parenthesize every OR group and any mix of operators, because precedence differs from textbook Boolean (Precedence).
  5. Read parsedQuery to confirm the grouping, log it rather than the raw string, and fix the expression any queryWarnings entry names (Response fields).
  6. Page with nextOffset until hasMore is false (Recall).
On 422, change the request before retrying. On 503, retry with backoff and leave the expression alone. Both are covered in Failure and charging.
  1. Quote multi-word terms to make phrases explicit: "security deposit".
  2. Prefer /s or /p to AND when two ideas must be connected, not merely present in a long section.
  3. Every expression needs one positive term. NOT x alone is refused.
  4. Scope with request fields, not query words. Use state, corpusType, code, titleNumber, yearFrom and yearTo. Field functions exist only for title( ), cite( ) and text( ).
  5. Quote matchContexts, not excerpt, to show why a section matched. The highlights are the words that satisfied the expression; excerpt may not contain them. When matchContexts is absent, fetch the body before quoting.
  6. Read totalMatches first when you need every match: when totalMatchesExact is false it is an upper bound. For the total alone, send the expression to POST /us/statutes/count.
Last modified on November 7, 2026