This is a barebones and hardly complete Go client for the Strava API v3. It was written mainly as an exercise to play around with Go and therefore only supports a small set of operations and includes a subset of fields on model objects.
The Strava API requires authentication and uses OAuth. The OAuth flow is not implemented in this API, but access can still be gained using a developer access token which can be easily obtained by any Strava user. The Strava API page has details. Don't share your access token.
A sample command line app is included that can list activities or segments. Output is in CSV (though custom delimiters are supported with with --delimiter
).
go install github.com/alecholmes/strava
STRAVA_ACCESS_TOKEN=your_private_token
$GOPATH/bin/strava --accessToken $STRAVA_ACCESS_TOKEN
Or, to get activities after a given id:
STRAVA_ACCESS_TOKEN=your_private_token
$GOPATH/bin/strava --accessToken $STRAVA_ACCESS_TOKEN --afterId 212147000
All segments for activities can be printed instead of activity summaries. This is done by including the --segment
flag.
STRAVA_ACCESS_TOKEN=your_private_token
$GOPATH/bin/strava --accessToken $STRAVA_ACCESS_TOKEN --afterId 212147000 --segments
All times for a specific segment, and the date of the effort:
STRAVA_ACCESS_TOKEN=your_private_token
# Dump everything into all_segments to allow reuse, since fetching is relatively slow
$GOPATH/bin/strava --accessToken $STRAVA_ACCESS_TOKEN --delimiter $'\t' --segments > all_segments
grep "\tHawk Hill\t" all_segments | cut -d $'\t' -f 8,10
- GetActivity blows up if a ride is private