JavaScript
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.updateWidget('7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d', {
dashboardId: '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.update_widget(
widget_id="7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
dashboard_id="6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b",
measures=[{}],
name="x",
)
print(response.data)curl --request PUT \
--url https://api.roark.ai/v1/dashboard/{dashboardId}/widget/{widgetId} \
--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/{widgetId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
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/{widgetId}"
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("PUT", 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.put("https://api.roark.ai/v1/dashboard/{dashboardId}/widget/{widgetId}")
.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/{widgetId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.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",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"isBaseline": true,
"color": "GREEN"
}
],
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filters": [
{
"type": "METRIC_PROPERTY",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"interval": "HOUR",
"comparisonMode": "NONE",
"comparisonGroups": [
{
"name": "<string>",
"filters": [
{
"type": "METRIC_PROPERTY",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"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"
}Dashboard
Replace a widget
Replaces a widget’s definition. It keeps its id and its place on the dashboard.
PUT
/
v1
/
dashboard
/
{dashboardId}
/
widget
/
{widgetId}
JavaScript
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.updateWidget('7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d', {
dashboardId: '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.update_widget(
widget_id="7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
dashboard_id="6f1d2c3b-4a5e-4f60-8b71-9c0d1e2f3a4b",
measures=[{}],
name="x",
)
print(response.data)curl --request PUT \
--url https://api.roark.ai/v1/dashboard/{dashboardId}/widget/{widgetId} \
--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/{widgetId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
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/{widgetId}"
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("PUT", 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.put("https://api.roark.ai/v1/dashboard/{dashboardId}/widget/{widgetId}")
.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/{widgetId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.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",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"isBaseline": true,
"color": "GREEN"
}
],
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filters": [
{
"type": "METRIC_PROPERTY",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"interval": "HOUR",
"comparisonMode": "NONE",
"comparisonGroups": [
{
"name": "<string>",
"filters": [
{
"type": "METRIC_PROPERTY",
"property": "<string>",
"operator": "EQUALS",
"value": "<string>"
}
],
"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
Path Parameters
Body
application/json
One widget: an analytics query plus its name (unique on the dashboard), chart type and size.