Strava client RestTemplate
Strava API v3
- API version: 3.0.0
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.
Automatically generated by the Swagger Codegen
Requirements
Building the API client library requires:
- Java 1.7+
- Maven/Gradle
Installation
To install the API client library to your local Maven repository, simply execute:
mvn clean install
Maven users
Add this dependency to your project's POM:
<dependency>
<groupId>io.github.jfermat</groupId>
<artifactId>strava-api-client-resttemplate</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
Gradle users
Add this dependency to your project's build file:
compile "io.github.jfermat:strava-api-client-resttemplate:1.0.2"
Getting Started
Please follow the installation instruction and execute the following Java code:
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
String name = "name_example"; // String |
String type = "type_example"; // String |
OffsetDateTime startDateLocal = new OffsetDateTime(); // OffsetDateTime |
Integer elapsedTime = 56; // Integer |
String description = "description_example"; // String |
Float distance = 3.4F; // Float |
Integer trainer = 56; // Integer |
Integer commute = 56; // Integer |
try {
DetailedActivity result = apiInstance.createActivity(name, type, startDateLocal, elapsedTime, description, distance, trainer, commute);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#createActivity");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
Boolean includeAllEfforts = true; // Boolean | To include all segments efforts.
try {
DetailedActivity result = apiInstance.getActivityById(id, includeAllEfforts);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getActivityById");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
Integer page = 56; // Integer | Page number. Defaults to 1.
Integer perPage = 30; // Integer | Number of items per page. Defaults to 30.
try {
List<Comment> result = apiInstance.getCommentsByActivityId(id, page, perPage);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getCommentsByActivityId");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
Integer page = 56; // Integer | Page number. Defaults to 1.
Integer perPage = 30; // Integer | Number of items per page. Defaults to 30.
try {
List<SummaryAthlete> result = apiInstance.getKudoersByActivityId(id, page, perPage);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getKudoersByActivityId");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
try {
List<Lap> result = apiInstance.getLapsByActivityId(id);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getLapsByActivityId");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Integer before = 56; // Integer | An epoch timestamp to use for filtering activities that have taken place before a certain time.
Integer after = 56; // Integer | An epoch timestamp to use for filtering activities that have taken place after a certain time.
Integer page = 56; // Integer | Page number. Defaults to 1.
Integer perPage = 30; // Integer | Number of items per page. Defaults to 30.
try {
List<SummaryActivity> result = apiInstance.getLoggedInAthleteActivities(before, after, page, perPage);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getLoggedInAthleteActivities");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
try {
List<ActivityZone> result = apiInstance.getZonesByActivityId(id);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#getZonesByActivityId");
e.printStackTrace();
}
}
}
import io.github.jfermat.strava.invoker.*;
import io.github.jfermat.strava.invoker.auth.*;
import io.github.jfermat.strava.model.*;
import io.github.jfermat.strava.api.ActivitiesApi;
import java.io.File;
import java.util.*;
public class ActivitiesApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: strava_oauth
OAuth strava_oauth = (OAuth) defaultClient.getAuthentication("strava_oauth");
strava_oauth.setAccessToken("YOUR ACCESS TOKEN");
ActivitiesApi apiInstance = new ActivitiesApi();
Long id = 789L; // Long | The identifier of the activity.
UpdatableActivity body = new UpdatableActivity(); // UpdatableActivity |
try {
DetailedActivity result = apiInstance.updateActivityById(id, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ActivitiesApi#updateActivityById");
e.printStackTrace();
}
}
}
Documentation for API Endpoints
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 |
RunningRacesApi | getRunningRaceById | GET /running_races/{id} | Get Running Race |
RunningRacesApi | getRunningRaces | GET /running_races | List Running Races |
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 |
Documentation for Models
- ActivityStats
- ActivityTotal
- ActivityType
- ActivityZone
- AltitudeStream
- BaseStream
- Body
- Body1
- Body2
- CadenceStream
- Comment
- DetailedActivity
- DetailedAthlete
- DetailedClub
- DetailedGear
- DetailedSegment
- DetailedSegmentEffort
- DistanceStream
- Error
- ExplorerResponse
- ExplorerSegment
- Fault
- HeartRateZoneRanges
- HeartrateStream
- Lap
- LatLng
- LatLngStream
- MetaActivity
- MetaAthlete
- MetaClub
- MovingStream
- PhotosSummary
- PhotosSummaryPrimary
- PolylineMap
- PowerStream
- PowerZoneRanges
- Route
- RunningRace
- SmoothGradeStream
- SmoothVelocityStream
- Split
- StreamSet
- SummaryActivity
- SummaryAthlete
- SummaryClub
- SummaryGear
- SummaryPRSegmentEffort
- SummarySegment
- SummarySegmentEffort
- TemperatureStream
- TimeStream
- TimedZoneDistribution
- TimedZoneRange
- UpdatableActivity
- Upload
- ZoneRange
- ZoneRanges
- Zones
Documentation for Authorization
Authentication schemes defined for the API:
strava_oauth
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://www.strava.com/api/v3/oauth/authorize
- Scopes:
- :
Recommendation
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.