TypeScript SDK and MCP server for CourtListener - the largest free legal database
Features • Installation • Authentication • Quick Start • API • MCP Server • CourtListener API Docs
- ⚖️ Case Law - Access millions of legal opinions from federal and state courts
- 👨⚖️ Judge Data - Comprehensive judge profiles and biographical information
- 🎙️ Oral Arguments - Audio recordings with metadata
- 📚 Citation Tools - Advanced citation lookup and normalization
- 💼 PACER Integration - Federal court docket access
- 🔔 Real-time Alerts - Track changes to cases and dockets
- 🤖 MCP Server - AI-ready server for integration with Claude and other AI assistants
- 🔍 Advanced Search - Powerful search with Elasticsearch backend
- ✨ Type-safe - Full TypeScript support with auto-completion
# npm
npm install @us-legal-tools/courtlistener-sdk
# yarn
yarn add @us-legal-tools/courtlistener-sdk
# pnpm
pnpm add @us-legal-tools/courtlistener-sdk
# bun
bun add @us-legal-tools/courtlistener-sdkThe CourtListener API requires authentication for most endpoints. Get your API token from CourtListener.
// Set via environment variable
process.env.COURTLISTENER_API_TOKEN = 'your-token';
// Or configure the axios instance directly
import { axiosInstance } from '@us-legal-tools/courtlistener-sdk';
axiosInstance.defaults.headers.common['Authorization'] = 'Token your-token';import { getSearch } from '@us-legal-tools/courtlistener-sdk';
// Search for Supreme Court cases
const results = await getSearch({
type: 'o', // 'o' for opinions
q: 'miranda rights',
court: 'scotus',
order_by: 'score desc'
});
console.log(`Found ${results.count} cases`);
results.results.forEach(result => {
console.log(`- ${result.caseName} (${result.dateFiled})`);
});import { getOpinionsId } from '@us-legal-tools/courtlistener-sdk';
// Get a specific opinion
const opinion = await getOpinionsId({ id: 123456 });
console.log(`Case: ${opinion.case_name}`);
console.log(`Court: ${opinion.court}`);
console.log(`Date: ${opinion.date_filed}`);
console.log(`Text: ${opinion.plain_text || opinion.html}`);import { getSearch } from '@us-legal-tools/courtlistener-sdk';
// Search for judges
const judges = await getSearch({
type: 'p', // 'p' for people/judges
q: 'Ruth Bader Ginsburg',
order_by: 'name_reverse asc'
});
judges.results.forEach(judge => {
console.log(`${judge.name_full} - ${judge.court}`);
});import { getAudio } from '@us-legal-tools/courtlistener-sdk';
// Get oral arguments
const audio = await getAudio({
docket__court: 'scotus',
argued_after: '2023-01-01'
});
audio.results.forEach(recording => {
console.log(`${recording.case_name} - ${recording.date_argued}`);
console.log(`Audio: ${recording.download_url}`);
});getSearch- Universal search endpoint for all content typesgetSearchV4OpinionsClusters- Search opinion clustersgetSearchV4People- Search judges and peoplegetSearchV4OralArguments- Search oral arguments
getOpinions- List opinionsgetOpinionsId- Get specific opiniongetClusters- List opinion clustersgetClustersId- Get specific cluster
getPeople- List judges and peoplegetPeopleId- Get specific person detailsgetPersonDisclosures- Get financial disclosures
getDockets- List docketsgetDocketsId- Get specific docketgetDocketEntries- List docket entriesgetDocketAlerts- Manage docket alerts
getAudio- List audio recordingsgetAudioId- Get specific audio recording
getCitations- Citation lookupgetCitationNormalize- Normalize citations
The MCP server allows AI assistants to interact with the CourtListener API.
# Using the SDK directly (requires COURTLISTENER_API_TOKEN env var)
COURTLISTENER_API_TOKEN=your-token npx @us-legal-tools/courtlistener-sdk/mcp
# Or if installed locally
cd node_modules/@us-legal-tools/courtlistener-sdk
COURTLISTENER_API_TOKEN=your-token npm run mcp:serverAdd to your Claude configuration:
{
"mcpServers": {
"courtlistener": {
"command": "npx",
"args": ["@us-legal-tools/courtlistener-sdk/mcp"],
"env": {
"COURTLISTENER_API_TOKEN": "your-token"
}
}
}
}Use the following types with the search endpoint:
o- Opinionsr- RECAP Archived- Docketsp- People/Judgesoa- Oral Argumentsopinion-cluster- Opinion Clusters
import { getSearch } from '@us-legal-tools/courtlistener-sdk';
// Complex search with filters
const results = await getSearch({
type: 'o',
q: 'first amendment',
court: 'ca9 ca10 cafc', // Multiple courts
filed_after: '2020-01-01',
filed_before: '2023-12-31',
cited_gt: 50, // Cited more than 50 times
order_by: 'dateFiled desc',
highlight: true
});import { getOpinionsId } from '@us-legal-tools/courtlistener-sdk';
try {
const opinion = await getOpinionsId({ id: 123456 });
} catch (error) {
if (error.response?.status === 401) {
console.error('Invalid API token');
} else if (error.response?.status === 404) {
console.error('Opinion not found');
} else if (error.response?.status === 429) {
console.error('Rate limit exceeded');
} else {
console.error('API error:', error.message);
}
}CourtListener has rate limits based on your account type. Free accounts are limited to 5,000 requests per day.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- npm Package
- GitHub Repository
- CourtListener Website
- CourtListener API Documentation
- Report Issues
- Request Features
Need help? Check out our documentation or create an issue.