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 Next
Get
/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
Query parameters
schedule_id
string

Custom query schedule ID

Max length100
Exampleexample
sync_timeout
integer (int32)

Number of seconds to wait for the query to finish

Minimum0
Maximum3600
Default1800
Example0
api_links
array of string

Types of resource links to return. Not in use.

Item Max length100
ds_id
stringRequired

Data source ID

Max length100
ExampleGA
ds_accounts
string

List of data source account IDs to query

Max length100
Exampleexample
ds_segments
string

List of data source segment IDs to query

Max length100
Exampleexample
ds_user
string

Shorthand parameter to provide one value for ds_users

Max length100
Exampleexample
ds_users
string

List of data source usernames we should target

Max length100
Exampleexample
date_range_type
string

Type of date range the query should use

Max length50
Exampleyesterday
start_date
string

Fixed or relative query start date

Max length50
Exampleyesterday
end_date
string

Fixed or relative query end date

Max length50
Exampleyesterday
compare_type
string

Date range comparison type

Max length100
Exampleexample
compare_show
string

Display type for comparison values

Max length100
Exampleexample
compare_start_date
string

Fixed or relative start date for comparison date range

Max length50
Exampleyesterday
compare_end_date
string

Fixed or relative end date for comparison date range

Max length50
Exampleyesterday
fields
string

List of metric and dimension field IDs or field objects for the query

Max length100
Exampleexample
filter
string

Query filter string

Max length100
Exampleexample
settings
array of string

Additional settings for query in key-value pairs

Item Max length100
order_rows
string

List of fields and their sorting directions for the results

Max length100
Exampleexample
order_columns
string

Order policy for fields that are split by column

Max length100
Exampleexample
offset_start
integer (int32)

Starting row index for a paginated response. Defaults to 0.

Minimum0
Maximum1000000
Default0
Example0
offset_end
integer (int32)

Ending row index for a paginated response. Defaults to none for all the data.

Minimum0
Maximum1000000
Example0
max_columns
integer (int32)

Maximum number of columns the query should return when fields are split by column

Minimum0
Maximum2147483647
Default20
Example0
max_rows
integer (int32)

Maximum number of rows the query should return. Defaults to 1000.

Minimum0
Maximum2147483647
Default1000
Example0
cache_minutes
integer (int32)

Maximum allowed age of query results cache in minutes. Defaults to none for no explicit policy.

Minimum0
Maximum2147483647
Example0
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.