Data Notifications via Webhooks
Subscribe to event notifications via the API to be instantly updated when new daily and monthly website data is released.
Webhooks in Similarweb: Real-Time Notifications for Your Data Needs
Webhooks in Similarweb offer a robust solution for receiving real-time notifications about data updates. This guide details the setup and management of webhooks in your Similarweb API integration, ensuring that your systems remain synchronized with the latest data releases without needing constant API polling.
Why Use Webhooks?
Webhooks provide an efficient method to receive notifications when new daily or monthly website data is available. Instead of periodically polling the API to check for data updates, you can set up webhooks that prompt Similarweb to send real-time notifications directly to a specified URL.
Webhook Events
You can subscribe to two types of events:
Daily
: a specific date's data is released within 72 hours after the end of that date (EST time zone). For example, data for the 14th will typically be published by the end of the day on the 17th (EST).
Monthly
: monthly data is released by the 10th of the following month. In most cases, it is released sooner.
The URL in the subscription should be a POST endpoint, and it will be triggered with the following body:
{
"subscription_id": "1hb87575e7-b56e-45e4-9d3534569bcb9c90",
"latest_data_available": "10/19/2023",
"webhook_event_type": "Daily",
"created": 1634629790,
"text": "Hi! New daily data is available. The latest day is 19/10/2023"
}
Webhook Object Attributes
subscription_id
[String] - The unique ID per account and subscription
latest_data_available
[String MM/DD/YYYY] - The most recent date for which data is available.
webhook_event_type
[String] - Can be either “Daily” or “Monthly”
created
[Int] - Time at which the object was created. Measured in seconds since the Unix epoch.
text
[String] - a descriptive element, which includes the most recent date of available data.
Managing Webhooks
Subscribing to a Webhook
For details on subscribing to a webhook, please see the Subscribe documentation.
Viewing Your Webhook Subscriptions
To view existing subscriptions, issue a GET request to:
GET https://api.similarweb.com/v1/webhooks/subscriptions?api_key={similarweb_api_key}
Example response:
{
"subscription_id": "brdfh9fe-0cg8-42fg-afge-56dfhg258d0",
"webhook_event_type": "Monthly",
"url": "https://hook.listener.com",
"last_update_date": "2021-10-15"
}
Unsubscribing from a Webhook
For details on unsubscribing from a webhook, please refer to the Unsubscribe documentation.
Authentication
To authenticate the source of a webhook notification, use the 'X-sw-authorization' token received in the header of the notification. This token helps ensure that notifications are from Similarweb and expires five minutes after issue.
curl --location -g --request POST '<https://api.similarweb.com/v1/webhooks/authorize?api_key={{similarweb_api_key}}'>
--header 'X-sw-authorization: {{authrization-signature}}'
HEADER
X-sw-authorization
{{authrization-signature}}
PARAMS
api-key
{{similarweb_api_key}} - Your Similarweb API key - Insert without {{ }} brackets
BODY
Should contain the same body that was sent when your webhook was triggered.
{
"subscription_id": "1hb87575e7-b56e-45e4-9d3534569bcb9c90",
"latest_data_available": "10/19/2023",
"webhook_event_type": "Daily",
"created": 1634629790
"text": "Hi! New daily data is available. The latest day is 19/10/2023"
}
Response Index
200
: Ok → Authentication succeeded, your webhook was triggered by Similarweb.
406
: Not Acceptable → Authentication failed, your webhook was not triggered by Similarweb.
424
: Failed Dependency → Authentication failed. Your webhook was triggered by Similarweb but the authorization token expired. This means that more than 5 min has passed since the trigger.
FAQs
Q: Does this service include App data?
No. Currently, these webhooks are limited to website data only.
Q: Will I be charged data credits for subscribing?
No, there are no data credit charges for using webhooks.
Q: Is there a timeout limit for webhook responses?
Yes, each webhook requires a response within 100 seconds. If a response is not received within this timeframe, the update may not be processed.
Need help?
If you have any questions or would like to speak to one of our dedicated technical API specialists, please reach out to your Account Manager.
Updated 4 months ago