public:api_python

Approved

Cosinuss Api Python

Download the zip and extract:

If you are already familiar with python syntax, then it is fairly easy to work with the scripts.

It is required to have the latest version of python installed on your system. If you do not have python on your system, you can install it here. please follow their instruction for installation depending on your operating system.

if you have windows as your operating system, then you need to also add python to PATH on your system as described in details here

In addition, installation of python packages are also required, which can be done easily using pip or pip3 for installation(depending on your operating system).

pip3 install python-jose 
pip3 install pandas 
pip3 install pathlib 
pip3 install requests 

In case you also want to plot the data, then you also need to pip or pip3 install matplotlib as well:

pip3 install matplotlib 

you can save the downloaded zip file in any location on your system. when you extract the zip file, then the content of folder is structured as demonstrated below:

├── cosinuss_api
    ├── download_data.py
    ├── test_api_routes.py
    ├── cosinuss/api_client.py
    └── cosinuss/api_login.py

The cosinuss/*.py files are cosinuss lib. With test_api_routes.py you can test available routes of the cosinuss API and with download_data.py you can download data from a project.

Before downloading the data change the config part of the script download_data.py. Replace params with your own username, project_hash and define your target data_path. And define the data_types you want to download.

# CONFIG
username = 'username'
project_hash = '6QP3'
data_path = Path('data_export')
data_types = ['heart_rate', 'spo2']

If you want to download and store all the data files that are created for your project, then please run the download_data.py in the command line as below:

python3 download_data.py

alternatively, if you are a windows user:

py download_data.py

The script will not download the same data twice unless you delete the corresponding file again. Therefore, pay attention if the data file is from the same day and new data is still being recorded. You can change the code or make your own code to avoid this.

provide each script with username and password of your own account ID and password. Make sure that your username is assigned to all projects, otherwise the returned x and y values will be empty.

Note: Pay attention that the user role should be api, otherwise an access will be denied. Also don't forget to assign the user to the specific projects from which the data shall be downloaded.

any feedback would be welcome. We encourage you to also visit our documentation and user manuals. If you have any issues or questions, you can contact your supervisor via email. We will get in touch as soon as possible.

  • public/api_python.txt
  • Last modified: 2024/07/10 17:37
  • by tim.adams