FokkeZB / libreview-unofficial

LibreView Unofficial API Documentation.
https://libreview-unofficial.stoplight.io/
53 stars 6 forks source link

How to get historical glucose readings for a date range? #4

Closed opsb closed 10 months ago

opsb commented 10 months ago

The graph endpoint gets your the last couple of days but I know that services like TryTerra and TryVital expose an API which let's you query LibreView glucose data between a specific range. Are there maybe some parameters which can be passed to the graph endpoint?

FokkeZB commented 10 months ago

As far as I can see TryTerra nor TryVital are open source, so I can't tell how they get that data, but I suspect they use the same APIs but then store the data so that you can query segments of it.

opsb commented 10 months ago

@FokkeZB I know that TryTerra at least doesn't store the data at all, they use webhooks for new data (based on polling LibreView) and for historical data pass the queries through to LibreView (I know this because I've used their API to query data from months before the user made a connection using their system).

FokkeZB commented 10 months ago

I haven't used TryTerra, but looking at https://tryterra.co/integrations/freestylelibre you receive data via webhooks, but that doesn't say anything about how they get it from LibreView and whether they store it or not. And as you said, you can also query it by date, so to me that suggests they do store it, or they are indeed aware of some other endpoint and/or parameters that we're not and also (from peeking at the app) are not used by LibreLinkUp.

opsb commented 10 months ago

Hey @FokkeZB, if they were storing it and querying that data then you wouldn't be able to query data from before the point you made a connection with them. Their query by date API allows you to fetch data from years before a connection was even made. They've also told me that they don't store the data which based on my previous point I'm inclined to believe.

FokkeZB commented 10 months ago

@opsb ah indeed, if you can query from (way) before the connection than apparently there's an API endpoint or parameter we don't know about. As LibreLinkUp doesn't use that itself.

I wonder if the API endpoints that LibreView uses would work with the same access token?

That uses e.g. https://api-eu.libreview.io/glucoseHistory?from=1700092800&numPeriods=5&period=14 where from is a unix epoch to start pulling in this case 5 periods of 14 days from.

Perhaps give that a try?

gui-dos commented 9 months ago

@FokkeZB

Yep, https://api.libreview.io/glucoseHistory works for me by using the access token you get after logging in.

You can get this way not the whole glucose values history but the precomputed percentiles, anyway: https://github.com/gui-dos/DiaBLE/commit/4b35dd3 ;-)

StashOfCode commented 8 months ago

Is there an api endpoint to get minute by minute historical glucose values without installing a 3rd party ios app or writing your own ios app?

I see a POST request going out of my librelink app with raw data each time I scan the sensor - I want this exact data too.

FokkeZB commented 8 months ago

@StashOfCode that is exactly what you can get via the Libre API documented (unofficially) in this repo and published at https://libreview-unofficial.stoplight.io/