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

Arduino

Arduino client/SDK for SlicingDice

You can use the SlicingDice's Arduino client/SDK to rapidly start inserting and querying your data, without having to handle with all the API HTTP requests yourself.

Installing the client

Click here to download our Arduino client as a zip file. After downloading it, you only need to import the zipped contents into your project path.


Source code

SlicingDice's Arduino client/SDK source code is available on Github.


Tests and Examples

At the Arduino client/SDK Github repository, you will find examples of data insertion and queries with their respective expected result messages. You take advantage of all these examples to test the client and also learn how to use it.


Using the client

SlicingDice class encapsulates logic for sending requests to the API.

#include <SlicingDice.h>
#include <ArduinoJson.h>

// If you need a demo Database key visit: https://panel.slicingdice.com/docs/
String apiKey = String("YOUR_API_KEY");
SlicingDice sd = SlicingDice(apiKey);

void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    }

    // Arduino network settings, should match your internet connection properties
    byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 0, 10 };
    byte gateway[] = { 192, 168, 0, 1 }; 
    byte subnet[] = { 255, 255, 255, 0 };
    byte dnxs[] = { 8, 8, 8, 8 };
    Ethernet.begin(mac, ip, dnxs, gateway, subnet);
}

// Send an insertion request to Slicing Dice API and print the result
void loop() {
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& queryIndex = jsonBuffer.createObject();
    JsonObject& nestedQueryIndex = queryIndex.createNestedObject("user1@slicingdice.com");
    nestedQueryIndex["age"] = 22;
    // Auto create non-existent dimension and columns
    JSONArray& autoCreate = queryIndex.createNestedArray("auto-create");
		autoCreate.add("dimension");
		autoCreate.add("column");

    // Index object
    sd.insert(queryIndex);

    // Print result for debugging
    Serial.print("Status code: ");
    Serial.println(sd.statusCode);
    Serial.println(sd.response);
}

Constructor

SlicingDice(const char* apiKey)
  • apiKey (const char*) - Database key to authenticate requests with the SlicingDice API.

Methods

  • void insert(JsonObject& query) - Insert data to existing entities or create new entities, if necessary. This method corresponds to a POST request at /insert.
#include <SlicingDice.h>
#include <ArduinoJson.h>

// If you need a demo Database key visit: https://docs.slicingdice.com/docs/try-before-you-buy
String apiKey = String("YOUR_API_KEY");
SlicingDice sd = SlicingDice(apiKey);

void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    }

    // Arduino network settings, should match your internet connection properties
    byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 0, 10 };
    byte gateway[] = { 192, 168, 0, 1 };
    byte subnet[] = { 255, 255, 255, 0 };
    byte dns[] = { 8, 8, 8, 8 };
    Ethernet.begin(mac, ip, dns, gateway, subnet);
}

// Send an insertion request to Slicing Dice API and print the result
void loop() {
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& data = jsonBuffer.createObject();
    JsonObject& nestedInsertion = data.createNestedObject("user1@slicingdice.com");
    nestedInsertion["age"] = 22;
    
    // Auto create non-existent fields
    JsonArray& autoCreate = data.createNestedArray("auto-create");
    autoCreate.add("dimension");
    autoCreate.add("column");

    // Insert object
    sd.insert(data);

    // Print result for debugging
    Serial.print("Status code: ");
    Serial.println(sd.statusCode);
    Serial.println(sd.response);
}

HTTP Requests

The Arduino client currently uses HTTP (not HTTPS) when sending requests to SlicingDice's API.