Get data
Endpoint to run a data source query.
GET|POST
https://api.supermetrics.com/enterprise/v2/query/data/json
Please read more about how to make requests.
Parameters
-
api_key
string
Conditional. API key when not using an authorization header. See authentication for more.
-
schedule_id
string
Optional. Schedule ID for this query request. If not provided, one will be generated from the other query parameters. Only one schedule ID is allowed to be run at the same time. See async queries for more.
-
ds_id
string
Required. Target data source ID. See data sources for more.
-
ds_accounts
string | string[] | object
Conditional. List of data source accounts the query should target, or a filter for them. Not required for some data sources. Account selection can be limited by license restrictions. See accounts for more.
-
ds_segments
string | string[]
Optional. List of data source segment IDs the query should target.
-
ds_user
string
Optional. Shorthand parameter to provide one value for ds_users.
-
ds_users
string | string[]
Optional. List of data source login usernames we should limit to when searching for a suitable authentication for the query.
-
date_range_type
string
Conditional. Type of date range the query should use. Automatically set to custom if start_date and end_date are used. See date range type for more.
-
start_date
string
Conditional. Fixed or relative start date for your query. See date strings for more.
-
end_date
string
Conditional. Fixed or relative end date for your query. Future dates are allowed. See date strings for more.
-
compare_type
string
Conditional. Date range comparison type. Defaults to none. See date comparison for more.
-
compare_show
string
Optional. When compare_type is custom, display type for comparison values. Defaults to perc_change. See supported types.
-
compare_start_date
string
Conditional. When compare_type is custom, fixed or relative start date for your comparison date range. See date strings for more.
-
compare_end_date
string
Conditional. When compare_type is custom, fixed or relative end date for your comparison date range. See date strings for more.
-
fields
string | string[] | object[]
Conditional. Target data source fields the query should return. Not required for some data sources. Please check data source specific field documentation for accepted ID values. See fields for more.
-
settings
object
Conditional. Settings that should be applied when performing the query in key-value pairs. Some data sources require additional settings. See settings for more.
-
filter
string
Optional. Filter string that should be applied to the results before returning them. See filters for more.
-
order_columns
string
Optional. Order instruction for fields that are split by column. Defaults to met_desc. See order columns for more.
-
order_rows
string | string[]
Optional. List of order fields and sort directions for result rows. Limited to two items. See order rows for more.
-
max_columns
int
Optional. Maximum number of columns the query results should contain when fields that are split by column are used. Defaults to 20. Default and maximum values are subject to license restrictions.
-
max_rows
int
Optional. Maximum number of rows the query results should contain. Defaults to 100. Default and maximum values are subject to license restrictions.
-
offset_start
int
Optional. Starting row index for paginated response. Defaults to 0.
-
offset_end
int
Optional. Ending row index for paginated response. Defaults to none for all data.
-
cache_minutes
int
Optional. Maximum allowed age of query results cache in minutes. Defaults to dynamic caching based on query properties. When provided, license specific or default value range between 60 minutes and 1440 minutes is enforced. Please note that this parameter does not guarantee fully uncached results.
-
sync_timeout
int
Optional. Number of seconds the API should wait for query to finish before returning a response. Defaults to 1800 seconds (30 minutes). Default and maximum values are subject to license restrictions. See async queries for more.
Request
HTTP
Postman examples
GET /enterprise/v2/query/data/json?json={
"api_key": "<api key>",
"ds_id": "GA",
"ds_accounts": "567890",
"start_date": "2020-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
}
Response
Property | Type | Description | ||||
meta > request_id | string | API request ID | ||||
meta > schedule_id | string | Custom or generated schedule ID for the query | ||||
meta > status_code | string | Status code for the query | ||||
meta > query > start_date | string | Query start date in YYYY-MM-DD format, using query timezone. Defaults to null for queries without a date range. | ||||
meta > query > end_date | string | Query end date in YYYY-MM-DD format, using query timezone. Defaults to null for queries without a date range. | ||||
meta > query > ds_accounts | string[] | Data source account IDs used in the query | ||||
meta > query > ds_segments | string[] | Data source segment IDs used in the query | ||||
meta > query > fields | object[] | Requested fields in the order they appear in each data row. Ordering is best-effort and excludes dynamic columns from settings or from field values. | ||||
meta > query > fields > id | string | Field ID from the request | ||||
meta > query > fields > field_id | string | Field ID the API uses. Note that this value can be different than the requested field ID. | ||||
meta > query > fields > field_name | string | Field name | ||||
meta > query > fields > field_type | string | Field type
| ||||
meta > query > fields > field_split | string | Field split by type | ||||
meta > query > fields > data_type | string | Field data type. See field data types for more. | ||||
meta > query > fields > data_column | int | Field value position in each data row as 0-based index. Defaults to null for queries that split by column. | ||||
meta > query > fields > visible | bool | Whether data for this field is visible in the query result. Defaults to true. | ||||
meta > query > compare_type | string | Date range comparison type used in query. Defaults to null. | ||||
meta > query > compare_show | string | Display type for comparison values used in query. Defaults to null. | ||||
meta > query > compare_start_date | string | Fixed or relative start date for comparison date range. Defaults to null. | ||||
meta > query > compare_end_date | string | Fixed or relative end date for comparison date range. Defaults to null. | ||||
meta > query > settings > * | Settings used in query in key-value pairs | |||||
meta > query > cache_minutes | int | Requested maximum age of cache in minutes with minimum and maximum value enforced. Defaults to null. | ||||
meta > result > total_columns | int | Total amount of columns | ||||
meta > result > total_rows | int | Total amount of rows in data, including any header rows. | ||||
meta > result > run_seconds | float | Number of seconds it took for the query to run. This does not include queuing time. | ||||
meta > result > data_sampled | bool | If data source has provided sampled data for the results. Defaults to null when data source does not provide sampling information. | ||||
meta > result > cache_used | bool | If cached data was used to partially or to fully generate the query result. This value is best-effort only and does not guarantee real time data when false. | ||||
meta > result > cache_time | string | ISO 8601 datetime for the most recent cached data used to generate the query result. Defaults to null. | ||||
meta > paginate > prev | string | When paginated GET request, URL to previous offset, if available. Defaults to null. | ||||
meta > paginate > next | string | When paginated GET request, URL to next offset, if available. Defaults to null. | ||||
data | any[] | Query result rows |
HTTP 200 OK
{
"meta": {
"request_id": "tDcBg85cRzVZru7mRVQNkQ35tE4DdsPu",
"schedule_id": "...",
"status_code": "SUCCESS",
"query": {
"start_date": "2020-01-01",
"end_date": "2021-05-05",
"ds_accounts": "567890",
"ds_segments": "segment1",
"fields": [
{
"id": "date",
"field_id": "date",
"field_name": "Date",
"field_type": "dim",
"field_split": "row",
"data_type": "string.time.date",
"data_column": 0,
"visible": true
},
{
"id": "impressions",
"field_id": "impressions",
"field_name": "Impressions",
"field_type": "met",
"field_split": "row",
"data_type": "int.number.value",
"data_column": 1,
"visible": true
}
],
"compare_type": null,
"compare_show": null,
"compare_start_date": null,
"compare_end_date": null,
"settings": {
"no_headers": true,
"round_metrics_to": 4,
"no_json_keys": true
},
"cache_minutes": null
},
"result": {
"total_columns": 2,
"total_rows": 25678,
"run_seconds": 0.391,
"data_sampled": true,
"cache_used": true,
"cache_time": "2020-06-03T10:16:38+00:00"
},
"paginate": {
"prev": null,
"next": "https://..?json={... \"offset_start\":100, \"offset_end\":199}"
}
},
"data": [
[
"2020-01-20",
4384
],
[
"2020-01-21",
38518
]
]
}
Last updated 2022-11-15 UTC.