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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrx_legal-0.1.19.tar.gz (64.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrx_legal-0.1.19-py3-none-any.whl (73.1 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

0.1.44

2 files

0.1.43

2 files

0.1.42

2 files

0.1.41

2 files

0.1.40

2 files

0.1.39

2 files

0.1.38

2 files

0.1.37

2 files

0.1.36

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.30

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

This release

0.1.19 This release

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page