Combining Functions
Combing functions is one of the most powerful features of the GoSquared API. For each API, multiple GET requests can be combined into one - minimising network usage and offering far greater flexibility.
You can even get multiples of the same resource in one request (e.g. Getting Time Series data for this Friday as well as last Friday)
Multiple functions
You can retrieve multiple different endpoints at the same time by separating them with a comma. For example, to retrieve both a list of currently online browsers and a list of countries of online visitors
https://api.gosquared.com/now/v3/
browsers
,
countries
This will retrieve both timeSeries and concurrents data. In the response (demonstrated on the right).
In addition to this you can specify query parameters for each function by prefixing them with the function name e.g.
?
browsers:
limit=2
Combining functions is currently only possible directly via the HTTP API.
https://api.gosquared.com/now/v3/timeSeries:1,timeSeries:2,concurrents
?api_key=demo&site_token=GSN-106863-S
&timeSeries:1:from=2015-09-01
&timeSeries:1:to=2015-09-07
&timeSeries:2:from=2015-10-01
&timeSeries:2:to=2015-10-07
This will respond with a json object with each individual namespaced response as a property
{
"timeSeries:1": {
"visitors.total": [
{
"time": "2015-09-01T00:00:00+10:00",
"value": 568
},
{
"time": "2015-09-07T00:00:00+11:00",
"value": 743
}
]
},
"timeSeries:2": {
"visitors.total": [
{
"time": "2015-10-01T00:00:00+10:00",
"value": 777
},
{
"time": "2015-10-07T00:00:00+11:00",
"value": 622
}
]
},
"concurrents": {
"visitors": 801,
"returning": 653,
"pages": 746,
"active": 503,
"tagged": 0
}
}