The Swagger Playground is the easiest way to familiarize yourself with the Strava API by submitting HTTP requests and observing the responses before you write any client code. It will show what a response will look like with different endpoints depending on the authorization scope you receive from your athletes. To use the Playground, go to https://www.strava.com/settings/api and change your “Authorization Callback Domain” to developers.strava.com. Please note, we only support Swagger 2.0. There is a known issue where you can only select one scope at a time. For more information, please check the section “client code” at https://developers.strava.com/docs.
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 3.0.0
- Package version: 1.0.0
- Build date: 2024-01-07T23:52:02.036519012+01:00[Europe/Copenhagen]
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import strava "github.com/rasher/strava.go"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), strava.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), strava.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), strava.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), strava.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to https://www.strava.com/api/v3
Class | Method | HTTP request | Description |
---|---|---|---|
ActivitiesApi | CreateActivity | Post /activities | Create an Activity |
ActivitiesApi | GetActivityById | Get /activities/{id} | Get Activity |
ActivitiesApi | GetCommentsByActivityId | Get /activities/{id}/comments | List Activity Comments |
ActivitiesApi | GetKudoersByActivityId | Get /activities/{id}/kudos | List Activity Kudoers |
ActivitiesApi | GetLapsByActivityId | Get /activities/{id}/laps | List Activity Laps |
ActivitiesApi | GetLoggedInAthleteActivities | Get /athlete/activities | List Athlete Activities |
ActivitiesApi | GetZonesByActivityId | Get /activities/{id}/zones | Get Activity Zones |
ActivitiesApi | UpdateActivityById | Put /activities/{id} | Update Activity |
AthletesApi | GetLoggedInAthlete | Get /athlete | Get Authenticated Athlete |
AthletesApi | GetLoggedInAthleteZones | Get /athlete/zones | Get Zones |
AthletesApi | GetStats | Get /athletes/{id}/stats | Get Athlete Stats |
AthletesApi | UpdateLoggedInAthlete | Put /athlete | Update Athlete |
ClubsApi | GetClubActivitiesById | Get /clubs/{id}/activities | List Club Activities |
ClubsApi | GetClubAdminsById | Get /clubs/{id}/admins | List Club Administrators |
ClubsApi | GetClubById | Get /clubs/{id} | Get Club |
ClubsApi | GetClubMembersById | Get /clubs/{id}/members | List Club Members |
ClubsApi | GetLoggedInAthleteClubs | Get /athlete/clubs | List Athlete Clubs |
GearsApi | GetGearById | Get /gear/{id} | Get Equipment |
RoutesApi | GetRouteAsGPX | Get /routes/{id}/export_gpx | Export Route GPX |
RoutesApi | GetRouteAsTCX | Get /routes/{id}/export_tcx | Export Route TCX |
RoutesApi | GetRouteById | Get /routes/{id} | Get Route |
RoutesApi | GetRoutesByAthleteId | Get /athletes/{id}/routes | List Athlete Routes |
SegmentEffortsApi | GetEffortsBySegmentId | Get /segment_efforts | List Segment Efforts |
SegmentEffortsApi | GetSegmentEffortById | Get /segment_efforts/{id} | Get Segment Effort |
SegmentsApi | ExploreSegments | Get /segments/explore | Explore segments |
SegmentsApi | GetLoggedInAthleteStarredSegments | Get /segments/starred | List Starred Segments |
SegmentsApi | GetSegmentById | Get /segments/{id} | Get Segment |
SegmentsApi | StarSegment | Put /segments/{id}/starred | Star Segment |
StreamsApi | GetActivityStreams | Get /activities/{id}/streams | Get Activity Streams |
StreamsApi | GetRouteStreams | Get /routes/{id}/streams | Get Route Streams |
StreamsApi | GetSegmentEffortStreams | Get /segment_efforts/{id}/streams | Get Segment Effort Streams |
StreamsApi | GetSegmentStreams | Get /segments/{id}/streams | Get Segment Streams |
UploadsApi | CreateUpload | Post /uploads | Upload Activity |
UploadsApi | GetUploadById | Get /uploads/{uploadId} | Get Upload |
- ActivityStats
- ActivityTotal
- ActivityType
- ActivityZone
- AltitudeStream
- AltitudeStreamAllOf
- BaseStream
- CadenceStream
- CadenceStreamAllOf
- ClubActivity
- ClubAthlete
- Comment
- DetailedActivity
- DetailedActivityAllOf
- DetailedAthlete
- DetailedAthleteAllOf
- DetailedClub
- DetailedClubAllOf
- DetailedGear
- DetailedGearAllOf
- DetailedSegment
- DetailedSegmentAllOf
- DetailedSegmentEffort
- DetailedSegmentEffortAllOf
- DistanceStream
- DistanceStreamAllOf
- Error
- ExplorerResponse
- ExplorerSegment
- Fault
- HeartRateZoneRanges
- HeartrateStream
- HeartrateStreamAllOf
- Lap
- LatLngStream
- LatLngStreamAllOf
- MetaActivity
- MetaAthlete
- MetaClub
- MovingStream
- MovingStreamAllOf
- PhotosSummary
- PhotosSummaryPrimary
- PolylineMap
- PowerStream
- PowerStreamAllOf
- PowerZoneRanges
- Route
- SmoothGradeStream
- SmoothGradeStreamAllOf
- SmoothVelocityStream
- SmoothVelocityStreamAllOf
- Split
- SportType
- StreamSet
- SummaryActivity
- SummaryActivityAllOf
- SummaryAthlete
- SummaryAthleteAllOf
- SummaryClub
- SummaryClubAllOf
- SummaryGear
- SummaryPRSegmentEffort
- SummarySegment
- SummarySegmentEffort
- TemperatureStream
- TemperatureStreamAllOf
- TimeStream
- TimeStreamAllOf
- TimedZoneRange
- TimedZoneRangeAllOf
- UpdatableActivity
- Upload
- ZoneRange
- Zones
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://www.strava.com/api/v3/oauth/authorize
- Scopes:
- read: Read public segments, public routes, public profile data, public posts, public events, club feeds, and leaderboards
- read_all: Read private routes, private segments, and private events for the user
- profile:read_all: Read all profile information even if the user has set their profile visibility to Followers or Only You
- profile:write: Update the user's weight and Functional Threshold Power (FTP), and access to star or unstar segments on their behalf
- activity:read: Read the user's activity data for activities that are visible to Everyone and Followers, excluding privacy zone data
- activity:read_all: The same access as activity:read, plus privacy zone data and access to read the user's activities with visibility set to Only You
- activity:write: Access to create manual activities and uploads, and access to edit any activities that are visible to the app, based on activity read access level
Example
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
import "golang.org/x/oauth2"
/* Perform OAuth2 round trip request and obtain a token */
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime