Downloads

Downloading data that can be converted to authorityspoke objects.

So far this only covers the Case Access Project API.

authorityspoke.io.downloads.download_case(cap_id=None, cite=None, save_to_file=True, filename=None, directory=None, filepath=None, full_case=False, api_key=None, always_list=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.

  • save_to_file (bool) – whether to save the opinion to disk in addition to returning it as a dict. Defaults to True.

  • filename (Optional[str]) – the filename (not including the directory) for the file where the downloaded opinion should be saved.

  • directory (Optional[Path]) – a Path object specifying the directory where the downloaded opinion should be saved. If None is given, the current default is example_data/cases.

  • filepath (Optional[Path]) – Complete path to the location where the JSON file should be saved, including filename.

  • 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 Case 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 (bool) – 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.