Documentation Index

Fetch the complete documentation index at: https://docs.supermetrics.com/llms.txt

Use this file to discover all available pages before exploring further.

Making requests

Prev Next

This page contains general information that you might need, when making requests to Supermetrics API.

Authentication

All endpoints that require authentication, accept either an api_key parameter, or an Authorization header. Read more about authentication.

Authorization: Bearer <your api key>

GET method

When the endpoint supports the GET method, you can choose to either use the traditional GET query parameters, as defined in RFC 1738, or a JSON string representing the query parameters, sent as the json parameter.

The documentation shows examples mostly with the latter approach.

Example:

GET /enterprise/v2/query/data/json?json={
  "api_key": "<api key>",
  "ds_id": "GAWA",
  "ds_accounts": "567890",
  "start_date": "2024-01-01",
  "end_date": "today",
  "fields": "date, impressions",
  "settings": {"no_headers": true},
  "filter": "impressions > 0 AND impressions < 100",
  "order_rows": "impressions desc,date desc",
  "max_rows": 1000
} HTTP/1.1
Host: api.supermetrics.com
Accept: */*
Accept-Encoding: gzip,deflate)

@fancy_anchor({"id": "post-method"})
#### POST method

When endpoint supports the _POST_ method, you either choose to send the request body 
as POST fields with content type _application/x-www-form-urlencoded_, or as a JSON 
string with content type _application/json_.

###### Example

@fancy_endpoint_example(
POST /enterprise/v2/query/data/json HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: api.supermetrics.com
Accept: */*
Accept-Encoding: gzip,deflate
Authorization: Bearer <your api key>

{
  "ds_id": "GAWA",
  "ds_accounts": "567890",
  "start_date": "2024-01-01",
  "end_date": "today",
  "fields": "date, impressions",
  "settings": {"no_headers": true},
  "filter": "impressions > 0 AND impressions < 100",
  "order_rows": "impressions desc,date desc",
  "max_rows": 1000
}

Pretty JSON

URL query parameter pretty can be used to pretty-print JSON responses in a human-readable format. Please note that this also increases the response size, and it should not be used for automated requests.

GET /enterprise/v2/query/data/json?json={...}&pretty=true

CORS support

Currently, we discourage making authenticated requests to Supermetrics API from browser applications, as they are likely to expose credentials to end users. Therefore, we do not accept cross-origin HTTP requests by default. Please contact us if this behaviour is vital to your integration.