SlicingDice Documentation

SlicingDice API Docs

Welcome to the SlicingDice API documentation. You'll find comprehensive guides and documentation to help you start working with SlicingDice as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Documentation

Aggregations


A SlicingDice aggregation query is equivalent to a SQL query containing ORDER BY clauses, like this:

SELECT Count(DISTINCT User.UserID), 
       Country 
FROM   User 
GROUP  BY Country 
ORDER  BY Count(UserID) DESC; 

Query purpose

SlicingDice aggregation is really powerful for generating insights from the data by calculating metrics, such as maximum, minimum, sum and average, as well as crossing data from different columns to generate pivot tables. If you are used to Relational Databases, imagine the power of crossing data from different tables without the performance hit of multiple JOIN operations.

Aggregation queries are ideal to answer this kind of questions:

  • What is the quantity of users grouped by city and age?
  • What is the quantity of users that accessed /online-demo or /platform at least 3 times in the last 7 days grouped by their browser-version and os-version?
  • What is the sum of all purchase-values from orders between {% convert_date 'YYYY-MM-DDT00:00:00Z' '-30d' %} and {% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}, grouped by gender and age?

Multi-level Aggregations are not commutative

Keep in mind the results are generated by recursively applying aggregations, i.e., when making an aggregation between the age and city columns, it first find the top N values for age and, based on these values, it will find the top N values for city. In this sense, multi-level aggregation are not commutative.


Query endpoint

In order to make a aggregation query, you simply need to send a POST request to https://api.slicingdice.com/v1/query/aggregation with a single JSON object containing a list of columns and predicates.

Pro Tip

Remember that you can also use the /test endpoint https://api.slicingdice.com/v1/test/insert to make data insertions and https://api.slicingdice.com/v1/test/query/aggregation to query before inserting real data to your production database.

Consider generating a free demo API key for yourself to use in all examples below, as indicated on the try before you buy page.


Query syntax and structure

In this query below we will count how many unique entities there are on the table users, grouped by the top 2 most common values for the purchased-products column between {% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %} and {% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}, considering only entities where country column is equals to USA.

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "filter": [
            {
                "country": { "equals": "USA" }
            }
        ],
        "query": [
            {
                "purchased-products": 2,
                "between": [
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
                ]
            }
        ]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "purchased-products": 2,
            "between": [
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ]
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("filter", new JSONArray()
            .put(new JSONObject()
                .put("country", new JSONObject()
                    .put("equals", "USA"))))
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("purchased-products", 2)
                .put("between", new JSONArray()
                    .put("{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}")
                    .put("{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"))));
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "filter" => [
        {
            "country" => {
                "equals" => "USA"
            }
        }
    ],
    "query" => [
        {
            "purchased-products" => 2,
            "between" => [
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ]
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "purchased-products": 2,
            "between": [
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ]
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "filter" => array(
        array(
            "country" => array(
                "equals" => "USA"
            )
        )
    ),
    "query" => array(
        array(
            "purchased-products" => 2,
            "between" => array(
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            )
        )
    )
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"filter", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"country", new Dictionary<string, dynamic>{
                            {"equals", "USA"}
                        }}
                    }
                }},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"purchased-products", 2},
                        {"between", new List<dynamic>{
                            "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                            "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
                        }}
                    }
                }}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "filter": []interface{}{
            map[string]interface{}{
                "country": map[string]interface{}{
                    "equals": "USA",
                },
            },
        },
        "query": []interface{}{
            map[string]interface{}{
                "purchased-products": 2,
                "between": []interface{}{
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}",
                },
            },
        },
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Let's understand each component of this API request:

  • filter - An optional query to filter entities you want to perform the aggregation over (the same query you would pass to a count entities query)
  • query - A list of JSON objects representing aggregation levels

The API response for this query above will be in the format below:

{
    "status": "success",
    "result": {
        "purchased-products": [
            {
                "quantity": 1084,
                "value": "Laptop"
            }, {
                "quantity": 842,
                "value": "Mobile phone"
            }
        ]
    },
    "took": 0.103
}

