Last active
September 16, 2024 06:29
-
-
Save bruderjakob12/ba865818415d345dff4257c7cfcf3b68 to your computer and use it in GitHub Desktop.
Python-script to programmatically access your Sibionics CGM data via a dedicated follower account.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import hashlib | |
| # use a dedicated follower-account as there can only be one valid access_token per user | |
| # and you will get logged out of the app | |
| password = 'hunter42' | |
| username = 'sibionicsfollower@example.com' | |
| # login in and acquire access token | |
| req = requests.post("https://cgm-ce.sisensing.com/auth/app/user/login", | |
| headers={"Accept-Encoding": "application/json"}, | |
| json={ | |
| "email": username, | |
| "password": hashlib.md5(password.encode('utf-8')).hexdigest(), | |
| }, | |
| ) | |
| print(req.json()) | |
| access_token = req.json()['data']['access_token'] | |
| # acquire list of sharers and their ids - already contains the "latesValue" in mmol/L | |
| req = requests.get("https://cgm-ce.sisensing.com/user/app/follow/sharer", | |
| headers={ | |
| "Accept-Encoding": "application/json", | |
| "Authorization": access_token | |
| } | |
| ) | |
| print(req.json()) | |
| # acquire the current and historic glucose data - seems to be always in mmol/L | |
| req = requests.post("https://cgm-ce.sisensing.com/user/app/follow/deviceGlucose", | |
| headers={ | |
| "Accept-Encoding": "application/json", | |
| "Authorization": access_token | |
| }, | |
| json={ | |
| "range": "24", # hours for which to get the data | |
| "id": req.json()['data'][0]['id'] # id for which to get the data | |
| }, | |
| ) | |
| print(req.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment