Welcome to pycanlii’s documentation!

Contents:

class pycanlii.canlii.CanLII(apikey, language=<Language.en: 1>)

This is base the object used to interface with the CanLII API.

case_databases()

Returns a list of CaseDatabase objects, each representing the case database on CanLII :return: A list of CaseDatabase objects

legislation_databases()

Returns a list of LegislationDatabase objects, each representing a legislation database on CanLII

Returns:A list of LegislationDatabase objects
search(query, max_results, offset=0)

Searches the CanLII database for documents related to the input query

Parameters:
  • query – A string representing your search query
  • max_results – The number of results to be returned at max, must be less than 100.
  • offset – This can technically be anything, any positive integer anyways.
Returns:

A list of Case and Legislation objects representing the search results

class pycanlii.legislation.LegislationDatabase(data, apikey, language=<Language.en: 1>)

A database of CanLII Legislation. This object is both indexable and iterable.

Attributes:
name:A string representing the name of this LegislationDatabase
type:An instance of the LegislationType enum indicating what kind of Legislation this LegislationDatabasecontains
id:A string representing the databaseId of this LegislationDatabase
jurisdiction:An instance of a Jurisdiction enum representing the Jurisdiction of the Legislation in this LegislationDatabase
class pycanlii.legislation.Legislation(data, apikey, language=<Language.en: 1>)

An object representing Legislation on CanLII

Attributes:
databaseId:A string representing the databaseId of this legislation
legislationId:A string representing the legislationId of this legislation
title:A string representing the title of this legislation
content:A BeautifulSoup object representing the HTML content of this legislation
url:A string representing the URL where this legislation can be found
dateScheme:An instance of the DateScheme enum representing the dateScheme of this legislation
startDate:A date object representing the start date of this legislation
endDate:A date object representing the end date of this legislation. If it has no end date yet, it will be none
repealed:A boolean representing whether or not this legislation has been repealed or not
class pycanlii.case.CaseDatabase(data, apikey, language=<Language.en: 1>)

A database of CanLII Cases. This object is both indexable and iterable. These are both abstractions of the API. The API allows a maximum of 10000 cases at a time, so when populating the database it will grab all of the cases for you. If you are doing a loop or indexing very far into a CaseDatabase that is very large, be wary of 403 response codes, as by default you’re limited to 10 requests per second by the CanLII API. When a 403 response code is received an HTTPError will be raised.

Attributes:
name:A string representing the name of this CaseDatabase
id:A string representing the ID of this caseDatabase
jurisdiction:A Jurisdiction enum instance representing the Jurisdiction of this case
class pycanlii.case.Case(data, apikey)

An object representing a CanLII Case

Attributes:
content:A BeautifulSoup object representing the HTML content of this case
caseId:A string representing the caseId of this case
databaseId:A string representing the databaseId of this case
title:A string representing the title of this case
citation:A string representing the citation of this case
url:A string representing the URL where this case can be found
docketNumber:A string representing the docketNumber of this case
startDate:A date object date of this case
citedCases()

Returns a list of up to a maximum of 5 cases that are cited by this one.

Returns:A list of up to a maximum of 5 cases that are cited by this one, if there are no cited cases, None is returned
citedLegislation()

Returns a list of up to a maximum of 5 pieces of legislation that are cited by this one.

Returns:A list of up to a maximum of 5 pieces of legislation that are cited by this one, if there are no cited legislation, None is returned
citingCases()

Returns a list of up to a maximum of 5 cases that are citing this one.

Returns:A list of up to a maximum of 5 cases that are citing this one, if there are no citing cases, None is returned

Indices and tables