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.

Query data

Prev
Post
/query/data/{context_type}

Execute a query to retrieve data from a specified data source

Security
HTTP
Type bearer

API key authentication. Create API keys in the Supermetrics Hub and send them in the Authorization header: Authorization: Bearer <your-api-key>

Path parameters
context_type
stringRequired

Output format to use for query results

Valid values[ "json", "keyjson", "ndjson", "parquet", "powerbi", "qlik", "tableau", "csv", "tsv", "pbijson", "postman" ]
Examplejson
Body parameters

Query parameters for data retrieval

{
  "ds_id": "GAWA",
  "ds_accounts": "account123",
  "start_date": "yesterday",
  "end_date": "yesterday",
  "fields": "date,sessions"
}
object
schedule_id
string

Schedule ID for this query request. If not provided, one will be generated from other query parameters

Max length50
Pattern^[A-Za-z0-9_-]+$
Examplemy_query_123
ds_id
string Required

Target data source ID

Max length50
Pattern^[A-Za-z0-9_-]+$
ExampleGAWA
ds_accounts
string

List of data source accounts the query should target, or a filter for them

Max length100
Exampleaccount123,account456
ds_segments
string

List of data source segment IDs the query should target

Max length100
Examplesegment1,segment2
ds_user
string

Shorthand parameter to provide one value for ds_users

Max length255
Exampleuser@example.com
ds_users
string

List of data source login usernames to limit when searching for suitable authentication

Max length100
date_range_type
string

Type of date range the query should use

Max length50
start_date
string

Fixed or relative start date for your query

Max length100
Exampleyesterday
end_date
string

Fixed or relative end date for your query

Max length100
Exampleyesterday
compare_type
string

Date range comparison type. Defaults to none

Max length50
compare_show
string

When compare_type is custom, display type for comparison values

Max length50
compare_start_date
string

When compare_type is custom, fixed or relative start date for comparison

Max length100
compare_end_date
string

When compare_type is custom, fixed or relative end date for comparison

Max length100
fields
string

Target data source fields the query should return

Max length100
settings
Array of string

Settings that should be applied when performing the query

Max items1000
string
Max length255
filter
string

Filter string that should be applied to the results

Max length5000
order_columns
string

Order instruction for fields that are split by column

Max length1000
order_rows
string

List of order fields and sort directions for result rows

Max length100
max_columns
integer (int32)

Maximum number of columns the query results should contain

Minimum1
Maximum1000
max_rows
integer (int32)

Maximum number of rows the query results should contain

Minimum1
Maximum1000000
offset_start
integer (int32)

Starting row index for paginated response

Minimum0
Maximum1000000
offset_end
integer (int32)

Ending row index for paginated response

Minimum0
Maximum1000000
cache_minutes
integer (int32)

Maximum allowed age of query results cache in minutes

Minimum0
Maximum10080
sync_timeout
integer (int32)

Number of seconds the API should wait for query to finish

Minimum0
Maximum3600
api_links
Array of string

Types of resource links to return. Not in use.

Max items1000
string
Max length100
Responses
200

Query executed successfully

Expand All
object
meta
object
request_id
string

API request ID

Max length50
Pattern^[A-Za-z0-9_-]+$
schedule_id
string

Custom or generated schedule ID for the query

Max length50
Pattern^[A-Za-z0-9_-]+$
status_code
string

Status code for the query

Max length20
query
object
start_date
string

Query start date in YYYY-MM-DD format

Max length10
Pattern^\d{4}-\d{2}-\d{2}$
end_date
string

Query end date in YYYY-MM-DD format

Max length10
Pattern^\d{4}-\d{2}-\d{2}$
ds_accounts
Array of string

Data source account IDs used in the query

Max items100
string
Max length50
Pattern^[A-Za-z0-9_-]+$
ds_segments
Array of string

Data source segment IDs used in the query

Max items1000
string
Max length50
Pattern^[A-Za-z0-9_-]+$
fields
Array of object
Max items100
object
id
string

Field ID from the request

Max length100
Pattern^[A-Za-z0-9_-]+$
field_id
string

Field ID the API uses

Max length100
Pattern^[A-Za-z0-9_-]+$
field_name
string

Field name

Max length255
field_type
string

Field type

Max length10
field_split
string

Field split by type

Max length50
data_type
string

Field data type

Max length50
data_column
integer (int32)

Field value position in each data row

Minimum0
Maximum1000
visible
boolean

Whether data for this field is visible

compare_type
string

Date range comparison type used

Max length50
compare_show
string

Display type for comparison values

Max length50
compare_start_date
string

Start date for comparison date range

Max length10
Pattern^\d{4}-\d{2}-\d{2}$
compare_end_date
string

End date for comparison date range

Max length10
Pattern^\d{4}-\d{2}-\d{2}$
settings
object

Settings used in query

cache_minutes
integer (int32)

Requested maximum age of cache in minutes

Minimum0
Maximum10080
result
object
total_columns
integer (int32)

Total amount of columns

Minimum0
Maximum1000
total_rows
integer (int64)

Total amount of rows in data

Minimum0
Maximum100000000
run_seconds
number (float)

Number of seconds it took for the query to run

Minimum0
Maximum7200
data_sampled
boolean

If data source has provided sampled data

cache_used
boolean

If cached data was used

cache_time
string (date-time)

ISO 8601 datetime for the most recent cached data

Max length30
paginate
object
prev
string (uri)

URL to previous offset

Max length500
next
string (uri)

URL to next offset

Max length500
data
Array of array

Query result rows

Max items1000000
Array of string
Max items1000
string
Max length10000
400

Bad request - invalid parameters

Headers
X-RateLimit-Limit
integer
Request limit per hour
Minimum1
Maximum10000
Example5000
X-RateLimit-Remaining
integer
Remaining requests in current window
Minimum0
Maximum10000
Example4999
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "BAD_REQUEST",
    "message": "The request was invalid."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.
401

Unauthorized

Headers
WWW-Authenticate
string
Bearer token required
Max length255
Pattern^Bearer.*
X-RateLimit-Limit
integer
Request limit per hour
Minimum1
Maximum10000
Example5000
X-RateLimit-Remaining
integer
Remaining requests in current window
Minimum0
Maximum10000
Example4999
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Authentication is required."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.
403

Permission denied

Headers
X-RateLimit-Limit
integer
Request limit per hour
Minimum1
Maximum10000
Example5000
X-RateLimit-Remaining
integer
Remaining requests in current window
Minimum0
Maximum10000
Example4999
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "PERMISSION_ERROR",
    "message": "You do not have permission to perform this action."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.
422

Unprocessable Entity - validation failed for the request parameters

Headers
X-RateLimit-Limit
integer
Request limit per hour
Minimum1
Maximum10000
Example5000
X-RateLimit-Remaining
integer
Remaining requests in current window
Minimum0
Maximum10000
Example4999
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "UNPROCESSABLE_ENTITY",
    "message": "Validation failed for the request parameters."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.
429

Too Many Requests

Headers
X-RateLimit-Limit
integer
Request limit per hour
Minimum1
Maximum10000
Example5000
X-RateLimit-Remaining
integer
Remaining requests in current window
Minimum0
Maximum10000
Example4999
Retry-After
integer
Seconds until rate limit resets
Minimum1
Maximum86400
Example3600
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "TOO_MANY_REQUESTS",
    "message": "Rate limit exceeded. Retry later."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.
500

Internal server error

Headers
Access-Control-Allow-Origin
string
CORS header
Valid values[ "*" ]
Max length255
Example*
{
  "meta": {
    "request_id": "BXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN"
  },
  "error": {
    "code": "INTERNAL_SERVER_ERROR",
    "message": "An unexpected error occurred."
  }
}
Expand All
object

Standard envelope returned by all error (4xx/5xx) responses.

meta
object (Meta)

Metadata included in every API response.

request_id
string

Unique identifier for the request, for tracking and debugging.

Min length8
Max length64
Pattern^[A-Za-z0-9_-]+$
ExampleBXaEFVtjc7TXaJxgZhmFgSUD9edqq_CN
error
object (Error)

Machine- and human-readable detail for a failed request.

code
string

Stable, screaming-snake-case identifier for the error condition. Clients should branch on this, not on message. Common values include BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, CONFLICT_ERROR, PERMISSION_ERROR, UNPROCESSABLE_ENTITY, UNPROCESSABLE_CONTENT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR, DUPLICATION_FAILED, SERVICE_UNAVAILABLE; domains may define additional codes.

Max length100
Pattern^[A-Z][A-Z0-9_]*$
ExampleBAD_REQUEST
message
string

Short, human-readable summary of the error.

Max length255
Pattern^.+$
ExampleThe request was invalid.
description
string

Optional longer explanation specific to this occurrence.

Max length2048
ExampleThe field 'display_name' must not be empty.