Package for Python
Our package (Holistics Package for Python) allows Python's user export report's data by inputting:
- Your API-key
- Report's ID
- Dictionary of filters applied to that report
Notes:
Supported output format: DataFrame object, .CSV Python version: >= 3, < 4
#
InstallationPackage can be installed with pip
:
Alternatively, you can grab the latest source code from GitHub:
#
How to export dataBeginning by import holistics package
Next, creating an object of HolisticsAPI class with your API-key and Holistics server's url
Args:
api_key
(str): Your account's API-key.url
(str) (optional): URL of your Holistics server- Default value: 'https://secure.holistics.io'
Finally, call export_data function with specific syntax: โ โ export_data (report_id, path, filters, page_size, page)
Args:
report_id
(str): ID of report. Get from URL.path
(str) (optional): If you want to store export data to local path, set path variable.- Default value: None
- Ex: 'D:/Data/output.csv'
filters
(dict) (optional): dictionary of filters that would be applied to report.- Default value: None
- Ex: {'tenant': 'holistics', 'date': '2017-04-28'}
page_size
(int) (optional): Set the page size of the response.- Default value: 10000000
page
(int) (optional): Set the page number of data to fetch.- Default value: 10000000
#
Return:A DataFrame object. If path
is not None, save object as .csv file at that path.
#
Raises:HTTPError
: If the program can't connect to target site and get data.- You should check your API-key, url of Holistics and internet connection.
RuntimeError
: If return status is Failure.- It could be caused by wrong SQL of your QueryReport.
ParserError
: If program can't parse downloaded data as DataFrame object.- It could be caused when downloaded data is None.