timoschlueter / nightscout-librelink-up

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.
MIT License
192 stars 246 forks source link

Data always missing last few measurements - method to get latest data as well? #19

Closed caffe12345 closed 2 years ago

caffe12345 commented 2 years ago

First off I'm really impressed by this work.

I would like to adapt the code to display current measurements on a fitness band for Libre 3. However, when I run the code the result of the "/graph" GET-request is always missing the last few measurements. In other projects I saw people using "/glucoseHistory" but this somehow leads to error now.

Have you get any idea how to also fetch the latest data?

Thanks alot

timoschlueter commented 2 years ago

Thank you very much. :)

The /graph endpoint contains the history as well as the current measurement. My application uses both. The current measurement is always added the list of measurements first and the history is used to backfill the data.

If you look at the code here https://github.com/timoschlueter/nightscout-librelink-up/blob/ea3ab6c8c5d2010a9e2ac17c2383304e50df01f6/index.js#L149 you can see that you can find the latest measurement in the connection -> glucoseMeasurement path of the JSON response.

The history can be found under graphData. I am planning on putting together a Swagger UI documentation. That should help a lot :)