Let's understand each component of the API response:

  • status - Indicating whether the request was successfully processed or not.
  • result - JSON object containing columns and their matches.
    • <column-name> - The name of the column you are querying over.
      • quantity - Number of unique entities or occurrences of value, depending on the aggregation type.
      • value - Value stored on SlicingDice.
  • took - Time spent processing this request, in seconds.

Quantity vs. Count metrics

Be aware that the quantity value represents how many entities (if it's an attribute column) or events (if it's an event column) are present in that aggregation level for that particular value. Since count-events receive its own between parameter, its value may differ from the quantity value. And since count-entities can be performed over event columns, its value may differ as well.


Query operators, predicates and parameters

Aggregation operators

At this time it's not possible to use operators such and, or, not or freqgroup on the aggregation itself, but it is possible to used them on the filter part of the filtered aggregation query type, as we described below.

Filtered aggregation operators

This is the list of supported operators to be used exclusively in the filter level of the filtered aggregation query.

Note that filter receives the same query you would pass when performing a count entities or Data extraction query.

and

Usage example: Filter all entities that have the name equal to "Jeff" and age equal to 18

or

Usage example: Filter all entities that have the name equal to "Jeff" or age equal to 18

not

Usage example: Filter all entities that name equal to "Jeff" by age not equal to 18

freqgroup

Usage example: Filter all entities that have the purchased on "NY" or on "CA" at least two times when summing up both occurrences

Note that minfreq parameter is required to define a minimum frequency when evaluating the summed up frequencies.


Aggregation predicates

This is the list of supported predicates for the aggregation query (they must be inside query objects).

equals (as a string list)

Selects only values that are within the equals list.

not-equals (as a string list)

Selects only values that are not within the not-equals list.

range

Selects only values that are within the given range.

gt or greater-than

Selects only values that are greater than given gt or greater-than value.

gte or greater-than-or-equal

Selects only values that are greater than or equal to given gte or greater-than-or-equal value.

lt or less-than

Selects only values that are less than given lt or less-than value.

lte or less-than-or-equal

Selects only values that are less than or equal to given lte or less-than-or-equal value.

between

Selects only data stored within given between time ranges.

Note that this predicate is required for event columns and can receive multiple time ranges at a time for metrics aggregations (your results will be aggregated by each time range), such as:

{
  "query": [
    {
      "my-event-column": "count-entities",
      "between": [
        ["now", "-1 day"],
        ["now", "-7 days"],
        ["now", "-30 days"]
      ]
    }
  ]
}

order

Defines how aggregation response will be ordered in each aggregation level.

Date histogram aggregation predicates

interval

Usage example: What are the daily averages of purchases in the last 30 days?"

Metrics aggregation predicates

min

Answers the question: What is the minimum stored value in the age column?

Only supported by the following data types:

max

Answers the question: What is the maximum stored value in the age column?

Only supported by the following data types:

sum

Answers the question: What is the sum of all stored values in the purchases column?

Only supported by the following data types:

avg

Answers the question: What is the average of all stored values in the age column?

Only supported by the following data types:

count-entities

Answers the question: How many entities have at least one value in the signed-up column?

Supported by all data types.

count-events

Answers the question: How many times stored values does the purchases has?

Supported by all event data types.

count-distinct

Answers the question: How many unique values were inserted in the signed-up column?

Supported by all data types.

General parameters

This is the list of general parameters that can be used on most queries.

bypass-cache (optional)

Usage example: Boolean value defining to bypass or not the cache mechanism. Use "bypass-cache": true to ignore cached data. bypass-cache is false by default, meaning that all queries will be cached.

hide-empty-values (optional):

Usage example: Boolean value defining whether the aggregation should return empty values when there aren't enough stored values to fulfill the desired number of values. For instance, this may happen when we want to aggregate the top 5 country with the top 10 age, but there is only 3 stored age values for a particular country. Use "hide-empty-values": true to omit empty values from the response message. hide-empty-values is true by default, meaning that aggregations won't return the empty values.

table (optional)

In which the query should be performed over.

If you do not provide a value to table, the query will be performed over the default table.


Query examples

Find below many aggregation queries, using multiple data types and predicates.

Ready-to-use examples

