Webhook Endpoints
Webhooks in Similarweb: Real-Time Notifications for Your Data Needs
Webhooks let you stay informed about events and updates from the Similarweb API in real time. By subscribing to webhook notifications, your applications and systems are always up to date with the latest insights without the need for constant polling.
Introduction to webhooks
Webhooks are a mechanism for receiving real-time notifications when specific events occur within the Similarweb API. Instead of repeatedly querying the API for updates, webhooks let Similarweb send POST requests directly to your endpoints as soon as an event of interest takes place.
- Real-time updates — Know immediately when your report is available to download.
- Automations — Build automations around your reporting and dashboards.
Setting up webhooks
1
Configure your endpoint
Create a URL in your application that can receive HTTP POST requests from Similarweb.
2
Validate using the webhook test endpoint
Use the Check Webhook endpoint to validate that your webhook integration is successful.
3
Use your validated URL with report endpoints
Once validated, include the webhook_url field in your report request body.
Test webhook request
POST https://api.similarweb.com/v3/batch/webhooks/test
{
"webhook_url": "http://slack.com/example_url/abc"
}
import requests
url = "https://api.similarweb.com/v3/batch/webhooks/test"
payload = "{\n\"webhook_url\": \"http://slack.com/example_url/abc\"\n}"
headers = {
'api-key': '{{api_key}}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
The notification performs a POST with the following body:
{
"event_type": "test_webhook_endpoint",
"payload": "Webhook Integration with Similarweb is successful!"
}
Confirm in your internal system that you’ve received the test_webhook_endpoint event — it should be invoked immediately.
Timeout occurs after 5 seconds; a timeout will cause failure.
Use the validated URL with report endpoints
POST https://api.similarweb.com/batch/v4/request-report
{
"webhook_url": "http://slack.com/example_url/abc",
"domains": ["amazon.com"],
"category_ids": [2335752011],
"metrics": [
"category_sales_performance_product_views",
"category_sales_performance_units_sold",
"category_sales_performance_revenue",
"category_sales_performance_cvr"
],
"start_date": "2021-09",
"end_date": "2021-11",
"granularity": "monthly",
"response_format": "csv"
}
When the report status changes, the webhook is triggered.
Possible Report Statuses: "processing", "complete", or "internal_error".
On this page
- Webhook Endpoints