POST /us/statutes/search, GET /us/statutes/section/{actId}/body.
Ground an LLM answer in statutes covers multi-source answers and prompt design.
To answer in one call, pass "includeBody": true with "limit": 1. The price is the same.
Keep the two-call version below if you rank three candidates and ground on one.
The loop
1
Search on the user's message
Send the message to
POST /us/statutes/search.
Scope with corpusType and state if your bot already knows the jurisdiction.2
Pull the best section's text
Take the top result and fetch its full text with
GET /us/statutes/section/{actId}/body.3
Reply, grounded and cited
Give an LLM the section text and citation. Have it answer only from that text.
Add the official source link.
The search call on its own (cURL and JavaScript)
The search call on its own (cURL and JavaScript)
The Python version is
find_section() in the function below.The full chatbot in one function
Python
answer() from your message handler and post the result.
Tips
Set the jurisdiction once
Set the jurisdiction once
If your bot serves one state, pass
state on every search.
If users can switch states, pass the two-letter state code from the conversation.
Omit corpusType and state to search all US law.Handle the empty case
Handle the empty case
When search returns nothing or the body is unavailable, say so, as
answer() does above.Related
- Pick the best source URL: the shared preference order for the official URL.
- Grounding LLMs: why grounding on retrieved text matters.
- Resolve a citation and Vaquill MCP server.

