DEV Community

carrierone
carrierone

Posted on

Querying Federal Court Records (PACER) Programmatically

Querying Federal Court Records (PACER) Programmatically

As legaltech developers, we often need to programmatically access and query federal court records. One of the primary sources for obtaining such data is PACER (Public Access to Court Electronic Records), which provides access to a vast array of case documents from across the United States.

Small Python Code Example

Here’s a simple example using requests library to fetch a document from PACER:


python
import requests

def get_pacer_document(pacer_case_id, pacer_doctype, pacer_docnum):
    url = f"https://api.pacerpc.gov/api/v1/PDF/{pacer_case_id}/{pacer_doctype}/{pacer_docnum}"
    headers = {
        'X-PACER-KEY': '<YOUR_PACER_API_KEY>',  # Replace with your actual PACER API key
        'Accept': 'application/pdf'
    }

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

# Example usage
pacer_case_id = "1"
pacer_doctype = "Opinion"
pacer_docnum = "1"
document_content = get_pacer_document(pacer_case_id, pacer_do
Enter fullscreen mode Exit fullscreen mode

Top comments (0)