import Roark from '@roarkanalytics/sdk';
const client = new Roark({
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
});
const response = await client.dashboard.createWidget('6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b', {
measures: [{}],
name: 'x',
});
console.log(response.data);import os
from roark_analytics import Roark
client = Roark(
bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"), # This is the default and can be omitted
)
response = client.dashboard.create_widget(
dashboard_id="6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b",
measures=[{}],
name="x",
)
print(response.data)curl --request POST \
--url https://api.roark.ai/v1/dashboard/{dashboardId}/widget \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Sentiment",
"display": "LINE",
"size": "LARGE",
"interval": "DAY",
"measures": [
{
"metric": "sentiment_score",
"aggregation": "AVG"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/dashboard/{dashboardId}/widget",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sentiment',
'display' => 'LINE',
'size' => 'LARGE',
'interval' => 'DAY',
'measures' => [
[
'metric' => 'sentiment_score',
'aggregation' => 'AVG'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/dashboard/{dashboardId}/widget"
payload := strings.NewReader("{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/dashboard/{dashboardId}/widget")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/dashboard/{dashboardId}/widget")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"measures": [
{
"type": "METRIC",
"metric": "<string>",
"aggregation": "COUNT",
"percentile": 50,
"distinctBy": "NONE",
"nestedAggregation": "COUNT",
"nestedAggregationPercentile": 50,
"passOperator": "EQUALS",
"passValue": "<string>",
"breakdown": {
"type": "METRIC_PROPERTY",
"property": "<string>"
},
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"isBaseline": true,
"color": "GREEN"
}
],
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"interval": "HOUR",
"comparisonMode": "NONE",
"comparisonGroups": [
{
"name": "<string>",
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"color": "GREEN"
}
],
"description": "<string>",
"display": "LINE",
"size": "SMALL"
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "conflict",
"code": "resource_in_use",
"message": "The resource is in use and cannot be deleted"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}Add a widget
Adds a widget to the top of a dashboard. Its name must be unique on the dashboard.
import Roark from '@roarkanalytics/sdk';
const client = new Roark({
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
});
const response = await client.dashboard.createWidget('6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b', {
measures: [{}],
name: 'x',
});
console.log(response.data);import os
from roark_analytics import Roark
client = Roark(
bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"), # This is the default and can be omitted
)
response = client.dashboard.create_widget(
dashboard_id="6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b",
measures=[{}],
name="x",
)
print(response.data)curl --request POST \
--url https://api.roark.ai/v1/dashboard/{dashboardId}/widget \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Sentiment",
"display": "LINE",
"size": "LARGE",
"interval": "DAY",
"measures": [
{
"metric": "sentiment_score",
"aggregation": "AVG"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/dashboard/{dashboardId}/widget",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sentiment',
'display' => 'LINE',
'size' => 'LARGE',
'interval' => 'DAY',
'measures' => [
[
'metric' => 'sentiment_score',
'aggregation' => 'AVG'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/dashboard/{dashboardId}/widget"
payload := strings.NewReader("{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/dashboard/{dashboardId}/widget")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/dashboard/{dashboardId}/widget")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sentiment\",\n \"display\": \"LINE\",\n \"size\": \"LARGE\",\n \"interval\": \"DAY\",\n \"measures\": [\n {\n \"metric\": \"sentiment_score\",\n \"aggregation\": \"AVG\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"measures": [
{
"type": "METRIC",
"metric": "<string>",
"aggregation": "COUNT",
"percentile": 50,
"distinctBy": "NONE",
"nestedAggregation": "COUNT",
"nestedAggregationPercentile": 50,
"passOperator": "EQUALS",
"passValue": "<string>",
"breakdown": {
"type": "METRIC_PROPERTY",
"property": "<string>"
},
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"isBaseline": true,
"color": "GREEN"
}
],
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"interval": "HOUR",
"comparisonMode": "NONE",
"comparisonGroups": [
{
"name": "<string>",
"filters": [
{
"type": "METRIC_PROPERTY",
"value": "<string>",
"property": "<string>",
"operator": "EQUALS"
}
],
"color": "GREEN"
}
],
"description": "<string>",
"display": "LINE",
"size": "SMALL"
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "conflict",
"code": "resource_in_use",
"message": "The resource is in use and cannot be deleted"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The dashboard ID
Body
One widget: an analytics query plus its name (unique on the dashboard), chart type and size.
What to aggregate: 1 to 10 measures.
1 - 10 elementsShow child attributes
Show child attributes
Unique on the dashboard: how the widget is matched on update.
1 - 200Applied to every measure, on top of each measure's own filters.
20Show child attributes
Show child attributes
Bucket size. Defaults from the window's length and steps coarser when the window would exceed 500 buckets.
HOUR, DAY, WEEK, MONTH PREVIOUS_PERIOD adds the preceding window of the same length to every series.
NONE, PREVIOUS_PERIOD Run every measure once per named filter set, e.g. one group per agent.
2 - 5 elementsShow child attributes
Show child attributes
2000Chart type. Defaults to LINE.
LINE, NUMBER, RADAR, STACKED_BAR, TABLE Grid width. Defaults to MEDIUM.
SMALL, MEDIUM, LARGE, EXTRA_LARGE Response
The created widget
Show child attributes
Show child attributes