matrx-legal
Legal data integrations for the Matrx ecosystem. Standalone-installable; first-class inside aidream.
Initial provider: CourtListener (REST API v4, bulk S3 dumps, webhooks). Designed to host additional sources (Westlaw, Lexis, Justia, CAP, Caselaw Access Project) behind a uniform interface.
What it does
- Async client for CourtListener REST API v4 with token-bucket throttling, cursor pagination, retry, and 429/
Retry-Afterhandling. - Pydantic models for every public response shape.
- Optional ORM persistence (matrx-orm) for cached opinions, dockets, courts, citations.
- Optional bulk ingest from CourtListener's free quarterly S3 dumps via Postgres
COPY. - Optional RAG indexing of opinion full-text (host injects the embedder).
- Optional FastAPI streaming endpoints (host wires them up).
- AI tool callables ready to register with
matrx-ai's tools registry.
Quick start
import asyncio
from matrx_legal.courtlistener import CourtListenerClient
async def main():
async with CourtListenerClient() as client:
async for hit in client.search(q="miranda v arizona", type="o", page_size=20):
print(hit.case_name, hit.absolute_url)
asyncio.run(main())
Set COURTLISTENER_API_TOKEN in your environment.
Host integration
import matrx_legal
from my_app.settings import settings
from my_app.db import LegalOpinion, LegalDocket # subclassed from matrx_legal.orm
matrx_legal.configure(
settings=settings,
db_models={"LegalOpinion": LegalOpinion, "LegalDocket": LegalDocket, ...},
file_handler_class=FileManager,
embedder=my_embedder,
)
Standalone testing
uv run pytest packages/matrx-legal/tests
Tests must pass with only matrx-utils installed.
Release files for matrx-legal 0.1.126
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| matrx_legal-0.1.126.tar.gz | 68.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matrx_legal-0.1.126-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 143.5 kB
Release files / matrx_legal-0.1.126.tar.gz
| Download URL | matrx_legal-0.1.126.tar.gz |
|---|---|
| Size | 68.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33e317078c456819e291785d34120e4025c4efebbb8b7e59713185e34e2f4bc7
|
|
BLAKE2b-256 checksum How to use checksums |
1be563341446f689348b3c728fb3c106187b2c8975b15a984c0a7a5c7523fc33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logRelease files / matrx_legal-0.1.126-py3-none-any.whl
| Download URL | matrx_legal-0.1.126-py3-none-any.whl |
|---|---|
| Size | 75.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eac5bdd4050263b574ca1f298ae79d455b39233d9417db38f5cddac8672bbd1
|
|
BLAKE2b-256 checksum How to use checksums |
9571a9b8627412bc686dc3122f0adb52390ce440570fd72073306a79e5937a1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency log