Open alfredoramirez3 opened 4 days ago
patient_data.history
should return the complete set of measurements that are reported by the LLU api's /llu/connections/{patient_id}/graph
endpoint, which is not the full history of the patient's readings.
The raw response is exposed as the raw
property on the ConnectionResponse
model returned by the call to read()
, so you should be able to check that nothing has been dropped.
what do you get if you run the following, replacing the {email}
, {password}
, and {patient_id}
with your values?
from pylibrelinkup import PyLibreLinkUp
import json
client = PyLibreLinkUp(email="{email}", password="{password}")
client.authenticate()
conn_response = client.read(patient_identifier="{patient_id}")
raw_data = json.loads(conn_response.raw)
print(f"patient data history length: {len(conn_response.history)}")
print(f"raw graph data length: {len(raw_data['graph_data'])}")
interestingly, running that with known login details for me gives only 47 items, but they do match:
patient data history length: 47
raw graph data length: 47
https://gist.github.com/khskekec/6c13ba01b10d3018d816706a32ae8ab2 Please view comment by faysal-ali dated Feb 6 and ATouhou response dated Feb 10.. @faysal-ali I was able to access more data than described in this Gist, using the "/logbook" endpoint. Same headers and setup as "/graph" url. The data available from that is the same as is shown in the app under "log book / Logbog (danish)".
to your point, I was hoping to get "full history". not sure if using the /graph endpoint provides "full history" or just more data points.
any chance of adding an additional method that utilizes the /logbook endpoint?
sorry, correction ...
to your point, I was hoping to get "full history". not sure if using the "/logbook" endpoint provides "full history" or just more data points.
any chance of adding an additional method that utilizes the "/logbook" endpoint?
Hi @alfredoramirez3 - apologies for that, i misunderstood your original question.
any chance of adding an additional method that utilizes the "/logbook" endpoint?
That's an excellent idea. Yeah, I can absolutely do that.
I'm fairly sure it'll still be only a truncated set of the full history, but if it's more than just the graph data, that's at least something..
Hmm. looking at that thread, further down, there appears to be a suggestion that the data is only available from LibreView, and not LibreLinkUp (which would make sense given that the URL is /glucoseHistory/history
, and doesn't have the usual llu/connections/{patient_id}/{endpoint}
format.
I'll have a look into it though. If i can't implement that glucoseHistory
endpoint via the LLU api, I'll add the logbook
endpoint as a new method at the very least.
Wonder why the api’s didn’t provide start and end timestamp arguments for data extraction.
I’m a retired Data Engineer/Data Integration. Poor API design.
yeah, the API is weird in places. don't even get me started on the fact that some of their json keys are camelCase and others are snake_case, even in the same object!
it makes my eye twitch just looking at it. 😄
hi @alfredoramirez3 - i have a PR to implement support for that logbook endpoint on a working branch. if you want to give it an early play and see how it works for you, you can uninstall the pypi installed version and install it directly from github.
pip uninstall pylibrelinkup
pip install git+https://github.com/robberwick/pylibrelinkup.git@logbook-endpoint
I still need to write up some docs for it, and i might end up fiddling with the read
method now that it's not the only method for retrieving data, so it's a bit poorly named, but you should be able to have a play with that logbook endpoint and see how you get on.
patient_data.history only returns 141 items; not the complete history.