stravalib
stravalib copied to clipboard
description field not correctly read from strava
Hello, I'm trying to access the description field of a ride to fetch the comments I made on a ride. However, it looks like that field is always 'None'?
hello, I was wondering if there was any update regarding this question? Perhaps I'm doing something wrong? Thanks for the great work!
hey @maartenmennes i'm going through and looking at old issues. we have redone the entire stravalib API since this issue was posted. i have not yet tested to see if i can access the activity description lately but i'm just wondering if you are still encountering this issue.
i see this closed issue that you also commented on. please let us know if this is a persistent problem with the new stravalib api or if this could be closed.
Ok i have tested this out. This actually relates to this issue . Essentially the data are there in the stravalib return. however you have to use get_activity()
rather than get_activities()
to capture description information. This is because of some support for legacy stravalib behavior which we are discussing in the newer issue.
But because we are talking this through in the other issue and this issue is quite old - i'm going to close it. @maartenmennes feel free to reach out to us / open a new issue if something comes up that we can help you with. at a minimum we will document this somewhere to make it easier for users to understand why they are getting empty returns with some calls! the data are there just not where it seems like they should be!
A fix for returning the description is below.
activities = client.get_activities(after="2024-01-18")
for activity in activities:
# This returns None / empty as it's **not** a summary level attribute but the key does appear in the returned object
activity.description
# this will return calories and description as it's a detailed level attr that can be accessed via get_activity
detailed = client.get_activity(activity.id)
detailed.calories
detailed.description