Skip to content
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

Steps data not working #168

Closed
Gishan86 opened this issue Oct 15, 2023 · 11 comments · Fixed by #174
Closed

Steps data not working #168

Gishan86 opened this issue Oct 15, 2023 · 11 comments · Fixed by #174

Comments

@Gishan86
Copy link

Hi, did Garmin change the url for steps data?
Neither one of these work:

json = api.get_daily_steps("2023-01-01", "2023-10-01")
Throws garth.exc.GarthHTTPError: Error in request: 400 Client Error: Bad Request for url: https://connectapi.garmin.com/usersummary-service/stats/steps/daily/2023-01-01/2023-10-01

json = api.get_steps_data("2023-10-17")
Returns an empty list.

On https://connect.garmin.com there is step data for 2023-10-17.
Other routes like get_weigh_ins work and return data.

Python 3.12
garminconnect==0.2.8
garth==0.4.38
@matin
Copy link
Contributor

matin commented Oct 16, 2023

  1. iirc, there's a 28-day limit for the date period
  2. 2023-10-17 is currently in the future. No result is correct

@Gishan86
Copy link
Author

Thanks for your quick response!

  1. I've also tried 2022-10-15 to 2022-10-20 and 2023-10-01 to 2023-10-05
    which both resulted in the same exception

  2. Yeah, that was a typo, not a time traveller. :)
    With 2022-10-18 I get results but they are all empty.
    It returns an empty entry for every 15 minutes of the day like this:

[{'startGMT': '2022-10-17T22:00:00.0', 'endGMT': '2022-10-17T22:15:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T22:15:00.0', 'endGMT': '2022-10-17T22:30:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T22:30:00.0', 'endGMT': '2022-10-17T22:45:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T22:45:00.0', 'endGMT': '2022-10-17T23:00:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T23:00:00.0', 'endGMT': '2022-10-17T23:15:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T23:15:00.0', 'endGMT': '2022-10-17T23:30:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T23:30:00.0', 'endGMT': '2022-10-17T23:45:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-17T23:45:00.0', 'endGMT': '2022-10-18T00:00:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T00:00:00.0', 'endGMT': '2022-10-18T00:15:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T00:15:00.0', 'endGMT': '2022-10-18T00:30:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T00:30:00.0', 'endGMT': '2022-10-18T00:45:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T00:45:00.0', 'endGMT': '2022-10-18T01:00:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T01:00:00.0', 'endGMT': '2022-10-18T01:15:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, {'startGMT': '2022-10-18T01:15:00.0', 'endGMT': '2022-10-18T01:30:00.0', 'steps': 0, 'pushes': 0, 'primaryActivityLevel': 'none', 'activityLevelConstant': True}, ...]

The web UI shows 17.843 steps for 2022-10-18 though.

@matin
Copy link
Contributor

matin commented Oct 16, 2023

I have the same issue for 2022-10-18. Can you try a more recent date like 2023-10-01?

@matin
Copy link
Contributor

matin commented Oct 16, 2023

weekly works though:

api.garth.connectapi('/usersummary-service/stats/steps/weekly/2022-10-18/52')

@matin
Copy link
Contributor

matin commented Oct 16, 2023

daily also works for me:

api.get_daily_steps('2022-10-01', '2022-10-28')

It looks like the issue is when you want to get the granular data for an individual day.

@matin
Copy link
Contributor

matin commented Oct 16, 2023

Figured it out ...

Take a look at this:
IMG_4340

You can do the following:

  1. Request Garmin loads the old data:
resp = api.garth.post('connectapi', '/wellness-service/wellness/epoch/request/2022-10-18', api=True)
resp.json()

Response:

{'userProfilePk': 2591602,
 'calendarDate': '2022-10-18',
 'status': 'SUBMITTED',
 'source': 'USER',
 'ghReloadMetaData': '',
 'createDate': '2023-10-16T17:49:56.980',
 'deviceList': [{'deviceId': 3329978681,
   'deviceName': 'fēnix® 6X - Pro and Sapphire Editions',
   'preferredActivityTracker': True}]}
  1. Wait a few minutes for the data to load

  2. Make the request again

api.get_steps_data("2022-10-18")

In other words, this is not a garminconnect or Garth issue. It has to do with how Garmin handles old data.

This issue can be closed as it has instructions to:

  1. request weekly steps
  2. request daily steps
  3. request Garmin load old step data and then request that granular data

HTH!

@matin
Copy link
Contributor

matin commented Oct 16, 2023

@cyberjunky not sure if you want to add the following endpoint:

api.garth.post('connectapi', '/wellness-service/wellness/epoch/request/2022-10-18', api=True)

See the conversation above for context on what it does.

@Gishan86
Copy link
Author

Thanks, would appreciate if the endpoint could be added

@cyberjunky
Copy link
Owner

Lets keep open so I won't forget to add it ;)

@cyberjunky cyberjunky reopened this Oct 17, 2023
@cyberjunky
Copy link
Owner

@cyberjunky not sure if you want to add the following endpoint:

api.garth.post('connectapi', '/wellness-service/wellness/epoch/request/2022-10-18', api=True)

See the conversation above for context on what it does
@matin
Can you enlighten me, didn't follow whole issue...
Do I need to add this fixed endpoint with 2022-10-18 at the end?

matin added a commit to matin/python-garminconnect that referenced this issue Oct 29, 2023
@matin
Copy link
Contributor

matin commented Oct 29, 2023

@cyberjunky created the PR #174 with tests

Here's how it works:

def test_request_reload(garmin):
    garmin.login()
    cdate = "2021-01-01"
    assert sum(steps['steps'] for steps in garmin.get_steps_data(cdate)) == 0
    assert garmin.request_reload(cdate)
    # In practice, the data can take a while to load
    assert sum(steps['steps'] for steps in garmin.get_steps_data(cdate)) > 0

hirebusbrandon pushed a commit to hirebusbrandon/python-garminconnect that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants