Skip to content

Instantly share code, notes, and snippets.

@khskekec
Last active July 21, 2024 02:11
Show Gist options
  • Save khskekec/6c13ba01b10d3018d816706a32ae8ab2 to your computer and use it in GitHub Desktop.
Save khskekec/6c13ba01b10d3018d816706a32ae8ab2 to your computer and use it in GitHub Desktop.
HTTP dump of Libre Link Up used in combination with FreeStyle Libre 3
@ATouhou
Copy link

ATouhou commented Feb 10, 2024

@mrniceboot I was looking at the wrong APK file. Manually selecting the right one, worked wonders :-D !
I've uploaded it here: https://gist.github.com/ATouhou/deaf79038a6e2083b73be41c413e392f

@Burak50
Copy link

Burak50 commented Feb 11, 2024

@faysal-ali @ATouhou @voljumet @deelo55

I took a closer look at this, in general only 90* are possible backwards.
In addition to the actual header, two parameters must be passed in each case

"numPeriods": the return is divided into several blocks to make it clearer (default: 5)
"period" The days that are to be returned (default: 90)

*I only took the 90 days from libreview.com, but more is also possible, at least the API returns more than 90 days, in my case it is more than 400 days (if I set my period to 100)

API URL: https://api.libreview.io/glucoseHistory?numPeriods=5&period=90

@Burak50
Copy link

Burak50 commented Feb 11, 2024

FYI: for future users: https://api-eu.libreview.io does not work, for me anyway, the solution was https://api-de.....

The only question is still whether this is only the case in Germany or also in other European countries

My guess is that only the countries France, Germany, Italy, Netherlands, Spain, United Kingdom and United States of America work (because that's the countries listed on freestylelibre.com in the language selection)

wCsowDI 2

eu: gq8gBh9 1

de: G2hwAgy 1

I have also been able to solve this, the assumption that only specific lengths are available is taboo.
You can see: Countrie List

@ATouhou
Copy link

ATouhou commented Feb 12, 2024

That Seems to return data that is available on libreview and not librelinkup. So in my case, unless I use the patients login id / token, it will return no data . ( {
"status": 0,
"data": {
"lastUpload": 0,
"lastUploadCGM": 0,
"lastUploadPro": 0,
"reminderSent": 0,
"devices": [],
"periods": []
}, ) .

However, I will save it in my PostMan collection. Might come in handy in the future. Thanks @Burak50

@bruderjakob12
Copy link

This seems to be the most active thread concerning the LLU API, so I'd like to share some things I've noticed:

Regions

Get the region right

You don't have to get the region for log-in right the first time. If the credentials are correct, the endpoint e.g., https://api-la.libreview.io/llu/auth/login will reply with

{"status":0,"data":{"redirect":true,"region":"de"}}

So you know that the right endpoint for these credentials is https://api-de.libreview.io/llu/auth/login.

New Region!

Since a few weeks there is a new la region (Brazil, Mexico, ??) and it seems that users have been migrated. Tokens are still valid, you just get the the FollowerNotConnectedToPatient message. For a while the status-code 911 was sent for those requests, but that subsided.

LLU 4.11 - new Header-Item Account-Id

With LLU version 4.11 a new header is required - not an issue right now, as you can set the version to 4.0 and even lower, but it might become relevant. The header-key is Account-Id and the value is the SHA256-hash of the LLU-account-id.
r is the request-object from the login.

HEADER["Account-Id"] = hashlib.sha256(r.json()['data']['user']['id'].encode()).hexdigest()

@ATouhou
Copy link

ATouhou commented Jul 8, 2024

Thanks for sharing! ^^

@m-mansoor-ali
Copy link

P.S This was in response to a comment that has been deleted

If you have no patient ID returned from the get_patient_connections(token) function, then the first possibilities that jump to my mind are:

  1. You aren't using a LibreLinkUp account, this is a different from the FreeStyle LibreLink account. The linkup account is only used to view the freestyle account.

    • The fix, download the LibreLinkUp app, sign up an account (with different email from FreeStyle LibreLink account) and from the FreeStyle LibreLink account invite the LibreLinkUp account. Then retry with the python script using LibreLinkUp account details.
  2. You are using a LibreLinkUp account, but you haven't been connected to anyone's FreeStyle LibreLink account to be able to view them.

    • The fix, get whoever you would like to view to connect your LibreLinkUp account email from their FreeStyle LibreLink app, under Connections in the sidebar (if I recall).

The patient ID should be in the format of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx a mix of numbers and lower case letters.

Just checked the endpoint using https://github.com/smpurkis/libre-api-pg/tree/old and it ran successfully for me.

I used same email id in LibreLinkUp and FreeStyle LibreLink account and it worked for me i.e. I invited same account.

@dakyskye
Copy link

Hi, beautiful dump! So as I understand LibreLinkUp application makes those HTTP calls every second or what? It's able to update display with fetched data in real-time so I was expecting some kind of continuous streaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment