Skip to content

Official .NET/C# client for SlicingDice, Data Warehouse and Analytics Database as a Service.

License

Notifications You must be signed in to change notification settings

SlicingDice/slicingdice-dot-net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlicingDice Official .NET/C# Client (v2.1.0)

Official .NET/C# client for SlicingDice - Data Warehouse and Analytics Database as a Service.

SlicingDice is a serverless, SQL & API-based, easy-to-use and really cost-effective alternative to Amazon Redshift and Google BigQuery.

Build Status: CircleCI

Code Quality: Codacy Badge

Documentation

If you are new to SlicingDice, check our quickstart guide and learn to use it in 15 minutes.

Please refer to the SlicingDice official documentation for more information on how to create a database, how to insert data, how to make queries, how to create columns, SlicingDice restrictions and API details.

Tests and Examples

Whether you want to test the client installation or simply check more examples on how the client works, take a look at tests and examples directory.

Installing

In order to install the .NET/C# client, you only need to install our package SlicingDice through the Package Manager from Visual Studio.

Install-Package SlicingDice

You can also install our client through the following nuget command.

nuget install SlicingDice

Usage

SlicingDice encapsulates logic for sending requests to the API. Its methods are thin layers around the API endpoints, so their parameters and return values are JSON-like Dictionary<string, dynamic> objects with the same syntax as the API endpoints

Example:

The following code snippet is an example of how to add and query data using the SlicingDice C# client. We entry data informing [email protected] has age 22 and then query the database for the number of users with age between 20 and 40 years old. If this is the first record ever entered into the system, the answer should be 1.

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace Slicer.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            // Configure the client
            var client = new SlicingDice(masterKey: "API_KEY");

            // Creating a column
            var columnData = new Dictionary<string, dynamic>()
            {
                {"name", "Age"},
                {"api-name", "age"},
                {"description", "User age"},
                {"type", "integer"},
                {"storage", "latest-value"}
            };
            client.CreateColumn(columnData);

            // Inserting data
            var insert = new Dictionary<string, dynamic>()
            {
                {"[email protected]", new Dictionary<string, int>(){
                    {"age", 2}
               }}
            };
            client.Insert(insert);

            // Querying data
            var queryData = new Dictionary<string, dynamic>()
                        {
                            {"query-name", "users-between-20-and-40"},
                            {"query",
                                new List<Dictionary<string, dynamic>>()
                                {
                                    new Dictionary<string, dynamic>(){
                                        {"age", new Dictionary<string, dynamic>(){
                                                {"range", new List<int>(){ 20, 40 }}
                                            }
                                        }
                                    }
                                }
                            }
                        };

            var result = client.CountEntity(queryData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Attributes

  • key (string) - API key to authenticate requests with the SlicingDice API.
  • timeout (int) - Amount of time, in seconds, to wait for results for each request.

Constructors

SlicingDice(string masterKey=null, string customKey=null, string writeKey=null, string readKey=null, int timeout=60)

  • masterKey (string) - API key to authenticate requests with the SlicingDice API.
  • customKey (string) - API key to authenticate requests with the SlicingDice API.
  • writeKey (string) - API key to authenticate requests with the SlicingDice API.
  • readKey (string) - API key to authenticate requests with the SlicingDice API.
  • timeout (int) - Amount of time, in seconds, to wait for results for each request.

Dictionary<string, dynamic> GetDatabase()

Get information about current database. This method corresponds to a GET request at /database.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

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

            var result = client.GetDatabase();
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "name": "Database 1",
    "description": "My first database",
    "dimensions": [
    	"default",
        "users"
    ],
    "updated-at": "2017-05-19T14:27:47.417415",
    "created-at": "2017-05-12T02:23:34.231418"
}

Dictionary<string, dynamic> GetColumns()

Get all created columns, both active and inactive ones. This method corresponds to a GET request at /column.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

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

            var result = client.GetColumns();

            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "active": [
        {
          "name": "Model",
          "api-name": "car-model",
          "description": "Car models from dealerships",
          "type": "string",
          "category": "general",
          "cardinality": "high",
          "storage": "latest-value"
        }
    ],
    "inactive": [
        {
          "name": "Year",
          "api-name": "car-year",
          "description": "Year of manufacture",
          "type": "integer",
          "category": "general",
          "storage": "latest-value"
        }
    ]
}

Dictionary<string, dynamic> CreateColumn(Dictionary<string, dynamic> query)

Create a new column. This method corresponds to a POST request at /column.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var column = new Dictionary<string, dynamic>()
            {
                {"name", "Year"},
                {"api-name", "year"},
                {"type", "integer"},
                {"description", "Year of manufacturing"},
                {"storage", "latest-value"}
            };
            var result = client.CreateColumn(column);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "api-name": "year"
}

