Request Your REST API Endpoints Using Batch API

request data from select Similarweb REST API endpoints through the Batch API

Overview:

You can now request data from select Similarweb REST API endpoints through the Batch API. This guide will help you connect your existing REST API use cases with the Batch API, enabling bulk data extraction, easier integration, and more efficient workflows.

What You'll Learn

  • How to translate REST API endpoints into Batch API report queries
  • Limitations and constraints to be aware of
  • Benefits of using the Batch API
  • Real examples and code snippets for different use cases (segments, websites, apps, etc.)

Benefits of Using Batch API

  • Get bulk results in a single CSV file
  • Automate delivery to:
    • AWS S3
    • Google Cloud Storage
    • Snowflake
  • Easily integrate into your data pipeline
  • Minimize the number of individual API calls
  • Schedule and track report generation

Limitations

  • Supported granularities: daily and monthly
  • Maximum of 100 domains / segment IDs per request

Code Examples

https://api.similarweb.com/batch/v4/request-report
curl --request POST \
     --url https://api.similarweb.com/batch/v4/request-report \
     --header 'accept: application/json' \
     --header 'api-key: ADD_YOUR_API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "delivery_information": {
    "delivery_method": "download_link",
    "response_format": "csv"
  },
  "report_query": {
    "tables": [
      {
        "vtable": "segments",
        "start_date": "2022-01",
        "end_date": "2022-01",
        "granularity": "monthly",
        "filters": {
          "countries": ["WW"],
          "segment_ids": ["001ccf03-1bb3-468d-a204-b52c10dcd138",
          "001ccf03-1bb3-468d-a204-b52c10ffff"]
        },
        "metrics": [
          "segment_total_visits",
          "segment_total_unique_visitors",
          "segment_total_pages_per_visit",
          "segment_total_visit_duration",
          "segment_total_page_views",
          "segment_total_bounce_rate",
          "segment_total_share"
        ]
      }
    ]
  }
}'