API Documentation
Api Versión: 2.0
This document explains the use of the Datakubes API with examples.
This API allows you to make queries and add information to the resources that are in your DataKubes account.
Resource Concepts
The type of Kube resources consumed through the API, are as follows.
Type | Description |
---|---|
Kubes of Reports | They are the reports generated in Kubes. Only reports are supported, and this resource only allows GET-type actions. |
Charts of Kubes Store | They are the charts created in the Kubes Store repository. These resources allow the use of GET and PUT actions. |
Data Workshop Projects | They are projects that have an execution flow for machine learning or data projects. |
Data Workshop _ project _ Objects | Objects can be specifically run within Workshop projects. |
The resources require to be authorized in the section of each access token.
Token Management
The tokens are the access codes or keys to consume the resources in your Kube account. You can create the tokens in the Security / API Tokens section, where the following values that regulate access to the token are typified.
Configuration | Description |
---|---|
Ip Access | Here, you define the IPs that will have access to consume the API using the Token. |
Kubes Resources | The Resources that are Kubes Reports are defined; remember that this type of resource only allows GET actions. |
Kubes Store Resources | The Resources that are charts are defined in your KStore _ repository _. This type of resource allows GET and PUT actions. |
Access Type | It defines the types of actions that the Token can perform to the assigned resources. |
You can create all the Tokens you need to control access to the different resources.
Accessing to API
GET Obtain Data from Kube
Here are examples of how the API can be used in PHP and CURL code:
** Authentication model embedded in the POST Payload. **
curl --location --request POST 'https://api.datakubes.com' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '{
"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn",
"k":"7c34083fefa8e201cd90e0f509ae69d6",
"type":"GET",
"results":1,
"filters":[{"field":"Date","type":">=", "value":"2020-01-01"}, {"field":"Date","type":"<=", "value":"2020-01-01"}],
"orderby":[{"field":"Date", "type":"<ASC/DESC>"}]
}'
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://kubes.enx.one/api/kube/v2/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn","k":"7c34083fefa8e201cd90e0f509ae69d6",\n\"type\":\"GET\",\n\"results\":1,\n\"filters\":[{\"field\":\"Date\",\"type\":\">=\", \"value\":\"2020-01-01\"}, {\"field\":\"Date\",\"type\":\"<=\", \"value\":\"2020-01-01\"}]\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Models of direct authentication to URL
In some cases, it is necessary to place the direct credentials as URL variables to allow greater smoothness of integration. It can be done as the examples below:
¡Safety Alert!
This integration model is considered unsafe. However, remember that IP controls the access.
curl --location --request GET 'https://api.datakubes.com/?a=9c1acab8433828973a8c4a86ea166345-werw-isqycvrn&k=974f80d4160def16dd86e38bac5079d5&type=GET&results=10&filters[0][field]=Date&filters[0][type]=>=&filters[0][value]=2020-01-01&filters[1][field]=Date&filters[1][type]=<=&filters[1][value]=2020-01-31'
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.datakubes.com/?a=9c1acab8433828973a8c4a86ea166345-werw-isqycvrn&k=974f80d4160def16dd86e38bac5079d5&type=GET&results=10&filters[0][field]=Date&filters[0][type]=>=&filters[0][value]=2020-01-01&filters[1][field]=Date&filters[1][type]=<=&filters[1][value]=2020-01-31",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
The allowed parameters are explain as follows:
Variable | Description | Default Value | Required |
---|---|---|---|
a | Authorization token created from Security / API Tokens. | X | |
k | Token of the Kube resource, either Reports or Charts from the Kube Store. | X | |
type | To obtain must have GET and write PUT. | X | |
results | Number of records to obtain. | Empty equivalent to 100. | |
page | A page that you want to obtain according to the requested results. For example, "results = 5 pages = 3" will show the following five records after record 10. | Empty equivalent to 1. | |
filters | A JSON array with the filters to be applied. For example, in the case of the Payload or Array of URL Get variables in direct integration. | Empty without filters. | |
orderby | A JSON array with the fields and order by type to be applied. This option lets user control de data order to be displayed in every page result response. | Empty without order by. Array with valid field and type with value ASC or DESC. |
POST Send data to Resources Chart in the DataKube Repositories
The DataKubes API allows you to send data to the charts that reside in the DataKubes repository. These repositories will enable you to create your data containers in our powerful Analytics cloud. In addition, the charts that reside in DataKubes allow access to complex queries and data processing in real-time.
Here are examples of how the API can be used in PHP and CURL code to perform a POST:
curl --location --request POST 'https://api.datakubes.com' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '{
"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn",
"k":"7c34083fefa8e201cd90e0f509ae69d6",
"type":"POST",
"payload":[
{"field_1":"value_1", "value_2":"value_1", "field_3":"value_2"},
{"field_1":"value_2", "field_2":"value_2", "field_3":"value_2"},
{"field_1":"value_3", "field_2":"value_3", "field_3":"value_3"}
]
}'
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.datakubes.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn","k":"7c34083fefa8e201cd90e0f509ae69d6",\n\"type\":\"GET\",\n\"results\":1,\n\"payload\":[{"field_1":"value_1", "field_2":"value_2", "field_3":"value_3"},{"field_1":"value_1", "field_2":"value_2", "field_3":"value_3"},{"field_1":"value_1", "field_2":"value_2", "field_3":"value_3"},{"field_1":"value_1", "field_2":"value_2", "field_3":"value_3"}]\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Multiple records can be batch sent and inserted at the same time. In the example above, you can observe the three records that were sent.
As follows you will find the sent parameters explanation:
Field | Description | Required |
---|---|---|
a | Authorization token created from Security / API Tokens. | X |
k | Kube resource Token, either Reports or Charts from the Kube Store. | X |
type | To send data need to carry a POST. | X |
payload | A JSON array is composed of all the records and fields you want to insert into the Resource. | X |
Errors in the Name Fields
You must submit the fields in the way they are created in the chart in the repository. If a field is not named correctly or does not exist, it will send an error in the API.
Primary Keys
If the destination chart in the repository has a primary key and there is data sent in the API, it will replace the data of that single record.
Records with incomplete fields!
If you send a data record where not all the fields or columns are contained in the payload sent to the API, they will be filled with predefined values, null or empty, according to how it has been configured in the chart.
WebHook Relays - Middleware Model (Beta Invite Only)
In addition to allowing data to enter the resources in Kubes Store, our platform enables you to forward the records entered by API to these resources and copy them to other URLs configured in the resource. Thus, allowing the usage of Kubes as an easy and straightforward to implement middleware.
Execution of Projects and their Items in Data Workshop
You will be able to run the complete items and projects in Data Workshop using the DataKubes API.
To run a complete project in the order in which they are configured, you need to use the following Endpoint API:
curl --location --request POST 'https://api.datakubes.com' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '{
"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn",
"k":"7c34083fefa8e201cd90e0f509ae69d6",
"type":"POST",
"payload":[
{"field_1":"value_1", "value_2":"value_1", "field_3":"value_2"},
{"field_1":"value_2", "field_2":"value_2", "field_3":"value_2"},
{"field_1":"value_3", "field_2":"value_3", "field_3":"value_3"}
]
}'
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.datakubes.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn","k":"7c34083fefa8e201cd90e0f509ae69d6",\n\"type\":\"GET\",\n\"results\":1,\n\"payload\":[{"field_1":"row_1", "field_2":"row_1", "field_3":"row_1"},{"field_1":"row_2", "field_2":"row_2", "field_3":"row_2"},{"field_1":"row_3", "field_2":"row_3", "field_3":"row_3"}]\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
To execute one or multiple items of a specific project, you can proceed with the following API Endpoint:
curl --location --request POST 'https://api.datakubes.com' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw '{
"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn",
"k":"7c34083fefa8e201cd90e0f509ae69d6",
"type":"POST",
"payload":[
{"field_1":"value_1", "value_2":"value_1", "field_3":"value_2"},
{"field_1":"value_2", "field_2":"value_2", "field_3":"value_2"},
{"field_1":"value_3", "field_2":"value_3", "field_3":"value_3"}
]
}'
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.datakubes.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{"a":"9c1acab8433828973a8c4a86ea166345-werw-isqycvrn","k":"7c34083fefa8e201cd90e0f509ae69d6",\n\"type\":\"GET\",\n\"results\":1,\n\"payload\":[{"field_1":"row_1", "field_2":"row_1", "field_3":"row_1"},{"field_1":"row_2", "field_2":"row_2", "field_3":"row_2"},{"field_1":"row_3", "field_2":"row_3", "field_3":"row_3"}]\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
To obtain the project token.
Updated 3 months ago