public interface WebhookService extends StravaService
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(StravaEventSubscription subscription,
String verifyToken)
Creates a subscription to an allowed event
|
CompletableFuture<StravaEventSubscription> |
createSubscriptionAsync(StravaEventSubscription subscription,
String verifyToken)
Creates a subscription to an allowed event
|
void |
deleteSubscription(Integer id)
This request is used to unsubscribe from events.
|
CompletableFuture<Void> |
deleteSubscriptionAsync(Integer id)
This request is used to unsubscribe from events.
|
List<StravaEventSubscription> |
listSubscriptions()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
CompletableFuture<List<StravaEventSubscription>> |
listSubscriptionsAsync()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
|
clearCacheStravaEventSubscription createSubscription(StravaEventSubscription subscription, 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.
subscription - The subscription to create on StravaverifyToken - The verification token Strava should use when validating your endpointCompletableFuture<StravaEventSubscription> createSubscriptionAsync(StravaEventSubscription subscription, 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 Strava responds 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.
subscription - The subscription to create on StravaverifyToken - The verification token Strava should use when validating your endpointvoid deleteSubscription(Integer id)
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.
id - Unique identifier of the subscription to be deletedCompletableFuture<Void> deleteSubscriptionAsync(Integer id)
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.
id - Unique identifier of the subscription to be deletedList<StravaEventSubscription> listSubscriptions()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
CompletableFuture<List<StravaEventSubscription>> listSubscriptionsAsync()
This request is used to retrieve the summary representations of the subscriptions in place for the current application.
Copyright © 2016 Dan Shannon. All rights reserved.