Created
December 22, 2024 07:32
-
-
Save bruderjakob12/d8f60de01a976744fd30fb5c160ab8ee to your computer and use it in GitHub Desktop.
LibreLinkUp - Python3 - minimal
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 | |
| # your LibreLinkUp-region (login-requests gives hint when credentials are ok) | |
| region = 'de' | |
| # your username | |
| email = 'your_librelinkup_email@example.com' | |
| # your password | |
| password = 'your_librelinkup_password' | |
| header = { | |
| "User-Agent":"someuseragent", | |
| "Content-Type":"application/json", | |
| "version":"4.12.0", | |
| "product":"llu.android", | |
| "Accept-Encoding":"gzip, deflate, br", | |
| "Connection":"keep-alive", | |
| "Pragma":"no-cache", | |
| "Cache-Control":"no-cache", | |
| } | |
| url = 'https://api-'+region+'.libreview.io/llu/auth/login' | |
| data = {'email': email, 'password': password} | |
| # logging in & getting token | |
| r =requests.post(url, json=data, headers=header) | |
| print(r.text) | |
| # if you selected the wrong region, the LLU-server usually suggest a redirect to the correct region (not for russian accounts - which have a totally different URL: https://api.libreview.ru) | |
| if 'region' in r.json()['data']: | |
| region = r.json()['data']['region'] | |
| url = 'https://api-'+region+'.libreview.io/llu/auth/login' | |
| r =requests.post(url, json=data, headers=header) | |
| print(r.text) | |
| # getting the available connections & the last BG reading of each | |
| header["Authorization"] = "Bearer " + r.json()['data']['authTicket']['token'] | |
| header["Account-Id"] = hashlib.sha256(r.json()['data']['user']['id'].encode()).hexdigest() | |
| url = 'https://api-'+region+'.libreview.io/llu/connections/' | |
| r2 = requests.get(url, headers=header) | |
| print(r2.text) | |
| # getting the graph of a specific connection | |
| url = 'https://api-'+region+'.libreview.io/llu/connections/' + '/'+r2.json()['data'][0]['patientId']+'/graph' | |
| r3 = requests.get(url, headers=header) | |
| print(r3.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment