Javascript library
This section will walk you through some of the objects available when using the Onvo AI platform
Installation
In your backend environment, install the @onvo-ai/js
package, this lets you authenticate users, setup sessions and fetch the list of dashboards.
npm install @onvo-ai/js
Usage
Begin by creating an API key by going to https://dashboard.onvo.ai/api-keys (opens in a new tab), filling in a name for your API key and clicking Generate
.
Save this API key to your env file.
API_KEY=eyJhbGciOiJIUzI1NiJ9.e...
Now initialise the SDK
import Onvo from "@onvo-ai/js";
import dotenv from "dotenv";
dotenv.config();
// Initialize the Onvo class with your API key
const onvo = new Onvo(process.env.API_KEY);
You can now fetch the list of dashboards and reports you have with the following API calls:
let dashboards = await onvo.dashboards.list();
To allow a user to view a dashboard, you need to associate a user with the dashboard using a session. To get started, create the user using the following function:
await onvo.embed_users.upsert("123456", {
name: "John appleseed",
email: "john@appleseed.com",
metadata: {
// can contain any other key-pair data you would want to store about the user
group_id: 55,
},
});
To create a session linking the user and a dashboard, you can use the following code:
// Create a session
const sessionUrl = await onvo.sessions.upsert({
embed_user: "123456",
parent_dashboard:
"<id of dashboard you have received from the previous dashboards.list() function>",
parameters: {
year: 2023,
sort: "asc",
},
});
The session object looks like the following:
{
"id": "1ad893d9-8654-4797-8603-d01186575349",
"dashboard": "e0a6ce20-ca31-421e-8764-74cde46e9463",
"organisation": "31a05cfd-1275-4c76-8390-20b328a3c4bf",
"parameters": {
"hello": "world",
"testing": 1234567456
},
"user": "123456",
"url": "https://dashboard.onvo.ai/embed/dashboard/e0a6ce20-ca31-421e-8764-74cde46e9463?token=eyJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiYXV0aGVudGljYXRlZCIsImFwcF9tZXRhZGF0YSI6eyJkYXNoYm9hcmQiOiJlMGE2Y2UyMC1jYTMxLTQyMWUtODc2NC03NGNkZTQ2ZTk0NjMiLCJzZXNzaW9uIjoiMWFkODkzZDktODY1NC00Nzk3LTg2MDMtZDAxMTg2NTc1MzQ5In0sInN1YiI6IjMxYTA1Y2ZkLTEyNzUtNGM3Ni04MzkwLTIwYjMyOGEzYzRiZi1zdWNjZXNzZnVsbCIsImF1ZCI6ImF1dGhlbnRpY2F0ZWQiLCJpYXQiOjE2OTQxNTU3Mjd9.P_eZloNdX7FN2sVWsANfIrHy5SikE1Zl8NPmAteDIwU"
}
Library Reference
new Onvo(apiKey, options)
This is the main class that initializes the connection to the Onvo platform.
apiKey (string)
: Your API key for authentication.options
:baseUrl (string)
: The base URL to the Onvo platform or your self hosted endpoint.
Accounts
onvo.accounts.list()
onvo.accounts.get(id:string)
Automations
onvo.automations.list()
onvo.automations.create(body:object)
onvo.automations.get(id:string)
onvo.automations.update(id:string, body:object)
onvo.automations.delete(id:string)
onvo.automation(id:string).getRuns()
Dashboards
onvo.dashboards.list()
onvo.dashboards.create(body:object)
onvo.dashboards.get(id:string)
onvo.dashboards.update(id:string, body:object)
onvo.dashboards.delete(id:string)
onvo.dashboard(id:string).updateWidgetCache()
onvo.dashboard(id:string).getWidgetSuggestions()
onvo.dashboard(dashboardId:string).datasources.list()
onvo.dashboard(dashboardId:string).datasources.link(datasourceId:string)
onvo.dashboard(dashboardId:string).datasources.unlink(datasourceId:string)
Datasources
onvo.datasources.list()
onvo.datasources.create(body:object)
onvo.datasources.get(id:string)
onvo.datasources.update(id:string, body:object)
onvo.datasources.delete(id:string)
onvo.datasource(id:string).getData()
onvo.datasource(id:string).fetchColumnDescriptions()
Embed Users
onvo.embed_users.list()
onvo.embed_users.get(id:string)
onvo.embed_users.upsert(id:string, body:object)
onvo.embed_users.delete(id:string)
onvo.embed_user(id:string).getAccessToken()
Questions
onvo.widgets.list(filters: object)
onvo.widgets.create(body:object)
onvo.widgets.delete(id:string)
Sessions
onvo.sessions.list(filters: object)
onvo.sessions.delete(id:string)
onvo.sessions.revokeAll(body:object)
onvo.sessions.upsert(body:object)
Teams
onvo.teams.list(filters: object)
onvo.teams.get(id:string)
onvo.teams.update(id:string, body:object)
Widgets
onvo.widgets.list(filters: object)
onvo.widgets.create(body:object)
onvo.widgets.get(id:string)
onvo.widgets.update(id:string, body:object)
onvo.widgets.delete(id:string)
onvo.widget(id:string).getImage()