API Help: Python Guidelines
server_api_example folder available at the end of this documentation, consists of python scripts for interacting with the cosinuss lab_server api. If you are already familiar with python syntax, then it is fairly easy to work with the scripts.
The instructions explained here, is also available as README file in the folder. If you are more comfortable to read the README file in your preferable IDE, you can jump to last section and download the zip file.
Note: please make sure to read the README file first, if you decided to jump to download the zip file.
Install Python
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
Folder structure
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:
├── server_api_example_folder ├── API_requests_helper.py ├── dl_all_data_files.py ├── dl_all_df_person_hash.py └── README.md
as you can see, there are 3 different scripts in the folder. The dl_all_data_files.py and dl_all_df_person_hash.py, are the files that you need to work with, depending on which data you want to download from server.
The files will be discussed in following sections.
Download all data files
If you want to download and store all the data files that are created for your scope, then please run the dl_all_data_files.py in the command line as below:
python3 dl_all_data_files.py
alternatively, if you are a windows user:
py dl_all_data_files.py
all the data will be downloaded and stored in a new folder created in the server_api_example_folder,with the name data_files, as csv files.
Download all data files of selected persons
maybe you would like to just download created data files for one or more specific persons in the project, then you can run the dl_all_df_person_hash instead:
python3 dl_all_df_person_hash.py
for windows users:
py dl_all_df_person_hash.py
The downloaded data files will be stored in the data_files_persons folder, which has been created as a new folder in the server_api_example_folder.
Tips and Notes
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.
contact and support
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.