Developers
No signup. No API key. No rate limits.
Install
npm
npm install -g open-legal-codes
Or with the TIDY-scoped package:
npm install -g @tidydotcom/open-legal-codes
Homebrew (macOS / Linux)
brew install tidyapp/tap/open-legal-codes
curl (no install needed)
# Search for a term
curl 'https://openlegalcodes.org/api/v1/jurisdictions/ca-mountain-view/search?q=dog&limit=5'
# Get a specific section
curl 'https://openlegalcodes.org/api/v1/jurisdictions/ca-mountain-view/code/chapter-5/article-i/section-sec.-5.1'
# Find a jurisdiction by name
curl 'https://openlegalcodes.org/api/v1/lookup?city=Mountain+View&state=CA'
npx (one-off, no install)
npx open-legal-codes search --jurisdiction ca-mountain-view --query "dog"
REST API
Base URL: https://openlegalcodes.org/api/v1
GET /jurisdictions # List all jurisdictions
GET /jurisdictions?state=CA # Filter by state
GET /jurisdictions?cached=true # Only cached (ready) jurisdictions
GET /jurisdictions/:id # Jurisdiction metadata + lastCrawled timestamp
GET /jurisdictions/:id/toc?depth=2 # Table of contents
GET /jurisdictions/:id/code/:path # Section text + permalink
GET /jurisdictions/:id/caselaw/:path # Court opinions citing this statute
GET /jurisdictions/:id/search?q=parking # Full-text search within a jurisdiction
GET /search?q=parking&state=CA # Search across all cached jurisdictions
GET /lookup?city=Mountain+View&state=CA # Find by name
Search is full-text across all indexed sections — not just headings. The global /search endpoint only covers cached jurisdictions; use /jurisdictions?cached=true to see what's available. Check lastCrawled in /jurisdictions/:id to see when a jurisdiction was last synced.
Case law
For any statute, you can look up court opinions that have cited it. Results are returned in reverse chronological order (most recent first) with pagination via limit and offset.
# Court opinions citing California Penal Code § 187 (murder)
GET /jurisdictions/ca-pen/caselaw/part-1/title-8/section-187?limit=20&offset=0
# Response
{
"data": {
"supported": true,
"totalCount": 356,
"cases": [
{
"caseName": "People v. Smith",
"court": "California Court of Appeal",
"dateFiled": "2026-01-15",
"url": "https://www.courtlistener.com/opinion/...",
"citation": "...",
"citeCount": 3
}
]
}
}
Case law is powered by CourtListener from the Free Law Project. We link directly to their records — we do not host or reproduce case law. Citations are matched automatically using standard citation formats and are likely imperfect. Currently supported for federal and state statutes. Nothing here constitutes legal advice.
How caching works
Content is fetched from the publisher on first request and cached. If a jurisdiction hasn't been cached yet, the API returns 202 and begins fetching in the background. Poll using the retryAfter value (seconds) until you get a 200. Subsequent requests are served instantly from cache.
# First request — not cached yet
GET /jurisdictions/ca-san-francisco/toc
→ 202 { "status": "CRAWL_IN_PROGRESS", "retryAfter": 30, "progress": { "phase": "toc", ... } }
# After ~30-60 seconds
GET /jurisdictions/ca-san-francisco/toc
→ 200 { "data": { "jurisdiction": "ca-san-francisco", "children": [...] } }
Lookup and discovery
The /lookup endpoint can find any US city or county by name — even jurisdictions not yet in the catalog. It searches the registry, then probes publishers (Municode, American Legal, eCode360) to discover who hosts the code. Once found, it triggers a crawl automatically.
GET /lookup?city=San+Francisco&state=CA # City lookup
GET /lookup?county=Maui&state=HI # County lookup
GET /lookup?address=306+Desert+Falls+East,+Palm+Desert,+CA # Address lookup
Status endpoint
GET /status # Server health, registry size, cached count
MCP Server
Add to your Claude Desktop or Claude Code config for direct tool access:
{
"mcpServers": {
"legal-codes": {
"url": "https://openlegalcodes.org/mcp"
}
}
}
If your MCP client requires a local process instead of a URL:
{
"mcpServers": {
"legal-codes": {
"command": "npx",
"args": ["-y", "-p", "open-legal-codes", "open-legal-codes-mcp"]
}
}
}
Tools: lookup_jurisdiction, list_jurisdictions, get_table_of_contents, get_code_text, search_code, get_case_law
CLI
After installing via npm or Homebrew:
open-legal-codes search --jurisdiction ca-mountain-view --query "parking"
open-legal-codes query --jurisdiction ca-mountain-view --path part-i/article-i/section-100
open-legal-codes caselaw --jurisdiction ca-pen --path part-1/title-8/section-187
open-legal-codes toc --jurisdiction ca-mountain-view --depth 2
open-legal-codes list --state CA
open-legal-codes lookup --city "Mountain View" --state CA