Skip to main content

Make your first API call

Basic example

You can find in this table the explanation of the main parameters. If you want more information, you can find them in the corresponding articles in the documentation in the category Parameters.

ParameterRequiredDescription
spacetrueAnalysis scope (single site or multi-sites).
columnstrueList of properties & metrics to query (separated by a comma).
periodtrueAnalysis period (single, multiple, relative).
filterfalseFilters to be applied on properties/metrics.
evofalseTo obtain the evolution of a group of metrics over a certain time period.
sorttrueList of properties / metrics according to which the results will be sorted.
max-resultstrueNumber of results in the results page.
page-numtruePage number of the data set.
optionsfalseAdditionnal parameters

Parameter syntax

PARAMETERSYNTAX
space"space": { "s":[123456789] }
columns"columns": [ "visit_device_type", "m_visits" ]
period"period": { "p1": [ { "type": "D", "start": "2019-10-20", "end": "2019-10-24" } ] }
filter"filter": { "metric": { "m_visits": { "$eq": 19 } }, }
evo"evo": { "granularity": "D", "top": { "max-results": 5, "page-num": 1, "sort": ["-m_visits"] } }
sort-by"sort": [ "m_visits" ]
max-results"max-results": 50
page-num"page-num": 1
options"options": {"ignore_null_properties": true, "eco_mode": true}
var data = JSON.stringify({
"columns": [
"device_type",
"m_visits",
"m_users"
],
"sort": [
"-m_visits"
],
"space": {
"s": [429023]
},
"period": {
"p1": [{
"type": "D",
"start": "2019-10-24",
"end": "2019-10-24"
}]
},
"max-results": 50,
"page-num": 1
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) { console.log(this.responseText); }
});
xhr.open("POST", "https://api.atinternet.io/v3/data/getData");
xhr.setRequestHeader("x-api-key", "YOURAPIKEY");
xhr.send(data);

Output format

This Reporting API v3 allows you to get a response either in csv or in json, the default format being json:

  • JSON output: https://api.atinternet.io/v3/data/getData or https://api.atinternet.io/v3/data/json/getData
  • CSV output: https://api.atinternet.io/v3/data/csv/getData

POST or GET method?

The Reporting API v3.0 is designed to be used with the POST method. As you may have noticed, the content of the API call is getting longer and longer as all the fields are well described, and the GET method can be limited because of th length of the http request.