Skip to main content

Prerequisites

  • A Tarvah instance with the SDK routes enabled
  • An API key (create one here)
  • A data source (database connection ID or VDM ID)

Step 1: Get your chart types

First, check available chart types and aggregations:
curl https://<your-instance>/v1/sdk/chart-types
This returns the full mapping of friendly names (like column, pie, line) to internal chart codes.

Step 2: Create a simple dashboard

import requests

API_KEY = "trvh_sdk_your_key_here"
BASE_URL = "https://<your-instance>/v1/sdk"

payload = {
    "name": "Revenue Dashboard",
    "description": "Quarterly revenue breakdown",
    "dataSource": {
        "dbId": "D2026A00002",
        "vdmId": "VDM2026A00001",
        "connType": "VDM"
    },
    "charts": [
        {
            "title": "Revenue by Region",
            "type": "column",
            "measures": [
                {"field": "revenue", "aggregation": "sum"}
            ],
            "dimensions": ["region"]
        },
        {
            "title": "Revenue Distribution",
            "type": "pie",
            "measures": [
                {"field": "revenue", "aggregation": "sum"}
            ],
            "dimensions": ["category"]
        }
    ],
    "category": ["Sales"],
    "tags": ["quarterly"]
}

response = requests.post(
    f"{BASE_URL}/import",
    json=payload,
    headers={"Authorization": f"Bearer {API_KEY}"}
)

result = response.json()
print(f"Dashboard created! Facade ID: {result['facadeId']}")

Step 3: Create a multi-section dashboard

Use the sections array for dashboards with KPI cards and category tabs:
{
  "name": "Executive Dashboard",
  "dataSource": { "dbId": "D2026A00002", "vdmId": "VDM2026A00001", "connType": "VDM" },
  "templateType": "realEstate",
  "sections": [
    {
      "name": "KPI Overview",
      "topSection": true,
      "charts": [
        { "title": "Total Revenue", "type": "kpi", "measures": [{"field": "revenue", "aggregation": "sum"}], "dimensions": ["period"] },
        { "title": "Total Orders",  "type": "kpi", "measures": [{"field": "order_count", "aggregation": "count"}], "dimensions": ["period"] }
      ]
    },
    {
      "name": "Sales",
      "category": true,
      "charts": [
        { "title": "Sales by Region", "type": "column", "measures": [{"field": "revenue", "aggregation": "sum"}], "dimensions": ["region"] }
      ]
    },
    {
      "name": "Operations",
      "category": true,
      "charts": [
        { "title": "Delivery Times", "type": "line", "measures": [{"field": "delivery_days", "aggregation": "avg"}], "dimensions": ["month"] }
      ]
    }
  ]
}
This creates:
  • A top section with KPI cards (always visible)
  • Category tabs for “Sales” and “Operations” with their respective charts

Response format

{
  "success": true,
  "facadeId": "F2026A00018",
  "experiments": [
    {
      "experimentId": "E2026A00042",
      "section": "KPI Overview",
      "charts": [
        { "chartId": "chart_1", "chartType": "CH00055", "chartTitle": "Total Revenue" },
        { "chartId": "chart_2", "chartType": "CH00055", "chartTitle": "Total Orders" }
      ]
    },
    {
      "experimentId": "E2026A00043",
      "section": "Sales",
      "charts": [
        { "chartId": "chart_1", "chartType": "CH00003", "chartTitle": "Sales by Region" }
      ]
    }
  ]
}