Dictionary<string, dynamic> Insert(Dictionary<string, dynamic> data)

Insert data to existing entities or create new entities, if necessary. This method corresponds to a POST request at /insert.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_WRITE_API_KEY");
            var insert = new Dictionary<string, dynamic>()
            {
                {"auto-create", new List<string>(){
                    "dimension", "column"
                }},
                {"[email protected]", new Dictionary<string, dynamic>{
                    {"car-model", "Ford Ka"},
                    {"year", 2006}
                }},
                {"[email protected]", new Dictionary<string, dynamic>{
                    {"car-model", "Honda Fit"},
                    {"year", 2006}
                }},
                {"[email protected]", new Dictionary<string, dynamic>{
                    {"car-model", "Toyota Corolla"},
                    {"year", 2010},
                    {"test-drives", new List<Dictionary<string, dynamic>>{
                        new Dictionary<string, dynamic>{
                            {"value", "NY"},
                            {"date", "2016-08-17T13:23:47+00:00"}
                        },
                        new Dictionary<string, dynamic>{
                            {"value", "NY"},
                            {"date", "2016-08-17T13:23:47+00:00"}
                        },
                        new Dictionary<string, dynamic>{
                            {"value", "CA"},
                            {"date", "2016-04-05T10:20:30Z"}
                        }
                    }}
                }},
                {"[email protected]", new Dictionary<string, dynamic>{
                    {"car-model", "Ford Ka"},
                    {"year", 2005},
                    {"test-drives", new List<Dictionary<string, dynamic>>{
                        new Dictionary<string, dynamic>{
                            {"value", "NY"},
                            {"date", "2016-08-17T13:23:47+00:00"}
                        }
                    }}
                }}
            };

            var result = client.Insert(insert);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "inserted-entities": 4,
    "inserted-columns": 10,
    "took": 0.023
}

Dictionary<string, dynamic> ExistsEntity(ids, dimension = null)

Verify which entities exist in a dimension (uses default dimension if not provided) given a list of entity IDs. This method corresponds to a POST request at /query/exists/entity.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var ids = new List<string>{
                "[email protected]",
                "[email protected]",
                "[email protected]"
            };
            var result = client.ExistsEntity(ids);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "exists": [
        "[email protected]",
        "[email protected]"
    ],
    "not-exists": [
        "[email protected]"
    ],
    "took": 0.103
}

Dictionary<string, dynamic> CountEntityTotal()

Count the number of inserted entities in the whole database. This method corresponds to a POST request at /query/count/entity/total.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            
            var result = client.CountEntityTotal();
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "result": {
        "total": 42
    },
    "took": 0.103
}

Dictionary<string, dynamic> CountEntityTotal(List<string> dimensions)

Count the total number of inserted entities in the given dimensions. This method corresponds to a POST request at /query/count/entity/total.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var dimensions = new List<string>()
            {
                "default"
            };
            var result = client.CountEntityTotal(dimensions);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "result": {
        "total": 42
    },
    "took": 0.103
}

Dictionary<string, dynamic> CountEntity(List<dynamic> query)

Count the number of entities matching the given query. This method corresponds to a POST request at /query/count/entity.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new List<dynamic>{
                new Dictionary<string, dynamic>()
                    {
                        {"query-name", "corolla-or-fit"},
                        {"query", new List<dynamic>{
                            new Dictionary<string, dynamic>{
                                {"car-model", new Dictionary<string, dynamic>{
                                    {"equals", "toyota corolla"}
                                }}
                            },
                            "or",
                            new Dictionary<string, dynamic>{
                                {"car-model", new Dictionary<string, dynamic>{
                                    {"equals", "honda fit"}
                                }}
                            }
                        }},
                        {"bypass-cache", false}
                    },
                new Dictionary<string, dynamic>()
                    {
                        {"query-name", "users-from-ny"},
                        {"query", new List<Dictionary<string, dynamic>>{
                            new Dictionary<string, dynamic>{
                                {"car-model", new Dictionary<string, dynamic>{
                                    {"equals", "ford ka"}
                                }}
                            }
                        }},
                        {"bypass-cache", false}
                    }
            };

            var result = client.CountEntity(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "ford-ka":2,
      "corolla-or-fit":2
   },
   "took":0.083,
   "status":"success"
}

Dictionary<string, dynamic> CountEntity(Dictionary<string, dynamic> query)

Count the number of entities matching the given query. This method corresponds to a POST request at /query/count/entity.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"query-name", "corolla-or-fit"},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "toyota corolla"}
                        }}
                    },
                    "or",
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "honda fit"}
                        }}
                    }
                }},
                {"bypass-cache", false}
            };

            var result = client.CountEntity(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "corolla-or-fit":2
   },
   "took":0.083,
   "status":"success"
}

Dictionary<string, dynamic> CountEvent(List<dynamic> query)

