Skip to main content

CourtListener API Client

A Python client for the CourtListener API, providing access to millions of legal opinions, dockets, judges, and more from Free Law Project.

Using an LLM? This repo also ships the CourtListener MCP server, which exposes the API to any Model Context Protocol client (Claude Desktop, Cursor, etc.). See MCP_README.md for connection details and for running it locally. Free Law Project hosts it at mcp.courtlistener.com. See the MCP documentation on the wiki for setup instructions.

Installation

pip install courtlistener-api-client

Authentication

You'll need a CourtListener API token. You can get one by creating an account and generating a token in your profile settings.

Set it as an environment variable:

export COURTLISTENER_API_TOKEN="your-token-here"

Or pass it directly to the client:

from courtlistener import CourtListener

client = CourtListener(api_token="your-token-here")

Quickstart

from courtlistener import CourtListener

client = CourtListener()

# Get a specific opinion by ID
opinion = client.opinions.get(1)

# Search for opinions
response = client.opinions.list(cluster__case_name="Miranda")

# Access results from the current page
for opinion in response.get_results():
    print(opinion)

# Check the total count of matching results
print(response.get_count())

# Iterate through all results across pages
response = client.dockets.list(court="scotus")
for docket in response:
    print(docket)

Pagination

List queries return a ResourceIterator that handles pagination automatically:

results = client.dockets.list(court="scotus")

# Iterate through all results across all pages
for docket in results:
    print(docket)

# Or navigate pages manually
results = client.dockets.list(court="scotus")
print(results.get_results())  # current page results

if results.has_next():
    results.next()
    print(results.get_results())  # next page results

Available Endpoints

Access any endpoint as an attribute on the client. Each endpoint supports .get(id) and .list(**filters).

Endpoint Description
search Search opinions, RECAP, judges, and oral arguments
dockets Court dockets
docket_entries Docket entries
recap_documents RECAP documents
opinions Court opinions
opinions_cited Citation relationships
clusters Opinion clusters
courts Court information
audio Oral argument audio
people Judges and other persons
positions Judge positions
parties Case parties
attorneys Attorneys
financial_disclosures Financial disclosures
alerts User alerts
docket_alerts Docket alerts
prayers Pray and Pay requests
tags User-created tags
visualizations Visualization data
schools Schools
educations Judge education records
political_affiliations Political affiliations
aba_ratings ABA ratings
fjc_integrated_database FJC integrated database

See the CourtListener API docs for the full list and available filters.

API usage and rate limits

client.api_usage.get() returns your live throttle usage per scope and rate, daily request counts for the last 14 days, and membership status. The endpoint has its own throttle scope, so checking usage never spends the quota being checked and it stays reachable when you are rate limited.

usage = client.api_usage.get()

for row in usage["current_usage"]:
    print(row["scope"], row["rate"], row["remaining"], row["reset_at"])

print(usage["historical_usage"]["total"])

Async

AsyncCourtListener mirrors CourtListener method for method. Anything that makes a request is awaited, iteration uses async for, and the client is an async context manager.

from courtlistener import AsyncCourtListener

async with AsyncCourtListener() as client:
    opinion = await client.opinions.get(1)

    results = client.dockets.list(court="scotus")
    async for docket in results:
        print(docket)

Metadata

Release files for courtlistener-api-client 1.3.0

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

Source distribution (sdist)

Source distribution for courtlistener-api-client 1.3.0
File Size Uploaded Provenance Actions
courtlistener_api_client-1.3.0.tar.gz 240.2 kB Without provenance Details for courtlistener_api_client-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for courtlistener-api-client 1.3.0
File Interpreter ABI Platform Actions
courtlistener_api_client-1.3.0-py3-none-any.whl Python 3 none any Details for courtlistener_api_client-1.3.0-py3-none-any.whl

Total release size: 470.8 kB

Release files / courtlistener_api_client-1.3.0.tar.gz

Download URL courtlistener_api_client-1.3.0.tar.gz
Size 240.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c45f3a53615fa41b7a248e5f17e0ace18daef4f23fbbe8dff10fe08e6958a355
BLAKE2b-256 checksum
How to use checksums
7d318de4b353648a4d0c7af15d9a674b770b75d01c2def63b76533d62af98ab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / courtlistener_api_client-1.3.0-py3-none-any.whl

Download URL courtlistener_api_client-1.3.0-py3-none-any.whl
Size 230.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00d53d64c0d8e7e87f42775e184b3684035aa7f469fd21276bf754d7b517dc45
BLAKE2b-256 checksum
How to use checksums
ad7e1bfa2c99dff80a1799ae6a02234ea5f52a1d50c90bb7605c0126a3cb7498
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for courtlistener-api-client 1.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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