All SlicingDice's clients/SDK have many ready-to-use examples on their Github repositories.
Check the our client/SDK page to know more.

Complete example

Below you can find a complete aggregation query example, using most of the supported predicates.

Example: What is the average age and maximum of purchase-values (broken by day through the last 10 days) grouped by the last 5 browsers (in alphabetic order) used in the most 5 popular os considering only users from USA?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "filter": [
            {
                "country": { "equals": "USA" }
            }
        ],
        "query": [
            {
                "os": 5,
                "order": {"quantity": "asc"}
            },
            {
                "browser": 5,
                "order": {"value": "desc"}
            },
            {
                "age": "avg",
                "purchase-values": "max",
                "between": ["-10 days", "now"],
                "interval": "days"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "os": 5,
            "order": {
                "quantity": "asc"
            }
        }, 
        {
            "order": {
                "value": "desc"
            },
            "browser": 5
        }, 
        {
            "age": "avg",
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("filter", new JSONArray()
            .put(new JSONObject()
                .put("country", new JSONObject()
                    .put("equals", "USA"))))
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 5)
                .put("order", new JSONObject()
                    .put("quantity", "asc")))
            .put(new JSONObject()
                .put("order", new JSONObject()
                    .put("value", "desc"))
                .put("browser", 5))
            .put(new JSONObject()
                .put("age", "avg")
                .put("between", new JSONArray()
                    .put("-10 days")
                    .put("now"))
                .put("interval", "days")
                .put("purchase-values", "max")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "filter" => [
        {
            "country" => {
                "equals" => "USA"
            }
        }
    ],
    "query" => [
        {
            "os" => 5,
            "order" => {
                "quantity" => "asc"
            }
        }, 
        {
            "order" => {
                "value" => "desc"
            },
            "browser" => 5
        }, 
        {
            "age" => "avg",
            "between" => [
                "-10 days", 
                "now"
            ],
            "interval" => "days",
            "purchase-values" => "max"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "os": 5,
            "order": {
                "quantity": "asc"
            }
        }, 
        {
            "order": {
                "value": "desc"
            },
            "browser": 5
        }, 
        {
            "age": "avg",
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "filter" => array(
        array(
            "country" => array(
                "equals" => "USA"
            )
        )
    ),
    "query" => array(
        array(
            "os" => 5,
            "order" => array(
                "quantity" => "asc"
            )
        ), 
        array(
            "order" => array(
                "value" => "desc"
            ),
            "browser" => 5
        ), 
        array(
            "age" => "avg",
            "between" => array(
                "-10 days", 
                "now"
            ),
            "interval" => "days",
            "purchase-values" => "max"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"filter", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"country", new Dictionary<string, dynamic>{
                            {"equals", "USA"}
                        }}
                    }
                }},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 5},
                        {"order", new Dictionary<string, dynamic>{
                            {"quantity", "asc"}
                        }}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"order", new Dictionary<string, dynamic>{
                            {"value", "desc"}
                        }},
                        {"browser", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"age", "avg"},
                        {"between", new List<dynamic>{
                            "-10 days", 
                            "now"
                        }},
                        {"interval", "days"},
                        {"purchase-values", "max"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "filter": []interface{}{
            map[string]interface{}{
                "country": map[string]interface{}{
                    "equals": "USA",
                },
            },
        },
        "query": []interface{}{
            map[string]interface{}{
                "os": 5,
                "order": map[string]interface{}{
                    "quantity": "asc",
                },
            },
            map[string]interface{}{
                "order": map[string]interface{}{
                    "value": "desc",
                },
                "browser": 5,
            },
            map[string]interface{}{
                "age": "avg",
                "between": []interface{}{
                    "-10 days",
                    "now",
                },
                "interval": "days",
                "purchase-values": "max",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Single-level aggregation

Example: What are the 5 most popular browsers and how many users they have?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "browser": 5
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "browser": 5
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("browser", 5)))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "browser" => 5
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "browser": 5
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "browser" => 5
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "browser": 5,
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Single-level aggregation with a metric

Example: What is the average age of all users?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "age": "avg"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "age": "avg"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("age", "avg")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "age" => "avg"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "age": "avg"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "age" => "avg"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"age", "avg"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "age": "avg",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Single-level aggregation with count events metric

Example: How many products have been purchased?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "purchased-products": "count-events",
                "between": [
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
                ]
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "purchased-products": "count-events",
            "between": [
               "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
               "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))
import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("purchased-products", "count-events")
                .put("between", new JSONArray()
                    .put("{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}")
                    .put("{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"))))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "purchased-products" => "count-events",
            "between" => [
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)
const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "purchased-products": "count-events",
            "between": [
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            ]
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "purchased-products" => "count-events",
            "between" => array(
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
            )
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"purchased-products", "count-events"},
                        {"between", new List<dynamic>{
                            "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}", 
                            "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}"
                        }}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "purchased-products": "count-events",
                "between": []interface{}{
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-20d' %}",
                    "{% convert_date 'YYYY-MM-DDT00:00:00Z' '-1d' %}",
                },
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Single-level aggregation with ends-with on aggregation level

Example: What are the 2 most popular operational systems that the name ends with "nux"?

 curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
    "query": [
        {
            "os": 2,
            "ends-with": "nux"
        }
    ]
}'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "ends-with": "nux",
            "os": 2
        }
    ]
}

print(slicingdice.aggregation(query_data))
import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("ends-with", "nux")
                .put("os", 2)));
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "ends-with" => "nux",
            "os" => 2
        }
    ]
}

puts slicingdice.aggregation(query_data)
const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "ends-with": "nux",
            "os": 2
        }
    ]
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "ends-with" => "nux"
            "os" => 2
        )
    )
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"ends-with", "nux"},
                        {"os", 2}
                    }
                }}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "ends-with": "nux",
                "os": 2,
            },
        },
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Multi-level aggregation

Example: What are the 5 most popular operational systems and their 5 most popular browsers?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "os": 5
            },
            {
                "browser": 5
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 5))
            .put(new JSONObject()
                .put("browser", 5)))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "os" => 5
        }, 
        {
            "browser" => 5
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "os" => 5
        ), 
        array(
            "browser" => 5
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "os": 5,
            },
            map[string]interface{}{
                "browser": 5,
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Multi-level aggregation with equals on aggregation level

Example: What are the 5 most popular browsers on Linux and Windows?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "os": 2,
                "equals": ["Linux", "Windows"]
            },
            {
                "browser": 5
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "os": 2,
            "equals": ["Linux", "Windows"]
        }, 
        {
            "browser": 5
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))
import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 2)
                .put("equals", JSONArray()
                     .put("Linux")
                     .put("Windows")))
            .put(new JSONObject()
                .put("browser", 5)))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "os" => 2,
            "equals" => ["Linux", "Windows"]
        }, 
        {
            "browser" => 5
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)
const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "os": 2,
            "equals": ["Linux", "Windows"]
        }, 
        {
            "browser": 5
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "os" => 2,
            "equals" => array(
                "Linux",
                "Windows"
            )
        ), 
        array(
            "browser" => 5
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 2},
                        {"equals", new List<dynamic>{
                            "Linux",
                            "Windows"
                        }}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "os": 2,
                "equals": []interface{}{
                    "Linux",
                    "Windows"
                },
            },
            map[string]interface{}{
                "browser": 5,
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Multi-level aggregation with a metric

Example: What are the 5 most popular operational systems, their 5 most popular browsers and the average age of their users?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "os": 5
            },
            {
                "browser": 5
            },
            {
                "age": "avg"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": "avg"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 5))
            .put(new JSONObject()
                .put("browser", 5))
            .put(new JSONObject()
                .put("age", "avg")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "os" => 5
        }, 
        {
            "browser" => 5
        }, 
        {
            "age" => "avg"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": "avg"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "os" => 5
        ), 
        array(
            "browser" => 5
        ), 
        array(
            "age" => "avg"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"age", "avg"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "os": 5,
            },
            map[string]interface{}{
                "browser": 5,
            },
            map[string]interface{}{
                "age": "avg",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Multi-level aggregation with multiple metrics

Example: What are the 5 most popular operational systems, their 5 most popular browsers and the average, minimum and maximum age of their users?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "os": 5
            },
            {
                "browser": 5
            },
            {
                "age": ["avg", "min", "max"]
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": [
                "avg", 
                "min", 
                "max"
            ]
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 5))
            .put(new JSONObject()
                .put("browser", 5))
            .put(new JSONObject()
                .put("age", new JSONArray()
                    .put("avg")
                    .put("min")
                    .put("max"))))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "os" => 5
        }, 
        {
            "browser" => 5
        }, 
        {
            "age" => [
                "avg", 
                "min", 
                "max"
            ]
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": [
                "avg", 
                "min", 
                "max"
            ]
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "os" => 5
        ), 
        array(
            "browser" => 5
        ), 
        array(
            "age" => array(
                "avg", 
                "min", 
                "max"
            )
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"age", new List<dynamic>{
                            "avg", 
                            "min", 
                            "max"
                        }}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "os": 5,
            },
            map[string]interface{}{
                "browser": 5,
            },
            map[string]interface{}{
                "age": []interface{}{
                    "avg",
                    "min",
                    "max",
                },
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Multi-level aggregation with count metrics

Example: What are the 5 most popular operational systems, their 5 most popular browsers, how many users and how many distinct ages they have?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "os": 5
            },
            {
                "browser": 5
            },
            {
                "age": "count-distinct",
                "name": "count-entities"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": "count-distinct",
            "name": "count-entities"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))
