DEV Community

carrierone
carrierone

Posted on

Querying Federal Court Records (PACER) Programmatically

Querying Federal Court Records (PACER) Programmatically for LegalTech Developers

As a legaltech developer working on e-discovery projects or case monitoring systems, having access to federal court records is crucial. The Public Access to Court Electronic Records (PACER) API provides the necessary data programmatically. Below is an example of how you can fetch PACER data using Python.

Small Python Code Example

First, you need to install the requests library if you don't have it already:

pip install requests
Enter fullscreen mode Exit fullscreen mode

Here's a simple script that demonstrates fetching case information from PACER:

import requests

def get_case_info(case_number):
    url = f"https://api.pacerpc.gov/v1/cases/{case_number}"

    headers = {
        "X-API-Key": "YOUR_PACER_API_KEY",  # Replace with your actual API key.
    }

    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Failed to fetch case info: {response.text}")

# Example usage
case_number = "15-cv-03647"
try:
    data = get_case_info(case_number)
    print(data)
except Exception as e:
    print(e)
Enter fullscreen mode Exit fullscreen mode

Mention

Top comments (0)