Python API Wrapper for CanLII
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
pycanlii
tests
.gitignore
.landscape.yaml
.python-version
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
requirements.txt
setup.cfg
setup.py

README.md

pycanlii Travis CI Code Health Documentation Status

Python API Wrapper for CanLII

Installation

Install the package from PyPI:

pip install pycanlii

Usage

from pycanlii import CanLII

canlii = CanLII('gHuBwvVx2VguA6meMfuXHGmy', language='en')

# Get the list of legislation databases
databases = canlii.legislation_databases()

# Print the title of all the legislation in the 5th database
for legislation in databases[4]:
    print(legislation.title)
    
# Get the list of case databases
cases = canlii.cases_databases()

# Get the 5th case in the 6th database
case = cases[5][4]

# Print the HTML content of that case
print(case.content)

# Search CanLII for a specfic case
case = canlii.search("Haldimand War Memorial Hospital", 1)[0]

# Get a list of the cases cited
cited_cases = case.citedCases()

# Print out the names of those cases
for case in cited_cases:
    print(case.title)