burnedikt / diasend-nightscout-bridge

Synchronize your diasend data to nightscout.
MIT License
18 stars 18 forks source link

Have you worked out any other diasend endpoints? #1

Closed grahamjenson closed 1 year ago

grahamjenson commented 2 years ago

Hey, I am working on some stuff related to diasend and found very little information. I have as well been able to pull down the patient/data but am looking for the endpoint that exposes the pump settings and have had little luck. Have you found anything useful about the API endpoints?

PieterDeBruijn commented 2 years ago

Currently: CamAPS --> Diasend Soonish: CamAPS --> Dexcom Follow (which is not Dexcom Share? Dexcom Share can send all data to Diasend (https://international.diasend.com/patient/account/apps). Long term: CamAPS will move from Diasend to the new Glooko environment, which will should have API access, so I'm told.

I try to use Nightscout as my main data portal, so everything needs to end up in there. Currently xDrip+ sends BGL from CamAPS and our Caresense Dual blood readings to Nightscout.

burnedikt commented 2 years ago

I have as well been able to pull down the patient/data but am looking for the endpoint that exposes the pump settings and have had little luck. Have you found anything useful about the API endpoints?

From my attempts to reverse-engineer the API due to the lack of any available documentation, it appears that there are no endpoints exposing the information you're looking for. The API that exists appears to have been tailor-made for the diasend app (which also doesn't offer the data you're looking for). So the only way to obtain that data to my knowledge would be to scrape the diasend website or use their export functionality.

Personally, I am planning to extend this project to import all available data from diasend to nightscout, not just the CGM values, but haven't yet spent a lot of time experimenting on getting that data.

burnedikt commented 2 years ago

Soonish: CamAPS --> Dexcom Follow (which is not Dexcom Share? Dexcom Share can send all data to Diasend (https://international.diasend.com/patient/account/apps).

That sounds like quite an improvement already since Dexcom (Folllow) at least appears to offer some APIs to get the data (but naturally, those will be focussed on CGM / BGL / EGV I assume?). Anyhow, is it already confirmed that the CamAPS team is working on that integration?

Long term: CamAPS will move from Diasend to the new Glooko environment, which will should have API access, so I'm told.

Do you have any information what long-term means? I am fairly new to the whole T1D world but I assume it could take years?

I try to use Nightscout as my main data portal, so everything needs to end up in there. Currently xDrip+ sends BGL from CamAPS and our Caresense Dual blood readings to Nightscout.

I've just recently found out about xDrip+ being able to pull the CGM data from CamAPS directly (thanks @grahamjenson ) but haven't tried it out personally yet. Does it also support pulling other data apart from the BGL values?

E.g. one issue I'm having with diasend right now is that it doesn't provide information about the BGL trend (up, down, steady, ...) since I guess it's goal is more on the side of historial reports than on the real-time monitoring.

grahamjenson commented 2 years ago

Unfortunatly xDrip pulling from CamAPS is a giant hack, so will not be able to support pulling any other data like insulin. How it works is it listens to the notifications that CamAPS publshes to the Android hopmescreen, then xDrip parses that notification (very manually) to extract the data. This is super jank, so can result in missed and incorrect readings.

I also did a bit more deep dive into diasend via. CamAPS, it seems that the other data (pump settings...) are uploaded to diasend via S3, so not very useful. I did find an enpoint https://api.diasend.com/1/patient/setting which seems active but I am just getting errors from. Perhaps to read it I need a different oAuth scope or something.

I have seen a few CamAPS docs that state they are working on sending their data to Dexcom directly, which has clarity (IMHO better than diasend). AFAIK all these integrations take years, or become vaporware which never happen, so waiting is not the best option.

PieterDeBruijn commented 2 years ago

That sounds like quite an improvement already since Dexcom (Folllow) at least appears to offer some APIs to get the data (but naturally, those will be focussed on CGM / BGL / EGV I assume?). Anyhow, is it already confirmed that the CamAPS team is working on that integration? Schermafbeelding 2022-08-20 121136 The delay I am told is only on the Dexcom side, implementation is finished, but Dexcom needs to turn it on.

Do you have any information what long-term means? I am fairly new to the whole T1D world but I assume it could take years? End of the year. Schermafbeelding 2022-08-20 125415

I try to use Nightscout as my main data portal, so everything needs to end up in there. Currently xDrip+ sends BGL from CamAPS and our Caresense Dual blood readings to Nightscout.

Xdrip Does it also support pulling other data apart from the BGL values? Nope, only BGL values, without backfill, so sometimes you get gaps.

burnedikt commented 2 years ago

I have as well been able to pull down the patient/data but am looking for the endpoint that exposes the pump settings and have had little luck. Have you found anything useful about the API endpoints?

So the only way to obtain that data to my knowledge would be to scrape the diasend website or use their export functionality.

I found some time today to do some scraping and put together some code to pull down the basal profile from the diasend website due to the lack of a proper API. It should be fairly simple to also scrape any other data of interest from there.

@grahamjenson You can check it out and see if that does what you need.

burnedikt commented 2 years ago

Update: v0.5.0 of this library supports obtaining the pump settings from diasend website like:

import { getPumpSettings, getAuthenticatedScrapingClient } from "./diasend";

const username = "my.user@diasend.com";
const password = "super-secret-password";

const { client, userId } = await getAuthenticatedScrapingClient({
  username, password
});

console.log(await getPumpSettings(client, userId));

yields

{
  "basalProfile": [
    ["00:00", 0.5],
    ["06:00", 1.0],
    ["12:00", 0.3],
    ["16:30", 0,7]
  ],
  "insulinCarbRatioProfile": [
    ["00:00", 20],
    ["06:00", 10],
    ["12:00", 15],
    ["16:30", 20]
  ],
  "insulinSensitivityProfile": [
    ["00:00", 350]
  ],
  "bloodGlucoseTargetLow": 70,
  "bloodGlucoseTargetHigh": 160,
  "insulinOnBoardDurationHours": 3,
  "units": "mg/dl",
funkstille commented 1 year ago

Just forked your cgm-remote-monitoring repo and deployed it to heroku - import from diasend works out of the box --> THANK YOU - Great Work! ... but I do have a timestamp issue. Imported data is postponed 2h. Bolus from 7.35 on diasend is on 9.35 on nightscout. I will check my config at heruko and diasend and report back.

burnedikt commented 1 year ago

Just forked your cgm-remote-monitoring repo and deployed it to heroku - import from diasend works out of the box --> THANK YOU - Great Work! ... but I do have a timestamp issue. Imported data is postponed 2h. Bolus from 7.35 on diasend is on 9.35 on nightscout. I will check my config at heruko and diasend and report back.

Yeah, that's kind of a known issue and was raised already here. The workaround right now is to make sure that the TZ is correctly set on your nightscout instance (on heroku). Should be set to the same timezone you're in. Diasend sadly doesn't tell us what timezone the data is in, so the data is just considered to be in the timezone the nightscout instance operates in (which by default is UTC). If you're in Germany, set TZ=Europe/Berlin and you should be fine.

burnedikt commented 1 year ago

Closing this due to the original question being answered. Feel free to open a new issue if you have some follow-up questions