public interface WebhookAPI
API implementation of the Strava webhook events API
Webhook push subscriptions allow an application to subscribe to events that occur within Strava’s infrastructure. These events are pushed to a URL designated by the subscription. Webhooks allow an application to update athletes in real-time, and implement smarter data fetching.
Requests to the subscription endpoint are made using the client_id and client_secret of the application because requests are made on behalf of an application.
This API is only available to select applications. To request access please contact developers@strava.com
| Modifier and Type | Method and Description |
|---|---|
StravaEventSubscription |
createSubscription(Integer clientId,
String clientSecret,
StravaSubscriptionObjectType objectType,
StravaSubscriptionAspectType aspectType,
String callbackURL,
String verifyToken)
Creates a subscription to an allowed event
|
void |
createSubscription(Integer clientId,
String clientSecret,
StravaSubscriptionObjectType objectType,
StravaSubscriptionAspectType aspectType,
String callbackURL,
String verifyToken,
StravaAPICallback<StravaEventSubscription> callback)
Creates a subscription to an allowed event
|
StravaResponse |
deleteSubscription(Integer subscriptionId,
Integer clientId,
String clientSecret)
This request is used to unsubscribe from events.
|
void |
deleteSubscription(Integer subscriptionId,
Integer clientId,
String clientSecret,
StravaAPICallback<StravaResponse> callback)
This request is used to unsubscribe from events.
|
StravaEventSubscription[] |
listSubscriptions(Integer clientId,
String clientSecret)
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
void |
listSubscriptions(Integer clientId,
String clientSecret,
StravaAPICallback<StravaEventSubscription[]> callback)
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
@POST(value="/subscriptions") StravaEventSubscription createSubscription(@Query(value="client_id") Integer clientId, @Query(value="client_secret") String clientSecret, @Query(value="object_type_id") StravaSubscriptionObjectType objectType, @Query(value="aspect_type_id") StravaSubscriptionAspectType aspectType, @Query(value="callback_url") String callbackURL, @Query(value="verify_token") String verifyToken)
Creates a subscription to an allowed event
The application must have permission to make use of the webhook API. Access can be requested by contacting developers -at- strava.com.
The above request will send a GET request to callback url to verify existence
Your response to this GET request must contain the hub.challenge token, ie. 15f7d1a91c1f40f8a748fd134752feb3 and have a response code of 200.
On callback verification we respond to the original POST with the created subscription. If there is an error, a response containing the reason for failure will be returned.
When an event occurs that corresponds to a push subscription, a POST request will be made to the callback url defined in the subscription. The payload will contain the object and aspect types affected, as well as information about the object and its owner if applicable.
You should acknowledge the POST within a 2 second timeout–if you need to do more processing of the received information, you can do so in an asynchronous task.
Additional metadata about the object is not included, and an application must decide how or if it wants to fetch updated data. For example, you may decide only to fetch new data for specific users, or after a certain number of activities have been uploaded.
clientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registrationobjectType - The type of object being subscribed toaspectType - The aspect being subscribed tocallbackURL - (Max 255 characters) URL which Strava will callback with an HTTP GET to verify the existence of the webhook endpoint, then subsequently will POST to with subscribed eventsverifyToken - The token's value will be included in the GET callback request when verifying the endpoint@POST(value="/subscriptions")
void createSubscription(@Query(value="client_id")
Integer clientId,
@Query(value="client_secret")
String clientSecret,
@Query(value="object_type_id")
StravaSubscriptionObjectType objectType,
@Query(value="aspect_type_id")
StravaSubscriptionAspectType aspectType,
@Query(value="callback_url")
String callbackURL,
@Query(value="verify_token")
String verifyToken,
StravaAPICallback<StravaEventSubscription> callback)
Creates a subscription to an allowed event
The application must have permission to make use of the webhook API. Access can be requested by contacting developers -at- strava.com.
The above request will send a GET request to callback url to verify existence
Your response to this GET request must contain the hub.challenge token, ie. 15f7d1a91c1f40f8a748fd134752feb3 and have a response code of 200.
On callback verification we respond to the original POST with the created subscription. If there is an error, a response containing the reason for failure will be returned.
When an event occurs that corresponds to a push subscription, a POST request will be made to the callback url defined in the subscription. The payload will contain the object and aspect types affected, as well as information about the object and its owner if applicable.
You should acknowledge the POST within a 2 second timeout–if you need to do more processing of the received information, you can do so in an asynchronous task.
Additional metadata about the object is not included, and an application must decide how or if it wants to fetch updated data. For example, you may decide only to fetch new data for specific users, or after a certain number of activities have been uploaded.
clientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registrationobjectType - The type of object being subscribed toaspectType - The aspect being subscribed tocallbackURL - (Max 255 characters) URL which Strava will callback with an HTTP GET to verify the existence of the webhook endpoint, then subsequently will POST to with subscribed eventsverifyToken - The token's value will be included in the GET callback request when verifying the endpointcallback - Callback for execution when the asynchronous call completes@DELETE(value="/subscriptions/{id}")
StravaResponse deleteSubscription(@Path(value="id")
Integer subscriptionId,
@Query(value="client_id")
Integer clientId,
@Query(value="client_secret")
String clientSecret)
This request is used to unsubscribe from events.
If the delete is successful, a 204 will be returned. Otherwise, an error will be returned containing the reason for a failure.
subscriptionId - The id of the subscription to be deletedclientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registration@DELETE(value="/subscriptions/{id}")
void deleteSubscription(@Path(value="id")
Integer subscriptionId,
@Query(value="client_id")
Integer clientId,
@Query(value="client_secret")
String clientSecret,
StravaAPICallback<StravaResponse> callback)
This request is used to unsubscribe from events.
If the delete is successful, a 204 will be returned. Otherwise, an error will be returned containing the reason for a failure.
subscriptionId - The id of the subscription to be deletedclientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registrationcallback - Callback for execution when the asynchronous call completes@GET(value="/subscriptions") StravaEventSubscription[] listSubscriptions(@Query(value="client_id") Integer clientId, @Query(value="client_secret") String clientSecret)
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
clientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registration@GET(value="/subscriptions")
void listSubscriptions(@Query(value="client_id")
Integer clientId,
@Query(value="client_secret")
String clientSecret,
StravaAPICallback<StravaEventSubscription[]> callback)
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
clientId - Application's id, as obtained during registration with StravaclientSecret - Application's secret, as obtained during Strava registrationcallback - Callback for execution when the asynchronous call completesCopyright © 2016 Dan Shannon. All rights reserved.