Downloading Decisions
Download client for data that can be converted to Decision and Opinion objects.
- class justopinion.download.CourtListenerClient(api_token)
Downloads judicial decisions from CourtListener API.
- get_api_headers(full_case=False)
Get API headers based on whether the full case text is requested.
- fetch(query, full_case=False)
Query by CourtListener id or citation, and download Docket from CourtListener API.
- Return type:
- fetch_cite(cite)
Get the API list response for a queried citation from the CourtListener API.
This will require a query to the citation-lookup endpoint <https://www.courtlistener.com/api/rest/v4/citation-lookup/>, so the CourtListenerClient will need to have the api_token attribute.
- Parameters:
cite (
str|CaseCitation) – a citation linked to an opinion in the CourtListener database. Usually these will be in the traditional format[Volume Number] [Reporter Name Abbreviation] [Page Number], e.g. 750 F.3d 1339 for Oracle America, Inc. v. Google Inc.full_case – whether to request the full text of the opinion from the API’s Opinions endpoint.
- Return type:
- Returns:
the “results” list for this queried citation.
- fetch_id(id, full_case=False)
Download a decision from CourtListener API.
- Parameters:
id (
int) –an identifier for a docket in the CourtListener database, e.g. 260804 for Oracle America, Inc. v. Google Inc..
full_case (
bool) – whether to request the full text of the opinion (unused in CourtListener API).
- Return type:
- Returns:
the first case in the “results” list for this queried citation.
- read_id(id, full_case=False)
Download a decision from Caselaw Access Project API.
- Parameters:
cap_id –
an identifier for a docket in the CourtListener database, e.g. 260804 for Oracle America, Inc. v. Google Inc..
full_case (
bool) – whether to request the full text of the opinion from the CourtListener API. If this isTrue, the CourtListenerClient must have the api_token attribute.
- Return type:
- Returns:
a Decision created from the first case in the “results” list for this queried citation.
- read_decision_from_response(response)
Deserialize a list of cases from the “results” list of a response from the CourtListener API.
- Parameters:
response (
Response) – a response from the CourtListener API- Return type:
- Returns:
all decisions in the “results” list for the response
- read_citation_response(response)
Deserialize a single case from the “results” list of a response from the CourtListener API.
- Parameters:
response (
Response) – a response from the CourtListener API- Return type:
- Returns:
the first decision in the “results” list for the response
- read_cite(cite)
Download a decision from Caselaw Access Project API.
- Parameters:
cap_id –
an identifier for a docket in the CourtListener database, e.g. 260804 for Oracle America, Inc. v. Google Inc..
full_case –
whether to request the full text of the opinion from the CourtListener API. If this is
True, the CourtListenerClient must have the api_token attribute.
- Return type:
- Returns:
a Decision created from the first case in the “results” list for this queried citation.
- class justopinion.download.CAPClient(api_token='')
Downloads judicial decisions from Case Access Project API.
- fetch(query, full_case=False)
Query by CAP id or citation, and download Decision from CAP API.
- Return type:
- read(query, full_case=False)
Query by CAP id or citation, download, and load Decision from CAP API.
- Return type:
- get_api_headers(full_case=False)
Get API headers based on whether the full case text is requested.
- fetch_cite(cite, full_case=False)
Get the API list response for a queried citation from the CAP API.
- Parameters:
cite (
str|CaseCitation|CAPCitation) – a citation linked to an opinion in the Caselaw Access Project database. Usually these will be in the traditional format[Volume Number] [Reporter Name Abbreviation] [Page Number], e.g. 750 F.3d 1339 for Oracle America, Inc. v. Google Inc.full_case (
bool) – whether to request the full text of the opinion from the Caselaw Access Project API. If this isTrue, the CAPClient must have the api_token attribute.
- Return type:
- Returns:
the “results” list for this queried citation.
- read_decision_list_by_cite(cite, full_case=False)
Download and deserialize the “results” list for a queried citation from the CAP API.
- Parameters:
cite (
str|CaseCitation|CAPCitation) –a citation linked to an opinion in the Caselaw Access Project database. Usually these will be in the traditional format
[Volume Number] [Reporter Name Abbreviation] [Page Number], e.g. 750 F.3d 1339 for Oracle America, Inc. v. Google Inc.full_case (
bool) –whether to request the full text of the opinion from the Caselaw Access Project API. If this is
True, the CAPClient must have the api_token attribute.
- Return type:
- Returns:
the first case in the “results” list for this queried citation.
- read_decisions_from_response(response)
Deserialize a list of cases from the “results” list of a response from the CAP API.
- read_decision_from_response(response)
Deserialize a single case from the “results” list of a response from the CAP API.
- read_cite(cite, full_case=False)
Download and deserialize a Decision from Caselaw Access Project API.
- Parameters:
cite (
str|CaseCitation|CAPCitation) –a citation linked to an opinion in the Caselaw Access Project database. Usually these will be in the traditional format
[Volume Number] [Reporter Name Abbreviation] [Page Number], e.g. 750 F.3d 1339 for Oracle America, Inc. v. Google Inc.full_case (
bool) –whether to request the full text of the opinion from the Caselaw Access Project API. If this is
True, the CAPClient must have the api_token attribute.
- Return type:
- Returns:
the first case in the “results” list for this queried citation.
- fetch_id(cap_id, full_case=False)
Download a decision from Caselaw Access Project API.
- Parameters:
cap_id (
int) –an identifier for an opinion in the Caselaw Access Project database, e.g. 4066790 for Oracle America, Inc. v. Google Inc..
full_case (
bool) –whether to request the full text of the opinion from the Caselaw Access Project API. If this is
True, the CAPClient must have the api_token attribute.
- Return type:
- Returns:
the first case in the “results” list for this queried citation.
- read_id(cap_id, full_case=False)
Download a decision from Caselaw Access Project API.
- Parameters:
cap_id (
int) –an identifier for an opinion in the Caselaw Access Project database, e.g. 4066790 for Oracle America, Inc. v. Google Inc..
full_case (
bool) –whether to request the full text of the opinion from the Caselaw Access Project API. If this is
True, the CAPClient must have the api_token attribute.
- Return type:
- Returns:
a Decision created from the first case in the “results” list for this queried citation.
- exception justopinion.download.CaseAccessProjectAPIError
Error for failed attempts to use the Case Access Project API.
- exception justopinion.download.CourtListenerAPIError
Error for failed attempts to use the CourtListener API.