OpenHumans / oh-fitbit-integration

Integration for connecting & importing Fitbit data into the Open Humans platform
https://fitbit.openhumans.org
0 stars 6 forks source link

Updates to Fitbit's API endpoints for sleep? #26

Open madprime opened 4 years ago

madprime commented 4 years ago

Looking at this: https://github.com/OpenHumans/oh-fitbit-integration/blob/master/datauploader/tasks.py

... it seems that the endpoint is going to https://api.fitbit.com/1/user

That prefix is still used for the following:

However from the sleep documentation: https://dev.fitbit.com/build/reference/web-api/sleep/

... I see the endpoint seems to be updated to be like https://api.fitbit.com/1.2/user/-/sleep/. (Note the "1.2".)

I was looking into this because I'd like to be collecting the sleep stages data (minute-by-minute information about which "stage" of sleep is occurring), which appears to be available in this new endpoint. (I think the old one is working but deprecated: https://dev.fitbit.com/build/reference/web-api/sleep-v1/ )

madprime commented 4 years ago

There's a temptation to clean up with versioned files and stuff but here’s an approach I think might be lossless and a lot easier.

  1. Add a new JSON key to fitbit_urls that stores all the relevant data from the new endpoint
  2. Fill it in with data into the past.
  3. Leave the old ones in place, and let them keep updating if they can. (Don’t care if it’s redundant.)

I think this is “good enough” as I expect it’s lossless, gets the new data, and allows (further) cleanup at some later date (which I don’t expect to happen, but at least it hasn’t been rendered impossible). It should be backwards compatible as long as something using the data isn't upset by the appearance of a new key (which seems very unlikely).