Skip to main content

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-After handling.
  • 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.

Metadata

Release files for matrx-legal 0.1.217

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrx-legal 0.1.217
File Size Uploaded Provenance
matrx_legal-0.1.217.tar.gz 69.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for matrx-legal 0.1.217
File Interpreter ABI Platform
matrx_legal-0.1.217-py3-none-any.whl Python 3 none any Details

Total release size: 145.1 kB

Security for matrx-legal 0.1.217

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for matrx_legal-0.1.217.tar.gz

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 Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.217 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page