Count the number of occurrences for time-series events matching the given query. This method corresponds to a POST request at /query/count/event.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new List<dynamic>{
                new Dictionary<string, dynamic>()
                    {
                        {"query-name", "test-drives-in-ny"},
                        {"query", new List<Dictionary<string, dynamic>>{
                            new Dictionary<string, dynamic>{
                                {"test-drives", new Dictionary<string, dynamic>{
                                    {"equals", "NY"},
                                    {"between", new List<string>{
                                        "2016-08-16T00:00:00Z",
                                        "2016-08-18T00:00:00Z"
                                    }}
                                }}
                            }
                        }},
                        {"bypass-cache", false}
                    },
                new Dictionary<string, dynamic>()
                    {
                        {"query-name", "test-drives-in-ca"},
                        {"query", new List<Dictionary<string, dynamic>>{
                            new Dictionary<string, dynamic>{
                                {"test-drives", new Dictionary<string, dynamic>{
                                    {"equals", "CA"},
                                    {"between", new List<string>{
                                        "2016-04-04T00:00:00Z",
                                        "2016-04-06T00:00:00Z"
                                    }}
                                }}
                            }
                        }},
                        {"bypass-cache", false}
                    }
            };

            var result = client.CountEvent(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "test-drives-in-ny":3,
      "test-drives-in-ca":0
   },
   "took":0.063,
   "status":"success"
}

Dictionary<string, dynamic> CountEvent(Dictionary<string, dynamic> query)

Count the number of occurrences for time-series events matching the given query. This method corresponds to a POST request at /query/count/event.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                    {"query-name", "test-drives-in-ny"},
                    {"query", new List<Dictionary<string, dynamic>>{
                        new Dictionary<string, dynamic>{
                            {"test-drives", new Dictionary<string, dynamic>{
                                {"equals", "NY"},
                                {"between", new List<string>{
                                    "2016-08-16T00:00:00Z",
                                    "2016-08-18T00:00:00Z"
                                }}
                            }}
                        }
                    }},
                    {"bypass-cache", false}
            };

            var result = client.CountEvent(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "test-drives-in-ny":3
   },
   "took":0.063,
   "status":"success"
}

Dictionary<string, dynamic> TopValues(Dictionary<string, dynamic> query)

Return the top values for entities matching the given query. This method corresponds to a POST request at /query/top_values.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"car-year", new Dictionary<string, dynamic>{
                    {"year", 2}
                }},
                {"car models", new Dictionary<string, dynamic>{
                    {"car-model", 3}
                }}
            };

            var result = client.TopValues(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "car models":{
         "car-model":[
            {
               "quantity":2,
               "value":"ford ka"
            },
            {
               "quantity":1,
               "value":"honda fit"
            },
            {
               "quantity":1,
               "value":"toyota corolla"
            }
         ]
      },
      "car-year":{
         "year":[
            {
               "quantity":2,
               "value":"2016"
            },
            {
               "quantity":1,
               "value":"2010"
            }
         ]
      }
   },
   "took":0.034,
   "status":"success"
}

Dictionary<string, dynamic> Aggregation(Dictionary<string, dynamic> query)

Return the aggregation of all columns in the given query. This method corresponds to a POST request at /query/aggregation.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"query", new List<Dictionary<string, dynamic>>{
                    new Dictionary<string, dynamic>{
                        {"year", 2},
                    },
                    new Dictionary<string, dynamic>{
                        {"car-model", 2},
                        {"equals", new List<string>{
                            "honda fit",
                            "toyota corolla"
                        }}
                    }
                }}
            };

            var result = client.Aggregation(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }

Output example

{
   "result":{
      "year":[
         {
            "quantity":2,
            "value":"2016",
            "car-model":[
               {
                  "quantity":1,
                  "value":"honda fit"
               }
            ]
         },
         {
            "quantity":1,
            "value":"2005"
         }
      ]
   },
   "took":0.079,
   "status":"success"
}

Dictionary<string, dynamic> GetSavedQueries()

Get all saved queries. This method corresponds to a GET request at /query/saved.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var result = client.GetSavedQueries();
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
    "status": "success",
    "saved-queries": [
        {
            "name": "users-in-ny-or-from-ca",
            "type": "count/entity",
            "query": [
                {
                    "state": {
                        "equals": "NY"
                    }
                },
                "or",
                {
                    "state-origin": {
                        "equals": "CA"
                    }
                }
            ],
            "cache-period": 100
        }, {
            "name": "users-from-ca",
            "type": "count/entity",
            "query": [
                {
                    "state": {
                        "equals": "NY"
                    }
                }
            ],
            "cache-period": 60
        }
    ],
    "took": 0.103
}

Dictionary<string, dynamic> CreateSavedQuery(Dictionary<string, dynamic> query)

