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
@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