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    Guides

A SlicingDice exists query is equivalent to SQL queries like this:

SELECT User.UserID 
FROM   User 
WHERE  User.UserID IN ( 'user1@slicingdice.com' ); 
SELECT User.UserID 
FROM   User 
WHERE  EXISTS (SELECT User.UserID 
               FROM   User 
               WHERE  User.UserID = 'user1@slicingdice.com'); 

Query purpose

You should use exists to check whether the given entity IDs exist within a dimension.

The exists query is ideal to answer this kind of questions:

  • Was the user user1@slicingdice.com inserted on the dimension users?

This query doesn't works at SlicingDice SQL

On our SQL Drivers and API endpoint, you can't make an exists query directly, you will need to check id by id if they exist on the database.


Query endpoint

In order to make a exists query, you simply need to send a POST request to https://api.slicingdice.com/v1/query/exists/entity with a single JSON object containing a list of entity IDs (ids) and the dimension you want to check.

Pro Tip

Remember that you can also use test databases to query before inserting real data to your production database.

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


Query syntax and structure

Checking multiple entities on the entire database

In this query below we will check if multiple users exists on the database MyProject.

The exists endpoint expects a JSON object containing a list of entity IDs to be verified.

curl -X POST https://api.slicingdice.com/v1/query/exists/entity \
    -H 'Authorization: MASTER_OR_READ_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "ids": [
            "user1@slicingdice.com",
            "user2@slicingdice.com",
            "user3@slicingdice.com",
            "user4@slicingdice.com",
            "user5@slicingdice.com"
        ],
        "dimension": "users"
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

table = "dimension"
query_data = [
    "user1@slicingdice.com", 
    "user2@slicingdice.com", 
    "user3@slicingdice.com", 
    "user4@slicingdice.com", 
    "user5@slicingdice.com"
]

print(slicingdice.exists_entity(query_data, table=table))

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");

        String table = "dimension";
        JSONArray queryData = new JSONArray()
        .put("user1@slicingdice.com")
        .put("user2@slicingdice.com")
        .put("user3@slicingdice.com")
        .put("user4@slicingdice.com")
        .put("user5@slicingdice.com");

        JSONObject result = slicingdice.existsEntity(queryData, table);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

table = "dimension"
query_data = [
    "user1@slicingdice.com", 
    "user2@slicingdice.com", 
    "user3@slicingdice.com", 
    "user4@slicingdice.com", 
    "user5@slicingdice.com"
]

puts slicingdice.exists_entity(query_data, table=table)

const SlicingDice = require('slicerjs');

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

const table = "dimension";
const queryData = [
    "user1@slicingdice.com", 
    "user2@slicingdice.com", 
    "user3@slicingdice.com", 
    "user4@slicingdice.com", 
    "user5@slicingdice.com"
];

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

<?php
use Slicer\SlicingDice;

$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$table = "dimension";
$queryData = array(
    "user1@slicingdice.com", 
    "user2@slicingdice.com", 
    "user3@slicingdice.com", 
    "user4@slicingdice.com", 
    "user5@slicingdice.com"
);

print_r($slicingdice->existsEntity($queryData, $table));
?>
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");

            string table = "dimension";
            var queryData = new List<string>{
                "user1@slicingdice.com", 
                "user2@slicingdice.com", 
                "user3@slicingdice.com", 
                "user4@slicingdice.com", 
                "user5@slicingdice.com"
            };

            var result = slicingdice.ExistsEntity(queryData, table);
            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)

    table := "dimension"
    queryData := []string{
        "user1@slicingdice.com",
        "user2@slicingdice.com",
        "user3@slicingdice.com",
        "user4@slicingdice.com",
        "user5@slicingdice.com",
    }

    fmt.Println(slicingdice.ExistsEntity(queryData, table))
}

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

{
    "status": "success",
    "exists": [
        "user1@slicingdice.com",
        "user3@slicingdice.com",
        "user4@slicingdice.com"
    ],
    "not-exists": [
        "user2@slicingdice.com",
        "user5@slicingdice.com"
    ],
    "took": 0.055
}

Let's understand each component of the API response:

  • status - Indicating whether the request was successfully processed or not.
  • exists - List of entity IDs found on the database.
  • not-exists - List of entity IDs not found on the database.
  • took - Time spent processing this request, in seconds.

Query operators, predicates and parameters

This section is focused on API-based JSON endpoint if you're using SQL to make your queries feel free to skip this part.

Supported operators

This type of query does not support any additional query operator.

Supported parameters

This is the list of supported parameters that should be used on the exists queries.

ids

List of entity IDs you want to check existence.

Usage example: What entities among these have been inserted to SlicingDice?

dimension

Which dimension ids should be checked in.

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


Query examples

You can check the Exists query examples to see a lot of exists query examples.


What's Next

Total