DEV Community

carrierone
carrierone

Posted on

Querying Federal Court Records (PACER) Programmatically

Querying Federal Court Records (PACER) Programmatically

If you're working on a legaltech project that requires access to federal court records, you might find yourself needing to programmatically query the PACER system. The Public Access to Court Electronic Records (Pacer) is an online database provided by the United States Courts, offering electronic access to case filings from most federal district and appeals courts.

A Simple Python Code Example

Here's a quick example of how you can use Python to fetch documents from the PACER using their API. The code below uses requests library to make HTTP requests:

import requests

def get_case_documents(pacer_case_id):
    # Replace with your own Pacer account information
    api_key = "YOUR_API_KEY"

    url = f"https://api.pacerlaw.com/v2/documents/{pacer_case_id}"
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Accept': 'application/json'
    }

    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Error: {response.status_code} - {response.text}")

# Example usage
case_id = "12345"
documents = get_case_documents(case_id)
print(documents)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)