OS Data Hub Downloads API
Open Data Product
- class osdatahub.DownloadsAPI.opendata.OpenDataDownload(product_id: str)
Bases:
osdatahub.DownloadsAPI.downloads_api._DownloadsAPIBase
Main class for downloading OS OpenData products (https://osdatahub.os.uk/docs/downloads/technicalSpecification#/OS%20OpenData)
- Parameters
product_id (str) – Valid ID for a Downloads API Product or DataPackage.
- download(output_dir: Union[str, pathlib.Path] = '.', file_name: Optional[str] = None, file_format: Optional[str] = None, file_subformat: Optional[str] = None, area: Optional[str] = None, download_multiple: bool = False, overwrite: bool = False, processes: Optional[int] = None) list
Downloads Product files to your local machine
- Parameters
output_dir (Union[str, Path], optional) – the path where the downloaded files will be saved. Defaults to current working directory
file_name (str, optional) – name of the file(s) to download
file_format (str, optional) – format of the file(s) to download
file_subformat (str, optional) – subformat of the file(s) to download
area (str, optional) – The area that the file must cover. Available values can be found in osdatahub.codes.AREA_CODES or on the OS Data Hub website
download_multiple (bool, optional) – whether to download multiple files if multiple products are within your search criteria. Defaults to False
overwrite (bool, optional) – whether to overwrite existing files. Defaults to False
processes (int, optional) – Number of processes with which to download multiple files. Only relevant if multiple files will be downloaded (and download_multiple is set to True)
- product_list(file_name: str = None, file_format: str = None, file_subformat: str = None, area: str = None, return_downloadobj: bool = False) Union[list, dict]
Returns a list of possible downloads for a specific OS OpenData Product based on given filters
- Parameters
file_name (str, optional) – Filter the list of downloads to only include those with this file name
file_format (str, optional) – Filter the list of downloads to only include those with this format
file_subformat (str, optional) – Filter the list of downloads to only include those with this subformat
area (str, optional) – values can be found here
return_downloadobj (bool, optional) – Returns the downloadable files as _DownloadObj objects instead of as a json. Defaults to False
- Returns
List of downloadable files from Downloads API
Data Package
- class osdatahub.DownloadsAPI.data_package.DataPackageDownload(key: str, product_id: str)
Bases:
osdatahub.DownloadsAPI.downloads_api._DownloadsAPIBase
Main class for downloading OS Premium Data Packages (https://osdatahub.os.uk/docs/downloads/technicalSpecification#/Data%20Packages)
- Parameters
key (str) – A valid OS API Key. Get a free key here - https://osdatahub.os.uk/
product_id (str) – Valid ID for Downloads API DataPackage.
- classmethod all_products(key) list
Returns a list of all available data packages
- Parameters
key (str) – A valid OS API Key. Get a free key here - https://osdatahub.os.uk/
Returns: A list of dictionaries containing all available Data Packages
- download(version_id: str, output_dir: Union[str, pathlib.Path] = '.', file_name: str = None, overwrite: bool = False, processes: int = None) list
Downloads Data Package files to your local machine
- Parameters
version_id (str) – The version id of the data package to download
output_dir (Union[str, Path], optional) – the path where the downloaded files will be saved. Defaults to current working directory
file_name (str, optional) – name of the file(s) to download
overwrite (bool, optional) – whether to overwrite existing files. Defaults to False
processes (int, optional) – Number of processes with which to download multiple files. Only relevant if multiple files will be downloaded (and download_multiple is set to True)
- product_list(version_id: str, return_downloadobj: bool = False) Union[list, dict]
Returns a list of possible downloads for a specific OS Premium Data Package based on given filters
- Parameters
version_id (str) – Filter the list of possible downloads by the version id of the given product
return_downloadobj (bool, optional) – Returns the downloadable files as _DownloadObj objects instead of as a json. Defaults to False
- Returns
List of downloadable files from Downloads API
- property versions: list
Get all the available versions for the data package