-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sleep stages data may require v1.2 API endpoint #128
Comments
🤔 @DanWebster Maybe we should make the version specifiable so people could use the version they want? |
Would it be better to make this set-able when initializing the OAuth2 or expose this for the different endpoints that feed into I will check today if making a 1.2 call breaks a few of the more canonical datasets and respond back here. Thanks for the quick response, btw. |
Oh that's interesting, so you could specify a different version depending upon the endpoint. Maybe you could specify a default version to use for all requests when you create the fitbit client, but then you could also override it for a specific request |
@DanWebster Thanks for checking that 👍 |
Can confirm that hardcoding in I think that this means being able to specify API version as a parameter when setting up the oauth client (rather than in each specific
|
@DanWebster Awesome, thank you for the testing! |
@DanWebster Thanks for that. I have hard coded the api version as you mentioned to get detailed sleep stages. Have you noticed any breaks on the code from that change? |
@Dannie1G Seems to work for the endpoints I am looking at (admittedly not exhaustive) with no breaks. |
I'm able to get the sleep data assuming that I know the date. I had to change the hardcoded API version just the same as this issue. Regarding additional endpoints, I am trying to get a list of nights the user has slept : https://dev.fitbit.com/build/reference/web-api/sleep/ - Get Sleep Logs List using the GET https://api.fitbit.com/1.2/user/-/sleep/list.json endpoint. I am not able to figure out from the documentation if getting a list of nights is supported by orcas-fitbit. |
@ANNCHAN not sure what kind of list you want. I’ve written a little script and posted as jupyter notebook (https://github.com/Dannie1G/python-fitbit/blob/master/Fitbit_APIv12DataCollection_gh.ipynb). In one I collect my sleep stages for each night as separate csv, and in another I collect sleep stats for dates that fall in a specific period of time. Have a look and let me know if you need help following it. |
@Dannie1G Your code assumes that you know the last date at which you want to stop from the current date. |
@aanchan I see.. yeah that makes sense, it could be handy for others PR sounds reasonable |
is it necessary to hardcode the API_VERSION? why not do
|
@aanchan did you ever decide to submit a PR for this? I just ran into this issue and it seems a bit more pertinent now that Fitbit has deprecated the 1.0 endpoints: https://dev.fitbit.com/build/reference/web-api/sleep-v1/ |
- Fix pre-midnight sleeps being shifted forwards a day, in the new API the point includes the full date and time, avoiding the confusion. - Fix stages being uncategoried, the old code checked for 1/2/3 as ints when they were actually strings, the new API includes more types, and uses strings. - I think the new API is also more granular (down to 30s) but less dense (it returns one point per stage, and tells you how long it lasted). Old: https://dev.fitbit.com/build/reference/web-api/sleep-v1 New: https://dev.fitbit.com/build/reference/web-api/sleep Workaround to enable it: orcasgit/python-fitbit#128 TODO: switch to the new GFit sleep segment API: https://developers.google.com/android/reference/com/google/android/gms/fitness/data/SleepStages
I have noticed that the data coming back from the fitbit.sleep() doesn't return the same format as specified in the current fitbit docs.
In looking through, it looks like most of the endoints are drawing from the Version 1 of the API (
GET
calls using 1 before theuser
as per below)GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json
But for the newest Sleep data, they look to be going from a 1.2 version
GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[date].json
api.py specifies API_VERSION=1; I haven't been using fitbit data until a few days ago so I am unsure whether this has a historical precedent for API differences between types and keeping backwards compatibility or not.
The text was updated successfully, but these errors were encountered: