Before invoking the Arcadia Data API, you must familiarize yourself with the syntax of the request payload.
This article includes the following sections:
{
"version":version_number,
"type":"SQL",
"limit":number_of_rows,
"dimensions":
[{
"type":"SIMPLE/SEGMENT",
"expr":"[dimension_1] as 'dimension_value_1',
"expr":"[dimension_2] as 'dimension_value_2',
"expr":"[dimension_n] as 'dimension_value_n',
"order": {"asc": True/False, "pri": order_sequence}
}],
"aggregates":
[{
"expr":["aggregate_1] as 'aggregate_value_1',
"expr":["aggregate_2] as 'aggregate_value_2',
"expr":["aggregate_n] as 'aggregate_value_n',
}],
"filters":
[
"[filter_1] in ('filter_value_1')",
"[filter_2] in ('filter_value_2')",
"[filter_n] in ('filter_value_n')"
],
"having":
[
"[aggregate_1]) > aggregate_value_1"
],
"dataset_id":dataset_id_number
}
The request payload parameters are defined as follows:
List of zero or more dimensions. Specifying no dimensions or aggregates returns all columns from the dataset. Each item in the list specifies a dimension that is requested, and has the following structure of key value pairs:
Either SIMPLE
or
SEGMENT
. Default is
SIMPLE
. Use field descriptions
for expr
and
order
with
SIMPLE
type.
Either a dimension or an aggregate with the following format: "expr":"[dimension_1] as 'dimension_value'. This is a mandatory parameter.
Maximum of two key value pairs: ‘asc’, which is set to True or False. This indicates the order and priority, which is set to an integer and specifies the sequence in which the order is to be applied.
List of zero or more aggregates. Specifying no aggregates returns all columns from the dataset. Each item in the list specifies an aggregate that is requested, and has the following structure of key value pairs:
Specifies one aggregate with the following format:
[{"expr":["aggregate_1] as 'aggregate_value_1'}]
HAVING
clause. Therefore, this
parameter has an aggregation comparison. This is an
optional parameter.Here is an example of a Data API request payload that interfaces with the Cereals dataset, which ships as a sample with most Arcadia Enterprise installations.
{
"version":1,
"type":"SQL",
"limit":100,
"dimensions":
[{
"type":"SIMPLE",
"expr":"[manufacturer] as 'manufacturer'",
"order": {"asc":False, "pri":1
}],
"aggregates":
[{
"expr":["avg([fat_grams]) as 'avg(fat_grams)'",
"expr":["sum(1) as 'Record Count'"
}],
"filters":
[
["[cold_or_hot] in ('C')"]
],
"having":
[
["[avg([fat_grams]) < 5"]
],
"dataset_id":11