From 80e603c47aaa34bdc359123facdb28bf82724ce0 Mon Sep 17 00:00:00 2001 From: gp Date: Sun, 19 Oct 2014 22:33:21 -0700 Subject: [PATCH] activities usage doc --- docs/index.rst | 1 + docs/usage/activities.rst | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e8487cb6..1428a0d5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -58,6 +58,7 @@ More detailed documentation to get you started usage/auth usage/overview usage/athletes + usage/activities (MORE COMING SOON) diff --git a/docs/usage/activities.rst b/docs/usage/activities.rst index f90876e5..6b7ed19f 100644 --- a/docs/usage/activities.rst +++ b/docs/usage/activities.rst @@ -3,3 +3,78 @@ Activities ********** +Examples of working with activities. + +Retrieve An Activity +==================== +To get a given activity, use the get_activity function and provide activity_id, +The function will return a :class:`stravalib.model.Activity` object.:: + + activity = client.get_activity(207650614) + print("type = " + activity.type) + +Activity object has many basic properties such as type and distance.:: + + print("type={0.type} distance={1} km".format(activity, + unithelper.kilometers(activity.distance))) + +But also many secondary properties like kudos, comments and photos which follow the following pattern.:: + + # Number of comments on activity + activity.comment_count + + # print each comment + for comment in activity.comments: + print("{} : {}".format(comment.athlete.lastname, comment.text)) + + +Activity information +-------------------- + +Most information pertaining to actitity is available directly on the :class:`stravalib.model.Activity` object. Some additional information can be retrieved relevant methods. + +Below is example of :meth:`stravalib.client.Client.get_activity_streams`:: + + # Activities can have many streams, you can request desired stream types + types = ['time', 'latlng', 'altitude', 'heartrate', 'temp', ] + + streams = client.get_activity_streams(123, types=types, resolution='medium') + + # Result is a dictionary object. The dict's key are the stream type. + if 'altitude' in streams.keys(): + print(streams['altitude'].data) + + +Additionally, activity zones can be retrieved with :meth:`stravalib.client.Client.get_activity_zones` and activity laps can be retrieved with :meth:`stravalib.client.Client.get_activity_laps` . + + + + +List of Activities +================== + +Three functions return lists of activities. + +List the authenticated athlete's activities with :meth:`stravalib.client.Client.get_activities`.:: + + for activity in client.get_activities(after = "2010-01-01T00:00:00Z", limit=5): + print("{0.name} {0.moving_time}".format(activity)) + +.. tip:: + To get activities in oldest to newest, specify a value for the `after` argument. To get newest to oldest use `before` argument. + +Additionally list the authenticated athlete's friends activities with :meth:`stravalib.client.Client.get_friend_activities`, or list a club member's activities with :meth:`stravalib.client.Client.get_club_activities`. + + +Manage Activities +================= +(TODO) + +=============== ================================================ +method doc +=============== ================================================ +create_activity :meth:`stravalib.client.Client.create_activity` +upload_activity :meth:`stravalib.client.Client.upload_activity` +update_activity :meth:`stravalib.client.Client.update_activity` +=============== ================================================ +