Create a saved query at SlicingDice. This method corresponds to a POST request at /query/saved.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"name", "my-saved-query"},
                {"type", "count/entity"},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "honda fit"}
                        }}
                    },
                    "or",
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "toyota corolla"}
                        }}
                    }
                }},
                {"cache-period", 100}
            };

            var result = client.CreateSavedQuery(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.053,
   "query":[
      {
         "car-model":{
            "equals":"honda fit"
         }
      },
      "or",
      {
         "car-model":{
            "equals":"toyota corolla"
         }
      }
   ],
   "name":"my-saved-query",
   "type":"count/entity",
   "cache-period":100,
   "status":"success"
}

Dictionary<string, dynamic> UpdateSavedQuery(string queryName, Dictionary<string, dynamic> query)

Update an existing saved query at SlicingDice. This method corresponds to a PUT request at /query/saved/QUERY_NAME.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"type", "count/entity"},
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "ford ka"}
                        }}
                    },
                    "or",
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "toyota corolla"}
                        }}
                    }
                }},
                {"cache-period", 100}
            };

            var result = client.UpdateSavedQuery("my-saved-query", query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.037,
   "query":[
      {
         "car-model":{
            "equals":"ford ka"
         }
      },
      "or",
      {
         "car-model":{
            "equals":"toyota corolla"
         }
      }
   ],
   "type":"count/entity",
   "cache-period":100,
   "status":"success"
}

Dictionary<string, dynamic> GetSavedQuery(string queryName)

Executed a saved query at SlicingDice. This method corresponds to a GET request at /query/saved/QUERY_NAME.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var result = client.GetSavedQuery("my-saved-query");
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "result":{
      "query":2
   },
   "took":0.035,
   "query":[
      {
         "car-model":{
            "equals":"honda fit"
         }
      },
      "or",
      {
         "car-model":{
            "equals":"toyota corolla"
         }
      }
   ],
   "type":"count/entity",
   "status":"success"
}

Dictionary<string, dynamic> DeleteSavedQuery(string queryName)

Delete a saved query at SlicingDice. This method corresponds to a DELETE request at /query/saved/QUERY_NAME.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_API_KEY");
            var result = client.DeleteSavedQuery("my-saved-query");
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.029,
   "query":[
      {
         "car-model":{
            "equals":"honda fit"
         }
      },
      "or",
      {
         "car-model":{
            "equals":"toyota corolla"
         }
      }
   ],
   "type":"count/entity",
   "cache-period":100,
   "status":"success",
   "deleted-query":"my-saved-query"
}

Dictionary<string, dynamic> Result(Dictionary<string, dynamic> query)

Retrieve inserted values for entities matching the given query. This method corresponds to a POST request at /data_extraction/result.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "ford ka"}
                        }}
                    },
                    "or",
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "toyota corolla"}
                        }}
                    },
                }},
                {"columns", new List<string>{"car-model", "year"}},
                {"limit", 2}
            };

            var result = client.Result(query);

            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.113,
   "next-page":null,
   "data":{
      "[email protected]":{
         "year":"2005",
         "car-model":"ford ka"
      },
      "[email protected]":{
         "year":"2016",
         "car-model":"ford ka"
      }
   },
   "page":1,
   "status":"success"
}

Dictionary<string, dynamic> Score(Dictionary<string, dynamic> query)

Retrieve inserted values as well as their relevance for entities matching the given query. This method corresponds to a POST request at /data_extraction/score.

Request example

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = new Dictionary<string, dynamic>()
            {
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "ford ka"}
                        }}
                    },
                    "or",
                    new Dictionary<string, dynamic>{
                        {"car-model", new Dictionary<string, dynamic>{
                            {"equals", "toyota corolla"}
                        }}
                    },
                }},
                {"columns", new List<string>{"car-model", "year"}},
                {"limit", 2}
            };

            var result = client.Score(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.063,
   "next-page":null,
   "data":{
      "[email protected]":{
         "score":1,
         "year":"2010",
         "car-model":"toyota corolla"
      },
      "[email protected]":{
         "score":1,
         "year":"2016",
         "car-model":"honda fit"
      }
   },
   "page":1,
   "status":"success"
}

Dictionary<string, dynamic> Sql(string query)

Retrieve inserted values using a SQL syntax. This method corresponds to a POST request at /query/sql.

Query statement

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = "SELECT COUNT(*) FROM default WHERE age BETWEEN 0 AND 49";

            var result = client.Sql(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Insert statement

using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SlicingDice(masterKey: "MASTER_OR_READ_API_KEY");
            var query = "SINSERT INTO default([entity-id], name, age) VALUES(1, 'john', 10)";

            var result = client.Sql(query);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}

Output example

{
   "took":0.063,
   "result":[
       {"COUNT": 3}
   ],
   "count":1,
   "status":"success"
}

License

MIT