REST-API for BI
Written By Rankshift
The REST API provides the following endpoints.
Bearer Token
A token corresponds to one project. Generate your project token by logging in and going to the integrations page, click on REST API and press the Generate button.
Endpoint: /bi/v1/meta
Discover all details about the available tables (‘cubes‘) using the meta endpoint. These can then be used by the load endpoint to query your data.
List all tables:
curl -L 'https://api.rankshift.ai/bi/v1/meta' \
-H 'Authorization: Bearer YOUR-TOKEN'Endpoint: /bi/v1/load
Run the query to the REST API and get the results.
Parameter | Description | Required? |
query | Either a single URL encoded Cube Query, or an array of queries | Yes |
queryType | If multiple queries are passed in query for data blending, this must be set to multi | No |
Response
query - The query passed via params. It can be an array of queries and in such case it will be treated as a Data Blending query.
data - Formatted dataset of query results.
annotation - Metadata for query. Contains descriptions for all query items.
title - Human readable title from the data model.
shortTitle - Short title for visualization usage (ex. chart overlay)
type - Data type
total - The total number of rows returned for the query. Useful for paginating results.
Use HTTP POST to fix problems with query length limits!
Example with HTTP GET:
curl \
-H "Authorization: YOUR-TOKEN" \
-G \
--data-urlencode 'query={"measures":["prompts.count"]}' \
https://api.rankshift.ai/bi/v1/loadExample with HTTP POST:
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: YOUR-TOKEN" \
--data '{"query": {"measures":["articles.count"]}}' \
https://api.rankshift.ai/bi/v1/loadExample response:
{
"query": {
"measures": ["scenarios.count"],
"filters": [],
"timezone": "UTC",
"dimensions": [],
"timeDimensions": []
},
"data": [
{
"scenarios.count": "700"
}
],
"annotation": {
"measures": {
"scenarios.count": {
"title": "Scenarios Count",
"shortTitle": "Count",
"type": "number"
}
},
"dimensions": {},
"segments": {},
"timeDimensions": {}
}
}Example
Get a count of answers (‘articles‘) per Large Language Model per Prompt in a specific scenario (based on scenario id 01jsfnye7yabsrf7eejtzh9jbp)
Query parameters:
{
"measures": ["articles.count"],
"dimensions": [
"prompts.name",
"large_language_models.name"
],
"filters": [
{
"dimension": "articles.scenario_id",
"operator": "equals",
"values": ["01jsfnye7yabsrf7eejtzh9jbp"]
}
]
}Query parameters in URL:
https://api.rankshift.ai/bi/v1/load?query={"measures":["articles.count"],"dimensions":["prompts.text","large_language_models.name"],"filters":[{"dimension":"articles.scenario_id","operator":"equals","values":["01jsfnye7yabsrf7eejtzh9jbp"]}]}Full cURL request:
curl --location --globoff 'https://api.rankshift.ai/bi/v1/load?query={%22measures%22%3A[%22articles.count%22]%2C%22dimensions%22%3A[%22prompts.text%22%2C%22large_language_models.name%22]%2C%22filters%22%3A[{%22dimension%22%3A%22articles.scenario_id%22%2C%22operator%22%3A%22equals%22%2C%22values%22%3A[%2201jsfnye7yabsrfmeejtzh9jbp%22]}]}' \
--header 'Authorization: Bearer YOUR-TOKEN'