cap-examples icon indicating copy to clipboard operation
cap-examples copied to clipboard

Examples for getting started using https://case.law

CAP examples

CircleCI

A repository of examples of what can be done with Caselaw Access Project data.

Table of Contents

  • Introduction
  • Examples
  • Contributing instructions
  • Using the API
  • Download bulk data
  • Installation Instructions - install this repo to run examples on your own machine

Start here!

  • Introduction

More examples

  • Bulk Case Extract - Get cases from our api's /bulk endpoint. Extract cases into a dataframe.
  • Full Text Search - Get all cases that include a keyword.
  • Full Text Search with Context - Like full text search, only this time using your API key to get the context around the word.
  • Ngrams – Use the open Arkansas bulk cases to explore interesting words.
  • Bulk Exploration: ngrams and Justice Cartwright – Use the open Illinois bulk cases to explore interesting words, and look at a Judge's opinion publishing history.
  • Map Courts - Map all the courts on a U.S. map.
  • Python Wrapper - Python wrapper for searching cases, downloading to CSV, etc.
  • Get Judges - Get judges and return CourtListener Person urls
  • API to CSV - Command line Python3 script with no external dependencies, fetching search results from the cases endpoint and writing to a CSV.
  • Labelling case parties and summarizing cases - Using some basic machine learning to label who the parties in each case were, and then summarizing the case text.

Interested in contributing your own examples?

  1. Fork this repository
  2. Install dependencies
  3. Add your work
  4. Make sure to add any requirements your project needs to requirements.in
  5. Run pip-compile --output-file requirements.txt requirements.in
  6. Add a link in the Examples section
  7. Create a pull request
  8. Receive gratitude (thank you so much!!)

Using the API

Read our API documentation.

In order to download non-whitelisted cases, you must register for an API key.

Once you have your API key, copy and paste it into your secret keys file settings.py.

Downloading bulk data

Helper methods to download whitelisted bulk data

These example require the existence of an API key in settings.py. Follow the instructions above in the Using the API section to obtain one.

Download the Illinois dataset

(capexamples) $ fab get_cases_from_bulk:Illinois

Or, download the Arkansas dataset

(capexamples) $ fab get_cases_from_bulk:Arkansas

Download a dataset with casebody format as xml

(capexamples) $ fab get_cases_from_bulk:Illinois,data_format=xml

Install

These examples assume some python knowledge. We will be using python3. This code has been tested using Python 3.9.10. We will also be installing all our dependencies and working in a virtual environment.

$ python3 -mvenv venv
$ source venv/bin/activate
$ (venv) pip install -r requirements.txt

Set up!

(venv) $ pip install -r requirements.txt
(venv) $ fab setup

To run jupyter notebook examples (i.e. any file ending in .ipynb):

(venv) $ jupyter notebook