stravalib icon indicating copy to clipboard operation
stravalib copied to clipboard

Paginated response handling

Open jsamoocha opened this issue 3 years ago • 5 comments

There are many methods in Client (e.g., get_activities()) that return a BatchedResultsIterator instance. The Strava API parameter that manages how many results are returned per page is per_page (which, BTW, has a deprecation warning in the swagger.json but not in the published API docs).

However, none of the stravalib client methods support the per_page or page parameters that allow paginated results. To better match the Strava API and allow developers to customize paginated responses, wouldn't it be better if the client methods would have these per_page and page parameters as well?

In the short term, a quick-n-dirty workaround is to manually set these attributes on the BatchedResultsIterator instance returned by the client method.

jsamoocha avatar Nov 09 '22 14:11 jsamoocha

I agree that this would be an improvement. If that is the only parameter that Strava API supports, I think just adding this to those methods directly makes sense. If it is anticipated that there would be other parameters that would be part of the specification on how results are returned (e.g. other systems might include things like sort field, sort direction, etc.) then probably some sort of PatinationInfo object/dataclass would make sense. (But from memory and this ticket description, that is probably overkill for this API.)

hozn avatar Nov 09 '22 18:11 hozn

I think we should consider that many users run stravalib in CI and some of them did not lock the version in requirements.txt If we have some break change we should be carefully.

yihong0618 avatar Nov 10 '22 00:11 yihong0618

Yeah, I think adding a new optional parameter would be fine (not breaking), but agree that we should be careful about not breaking API if the version is not changing major version numbers.

hozn avatar Nov 10 '22 13:11 hozn

hi @jsamoocha - this is an older issue but still has some activity. Is this an ongoing issue or did you address this @jsamoocha with the big API restructure? Just lemme know as with the other issues . i can organize things we want to do vs closing older things that have been already addressed as it makes sense!

lwasser avatar Feb 12 '24 02:02 lwasser

This is not fixed yet.

jsamoocha avatar Feb 12 '24 08:02 jsamoocha