API Overview
The LexBuild Data API provides programmatic access to over one million structured U.S. legal documents. You can retrieve individual sections, list and filter collections, search across sources, and browse hierarchical structures — all through a standard REST interface.
Base URL: https://lexbuild.dev/api
All endpoints are prefixed with /api/. There is no version prefix in the URL — new sources and fields are added without breaking existing responses.
Supported Sources
The API serves three sources of U.S. federal law:
| Source | Path Prefix | Description |
|---|---|---|
| U.S. Code (USC) | /api/usc/ | General and permanent federal statutes organized into 54 titles |
| eCFR | /api/ecfr/ | Continuously updated CFR content organized into 50 titles |
| Federal Register (FR) | /api/fr/ | Daily journal of the U.S. government: rules, proposed rules, notices, and presidential documents |
The API uses ecfr in route prefixes and source filters because the current regulatory corpus
comes from the Electronic Code of Federal Regulations. Canonical document identifiers still use
the /us/cfr/... namespace because the identifier scheme is keyed to the content type rather than
the transport source.
Key Features
- Content negotiation — Get responses as JSON (default), raw Markdown with YAML frontmatter, or stripped plaintext. Use the
Acceptheader or?format=query parameter. - Pagination — Offset-based pagination with configurable limits, totals, and a
nextlink for easy traversal. Document collection endpoints also support cursor pagination for deep result sets. - Filtering and sorting — Source-specific filters (title number, agency, document type, date ranges) and multi-field sorting.
- Field selection — Request only metadata, only the body, or specific fields to reduce response size.
- Full-text search — Cross-source search with faceted filtering, highlighting, and relevance ranking.
- ETag caching — Every document response includes an
ETagheader. SendIf-None-Matchto get a304 Not Modifiedwhen the content has not changed. - Rate limiting — Tiered rate limits with transparent
X-RateLimit-*headers on every response.
Quick Example
Fetch U.S. Code Title 1, Section 1 as JSON:
curl https://lexbuild.dev/api/usc/documents/t1%2Fs1
{
"data": {
"id": "us-usc-t1-s1",
"identifier": "/us/usc/t1/s1",
"source": "usc",
"metadata": {
"identifier": "/us/usc/t1/s1",
"source": "usc",
"display_title": "1 U.S.C. 1 - Words denoting number, gender, and so forth",
"title_number": 1,
"title_name": "General Provisions",
"section_number": "1",
"section_name": "Words denoting number, gender, and so forth",
"chapter_number": "1",
"chapter_name": "Rules of Construction",
"legal_status": "law",
"positive_law": true,
"status": "in_force"
},
"body": "In determining the meaning of any Act of Congress..."
},
"meta": {
"api_version": "v1",
"format_version": "1.0",
"timestamp": "2026-04-04T12:00:00.000Z"
}
}
When you use cursor pagination on document collection endpoints, pagination.total becomes
null because the API skips the expensive count query.
Interactive Documentation
The API includes a built-in interactive reference powered by Scalar. You can browse all endpoints, see request/response schemas, and test requests directly in your browser:
- API Reference UI: lexbuild.dev/docs/api
- OpenAPI Spec: lexbuild.dev/api/openapi.json
The OpenAPI 3.1 spec can be imported into tools like Postman, Insomnia, or any OpenAPI-compatible client.
Response Envelope
All JSON responses follow a consistent envelope structure:
{
"data": { },
"meta": {
"api_version": "v1",
"format_version": "1.0",
"timestamp": "2026-04-04T12:00:00.000Z"
}
}
Collection endpoints add a pagination object:
{
"data": [ ],
"meta": { },
"pagination": {
"total": 1542,
"limit": 20,
"offset": 0,
"has_more": true,
"next": "/api/usc/documents?offset=20&limit=20"
}
}
Next Steps
- Authentication — API keys and rate limits
- Document Endpoints — Retrieve and list documents
- Search — Full-text search across all sources
- Content Negotiation — JSON, Markdown, and plaintext formats