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
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.

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)

Release files for courtlistener-api-client 1.2.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.2.0
File Size Uploaded
courtlistener_api_client-1.2.0.tar.gz 186.8 kB Details

Built distribution (wheel)

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

Total release size: 387.2 kB

Release files / courtlistener_api_client-1.2.0.tar.gz

Download URL courtlistener_api_client-1.2.0.tar.gz
Size 186.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f617a31e2d8377e78e27da8839cefbfc98569d68aa14cb960a292ef0afe32553
BLAKE2b-256 checksum
How to use checksums
eb3f47f8e368693abfbedd826ac94f65ce669b9d1f2a8e8e9d299b916634c1b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL courtlistener_api_client-1.2.0-py3-none-any.whl
Size 200.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f424d158b40be4a5c22025f5bf6ed3b98d61b284fc5a9bbcb2ea512d52639c18
BLAKE2b-256 checksum
How to use checksums
d8cd478984b09f375bdd9a5a3159f6d54987f67f7123f2fd812d361833b8c30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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