mountainbiker_initializer: R6 Class for a strava application with authorization

Description Details Active bindings Methods See Also Examples

Description

This strava class is designed to interract with strava API using a set of methods. A mountainbikeR object must be initialized using the new method then all other method will be availabe

Details

TBD

Active bindings

token

Shows generated token.

Methods

Public methods


Method new()

Create a new moutainbiker object.

Requested scopes, as a comma delimited string, e.g. "activity:read_all,activity:write". Applications should request only the scopes required for the application to function normally. The scope activity:read is required for activity webhooks.

Usage
mountainbiker_initializer$new(
  my_app_name = NULL,
  my_client_id = NULL,
  my_client_secret = NULL,
  my_app_scope = "read,read_all,activity:read_all",
  cache = FALSE
)
Arguments
my_app_name

chr string, the name of the app defined in strava

my_client_id

chr string, the ID of the app like 27881

my_client_secret

chr string, the secret as defined in strava

my_app_scope

chr string for requested scopes, as a comma delimited

cache

a logical TRUE to keep cached token, false for not. string, e.g. "activity:read_all,activity:write"

Returns

A new 'mountainbikeR object' object.

Examples
\dontrun{
my_mb <- mountainbiker_initializer$new(
    my_app_name = "mycool_app"
    , my_client_id = 77777
    , my_client_secret = "a super secret string"
    , my_app_scope = "read,read_all,activity:read_all" #"public"
    , cache = FALSE
    )
}

Method get_activities()

List all activities from strava api. Returns the activities of an athlete for a specific identifier. Requires activity:read. Only Me activities will be filtered out unless requested by a token with activity:read_all.

Usage
mountainbiker_initializer$get_activities(
  activities_per_page = 200,
  page_number = 1,
  after_date = NULL,
  before_date = NULL
)
Arguments
activities_per_page

max number of item to return (must be 200 max)

page_number

the specific page number to extract

after_date

return activities after date as YYYY-MM-DD

before_date

return activities before date as YYYY-MM-DD


Method get_activity()

Returns the given activity that is owned by the authenticated athlete. https://developers.strava.com/playground/#/Activities/getActivityById

Usage
mountainbiker_initializer$get_activity(
  activity_id = NULL,
  include_all_efforts = FALSE
)
Arguments
activity_id

the strava id of the activity

include_all_efforts

boolean


Method get_activity_zones()

Returns the zones of a given activity. https://developers.strava.com/docs/reference/#api-Activities-getZonesByActivityId

Usage
mountainbiker_initializer$get_activity_zones(activity_id = NULL)
Arguments
activity_id

the strava id of the activity

include_all_efforts

boolean


Method get_athlete()

Get informations about the athlete

Usage
mountainbiker_initializer$get_athlete()

Method get_athlete_stats()

Get informations about the athlete stats

Usage
mountainbiker_initializer$get_athlete_stats(athlete_id = NULL)
Arguments
athlete_id

The identifier of the athlete. Must match the authenticated athlete.


Method get_athlete_zones()

Get informations about the athlete heart rate zone

Usage
mountainbiker_initializer$get_athlete_zones()

Method get_gear()

Get athlete gear description from gear id

Usage
mountainbiker_initializer$get_gear(gear_id = NULL)
Arguments
gear_id

the id of the gear to get


Method get_segment_efforts()

Returns a set of the authenticated athlete's segment efforts for a given segment.

Usage
mountainbiker_initializer$get_segment_efforts(
  segment_id = NULL,
  page = NULL,
  per_page = NULL
)
Arguments
segment_id

The identifier of the segment.

page

Page number

per_page

Number of items per page. Defaults to 30.


Method get_segment_effort()

Returns a segment effort from an activity that is owned by the authenticated athlete.

Usage
mountainbiker_initializer$get_segment_effort(effort_id = NULL)
Arguments
effort_id

the id of the specific effort to collect


Method explore_segments()

Explore segments returns the top 10 segments matching a specified query based on a bounding box.

Usage
mountainbiker_initializer$explore_segments(
  southwest_lat = NULL,
  southwest_long = NULL,
  northeast_lat = NULL,
  northeast_long = NULL,
  activity_type = NULL,
  min_climbing_cat = NULL,
  max_climbing_cat = NULL
)
Arguments
southwest_lat

southwest corner latitutde

southwest_long

southwest corner longitude

northeast_lat

northeast corner latitude

northeast_long

northeast corner longitude

activity_type

Desired activity type. May take one of the following values: running, riding

min_climbing_cat

int the minimum climbing category

max_climbing_cat