import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("os", 5))
            .put(new JSONObject()
                .put("browser", 5))
            .put(new JSONObject()
                .put("age", "count-distinct")
                .put("name", "count-entities"))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "os" => 5
        }, 
        {
            "browser" => 5
        }, 
        {
            "age" => "count-distinct",
            "name" => "count-entities"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)
const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "os": 5
        }, 
        {
            "browser": 5
        }, 
        {
            "age": "count-distinct",
            "name": "count-entities"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "os" => 5
        ), 
        array(
            "browser" => 5
        ), 
        array(
            "age" => "count-distinct",
            "name" => "count-entities"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"os", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"browser", 5}
                    }, 
                    new Dictionary<string, dynamic>{
                        {"age", "count-distinct"},
                        {"name", "count-entities"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "os": 5,
            },
            map[string]interface{}{
                "browser": 5,
            },
            map[string]interface{}{
                "age": "count-distinct",
                "name": "count-entities"
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Filtered aggregation

Example: What is the average age of all users from USA?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "filter": [
            {
                "country": { "equals": "USA" }
            }
        ],
        "query": [
            {
                "age": "avg"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "age": "avg"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("filter", new JSONArray()
            .put(new JSONObject()
                .put("country", new JSONObject()
                    .put("equals", "USA"))))
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("age", "avg")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "filter" => [
        {
            "country" => {
                "equals" => "USA"
            }
        }
    ],
    "query" => [
        {
            "age" => "avg"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "age": "avg"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "filter" => array(
        array(
            "country" => array(
                "equals" => "USA"
            )
        )
    ),
    "query" => array(
        array(
            "age" => "avg"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"filter", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"country", new Dictionary<string, dynamic>{
                            {"equals", "USA"}
                        }}
                    }
                }},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"age", "avg"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "filter": []interface{}{
            map[string]interface{}{
                "country": map[string]interface{}{
                    "equals": "USA",
                },
            },
        },
        "query": []interface{}{
            map[string]interface{}{
                "age": "avg",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Date histogram aggregation

Example: What was the highest value of purchase-values in each day since 10 days ago?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "purchase-values": "max",
                "between": ["-10 days", "now"],
                "interval": "days"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("between", new JSONArray()
                    .put("-10 days")
                    .put("now"))
                .put("interval", "days")
                .put("purchase-values", "max")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "between" => [
                "-10 days", 
                "now"
            ],
            "interval" => "days",
            "purchase-values" => "max"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "between" => array(
                "-10 days", 
                "now"
            ),
            "interval" => "days",
            "purchase-values" => "max"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"between", new List<dynamic>{
                            "-10 days", 
                            "now"
                        }},
                        {"interval", "days"},
                        {"purchase-values", "max"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "between": []interface{}{
                    "-10 days",
                    "now",
                },
                "interval": "days",
                "purchase-values": "max",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Filtered date histogram aggregation

Example: What was the highest value of purchase-values in each day since 10 days ago from users living in USA?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "filter": [
            {
                "country": { "equals": "USA" }
            }
        ],
        "query": [
            {
                "purchase-values": "max",
                "between": ["-10 days", "now"],
                "interval": "days"
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("filter", new JSONArray()
            .put(new JSONObject()
                .put("country", new JSONObject()
                    .put("equals", "USA"))))
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("between", new JSONArray()
                    .put("-10 days")
                    .put("now"))
                .put("interval", "days")
                .put("purchase-values", "max")))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "filter" => [
        {
            "country" => {
                "equals" => "USA"
            }
        }
    ],
    "query" => [
        {
            "between" => [
                "-10 days", 
                "now"
            ],
            "interval" => "days",
            "purchase-values" => "max"
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "filter": [
        {
            "country": {
                "equals": "USA"
            }
        }
    ],
    "query": [
        {
            "between": [
                "-10 days", 
                "now"
            ],
            "interval": "days",
            "purchase-values": "max"
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "filter" => array(
        array(
            "country" => array(
                "equals" => "USA"
            )
        )
    ),
    "query" => array(
        array(
            "between" => array(
                "-10 days", 
                "now"
            ),
            "interval" => "days",
            "purchase-values" => "max"
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"filter", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"country", new Dictionary<string, dynamic>{
                            {"equals", "USA"}
                        }}
                    }
                }},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"between", new List<dynamic>{
                            "-10 days", 
                            "now"
                        }},
                        {"interval", "days"},
                        {"purchase-values", "max"}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "filter": []interface{}{
            map[string]interface{}{
                "country": map[string]interface{}{
                    "equals": "USA",
                },
            },
        },
        "query": []interface{}{
            map[string]interface{}{
                "between": []interface{}{
                    "-10 days",
                    "now",
                },
                "interval": "days",
                "purchase-values": "max",
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

Aggregation with order predicate

Example: What are the 3 less popular browsers?

curl -X POST https://api.slicingdice.com/v1/query/aggregation \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "query": [
            {
                "browser": 3,
                "order": {"quantity": "asc"}
            }
        ],
        "table": "users",
        "bypass-cache": true
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

query_data = {
    "query": [
        {
            "order": {
                "quantity": "asc"
            },
            "browser": 3
        }
    ],
    "bypass-cache": True,
    "table": "users"
}

print(slicingdice.aggregation(query_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject queryData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("order", new JSONObject()
                    .put("quantity", "asc"))
                .put("browser", 3)))
        .put("bypass-cache", true)
        .put("table", "users");
        JSONObject result = slicingdice.aggregation(queryData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

query_data = {
    "query" => [
        {
            "order" => {
                "quantity" => "asc"
            },
            "browser" => 3
        }
    ],
    "bypass-cache" => true,
    "table" => "users"
}

puts slicingdice.aggregation(query_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const queryData = {
    "query": [
        {
            "order": {
                "quantity": "asc"
            },
            "browser": 3
        }
    ],
    "bypass-cache": true,
    "table": "users"
};

slicingdice.aggregation(queryData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$queryData = array(
    "query" => array(
        array(
            "order" => array(
                "quantity" => "asc"
            ),
            "browser" => 3
        )
    ),
    "bypass-cache" => true,
    "table" => "users"
);

print_r($slicingdice->aggregation($queryData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var queryData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"order", new Dictionary<string, dynamic>{
                            {"quantity", "asc"}
                        }},
                        {"browser", 3}
                    }
                }},
                {"bypass-cache", true},
                {"table", "users"}
            };

            var result = slicingdice.Aggregation(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    queryData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "order": map[string]interface{}{
                    "quantity": "asc",
                },
                "browser": 3,
            },
        },
        "bypass-cache": true,
        "table": "users",
    }

    fmt.Println(slicingdice.Aggregation(queryData))
}

What's Next

Top values

Aggregations