Downloads

Downloading data that can be converted to authorityspoke objects.

authorityspoke.io.downloads.download_enactment_from_client(path, client, date='')

Download Enactment object from an API.

Allows either a real client or a fake testing client.

authorityspoke.io.downloads.download_enactment(path, date='', api_token='', api_root='https://authorityspoke.com/api/v1')

Download Enactment object from an API using the Legislice JSON schema.

Parameters
  • path (str) – a path to the desired legislation section using the United States Legislation Markup tree-like citation format.

  • date (Union[date, str]) – The date of the desired version of the provision to be downloaded. This is not needed if a CrossReference passed to the query param specifies a date. If no date is provided, the API will use the most recent date.

  • api_token (str) – An authentication key for the API that will serve the enactment data.

  • api_root (str) – The URL where the API can be found.

authorityspoke.io.downloads.download_case(cap_id=None, cite=None, full_case=False, api_key=None, many=False)

Download cases from Caselaw Access Project API.

Queries the Opinion endpoint of the Caselaw Access Project API, saves the JSON object(s) from the response to the example_data/cases/ directory in the repo, and returns one or more dict objects from the JSON.

Parameters
  • cap_id (Optional[int]) – an identifier for an opinion in the Caselaw Access Project database, e.g. 4066790 for Oracle America, Inc. v. Google Inc..

  • cite (Optional[str]) –

    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. If the cap_id field is given, the cite field will be ignored. If neither field is given, the download will fail.

  • full_case (bool) –

    whether to request the full text of the opinion from the Caselaw Access Project API. If this is True, the api_key parameter must be provided.

  • api_key (Optional[str]) – a Caselaw Access Project API key. Visit https://case.law/user/register/ to obtain one. Not needed if you only want to download metadata about the opinion without the full text.

  • always_list – If True and as_generator is False, a single case from the API will be returned as a one-item list. If False and as_generator is False, a single case will be a list.

Return type

Union[Dict[str, Any], List[Dict[str, Any]]]

Returns

a case record or list of case records from the API.

class authorityspoke.io.downloads.FakeClient(responses)

Repository for mocking API responses locally.

fetch(query, date='')

Fetches data about legislation at specified path and date from Client’s assigned API root.

Parameters
  • path – A path to the desired legislation section using the United States Legislation Markup tree-like citation format. Examples: /us/const/amendment/IV, /us/usc/t17/s103

  • date (Union[date, str]) – A date when the desired version of the legislation was in effect. This does not need to be the “effective date” or the first date when the version was in effect. However, if you select a date when two versions of the provision were in effect at the same time, you will be given the version that became effective later.

Return type

Dict[str, Any]

Returns

A fake JSON response in the format of the Legislice API.