int the maximum climbing category


Method get_segment_leaderboard()

Returns the specified segment leaderboard.

Usage
mountainbiker_initializer$get_segment_leaderboard(
  segment_id = NULL,
  gender = NULL,
  age_group = NULL,
  weight_class = NULL,
  following = NULL,
  club_id = NULL,
  date_range = NULL,
  context_entries = NULL,
  page = NULL,
  per_page = NULL
)
Arguments
segment_id

int The identifier of the segment leaderboard.

gender

string, Filter by gender. May take one of the following values: M, F

age_group

string summit Feature. Filter by age group. May take one of the following values: 0_19, 20_24, 25_34, 35_44, 45_54, 55_64, 65_69, 70_74, 75_plus

weight_class

string, filter by weight class. May take one of the following values: 0_124, 125_149, 150_164, 165_179, 180_199, 200_224, 225_249, 250_plus, 0_54, 55_64, 65_74, 75_84, 85_94, 95_104, 105_114, 115_plus

following

Boolean Filter by friends of the authenticated athlete.

club_id

Long,Filter by club id

date_range

string, Filter by date range, will be in the athlete's timezone May take one of the following values: this_year, this_month, this_week, today

context_entries

Integer, ??? not documented

page

Integer, Page number

per_page

integer, Number of items per page. Defaults to 30.


Method get_starred_segments()

List of the authenticated athlete's starred segments. Private segments are filtered out unless requested by a token with read_all scope.

Usage
mountainbiker_initializer$get_starred_segments(page = NULL, per_page = NULL)
Arguments
page

Integer, Page number

per_page

integer, Number of items per page. Defaults to 30.


Method get_segment()

Returns the specified segment. read_all scope required in order to retrieve athlete-specific segment information, or to retrieve private segments.

Usage
mountainbiker_initializer$get_segment(segment_id = NULL)
Arguments
segment_id

the strava id of the segment


Method get_activity_streams()

Returns the given activity's streams. Requires activity:read scope. Requires activity:read_all scope for Only Me activities.

Usage
mountainbiker_initializer$get_activity_streams(
  activity_id = NULL,
  streams_types = NULL
)
Arguments
activity_id

the strava id of the segment

streams_types

vector of esired stream types. May take the following values: "time", "latlng", "distance", "altitude", "velocity_smooth", "heartrate", "cadence", "watts", "temp", "moving", "grade_smooth"


Method get_segment_effort_streams()

Returns a set of streams for a segment effort completed by the authenticated athlete. Requires read_all scope.

Usage
mountainbiker_initializer$get_segment_effort_streams(
  effort_id = NULL,
  streams_types = NULL
)
Arguments
effort_id

The identifier of the segment effort.

streams_types

vector of esired stream types. May take the following values: "time", "latlng", "distance", "altitude", "velocity_smooth", "heartrate", "cadence", "watts", "temp", "moving", "grade_smooth"


Method get_segment_streams()

Returns the given segment's streams. Requires read_all scope for private segments.

Usage
mountainbiker_initializer$get_segment_streams(
  segment_id = NULL,
  streams_types = NULL
)
Arguments
segment_id

the strava id of the segment

streams_types

vector of esired stream types. May take the following values: "latlng", "distance", "altitude"


Method clone()

The objects of this class are cloneable with this method.

Usage
mountainbiker_initializer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

https://developers.strava.com/playground

https://developers.strava.com/docs/reference/#api-SegmentEfforts-getEffortsBySegmentId

https://developers.strava.com/playground/#/SegmentEfforts/getEffortsBySegmentId

https://developers.strava.com/docs/reference/#api-SegmentEfforts-getSegmentEffortById

https://developers.strava.com/playground/#/SegmentEfforts/getSegmentEffortById

https://developers.strava.com/docs/reference/#api-Segments-getSegmentById

https://developers.strava.com/docs/reference/#api-Streams-getActivityStreams

https://developers.strava.com/docs/reference/#api-Streams-getSegmentEffortStreams

https://developers.strava.com/docs/reference/#api-Streams-getSegmentStreams

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## ------------------------------------------------
## Method `mountainbiker_initializer$new`
## ------------------------------------------------

## Not run: 
my_mb <- mountainbiker_initializer$new(
    my_app_name = "mycool_app"
    , my_client_id = 77777
    , my_client_secret = "a super secret string"
    , my_app_scope = "read,read_all,activity:read_all" #"public"
    , cache = FALSE
    )

## End(Not run)

longwei66/mountainbikeR documentation built on April 16, 2020, 6:23 p.m.