@@ -273,6 +273,41 @@ def get_activities(self, start, limit):
273273
274274 return self .fetch_data (activitiesurl )
275275
276+ def get_activities_by_date (self , startdate : str , enddate : str , activitytype = "" ) -> list [json ]:
277+ """
278+ Fetch available activities between specific dates
279+
280+ :param startdate: String in the format YYYY-MM-DD
281+ :param enddate: String in the format YYYY-MM-DD
282+ :param activitytype: (Optional) Type of activity you are searching
283+ Possible values are [cycling, running, swimming,
284+ multi_sport, fitness_equipment, hiking, walking, other]
285+ :return: list of JSON activities
286+ """
287+
288+ activities = []
289+ start = 0
290+ limit = 20
291+ returndata = True
292+ # mimicking the behavior of the web interface that fetches 20 activities at a time
293+ # and automatically loads more on scroll
294+ if activitytype :
295+ activityslug = "&activityType=" + str (activitytype )
296+ else :
297+ activityslug = ""
298+ while returndata :
299+ activitiesurl = self .url_activities + '?startDate=' + str (startdate ) + '&endDate=' + str (
300+ enddate ) + '&start=' + str (start ) + '&limit=' + str (limit ) + activityslug
301+ self .logger .debug ("Fetching activities with url %s" , activitiesurl )
302+ act = self .fetch_data (activitiesurl )
303+ if act :
304+ activities .extend (act )
305+ start = start + limit
306+ else :
307+ returndata = False
308+
309+ return activities
310+
276311 def get_excercise_sets (self , activity_id ):
277312 activity_id = str (activity_id )
278313 exercisesetsurl = f"{ self .url_exercise_sets } { activity_id } /exerciseSets"
0 commit comments