Dataset Switching

Hi,

Does DOMO offer API to embed Dashboard? Is there any API like below?
https://api.domo.com/v1/dashboards/{dashboardId}/embed
I could not find any details about this API in documentation. So, if this API exists can you please share the URL of Documentation?

GPT suggested below code to switch dataset and load Dashboard with Dataset Switching. Can you please confirm if this is possible?

public async Task<string> GetEmbedUrl(string accessToken, string dashboardId, string datasetId)
{
using var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"https://api.domo.com/v1/dashboards/{dashboardId}/embed"); request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
var payload = new { datasetId = datasetId }; // Pass dynamic dataset ID
request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();

var result = await response.Content.ReadAsStringAsync();
var json = Newtonsoft.Json.Linq.JObject.Parse(result);
return json["url"].ToString(); // Embedded URL }

Tagged:

Comments

  • Domo supports embedding dashboards, but it is done through Publish Dashboard or Domo Everywhere. (I'm not familiar with any API endpoint.)

    The Domo API does not provide functionality to dynamically switch datasets within an embedded dashboard. Dashboard views in Domo are tied to specific datasets as defined during dashboard creation.

    No, the code you show does not work with Domo's API. There's no POST endpoint.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • cadellfalconer
    cadellfalconer Domo Product Manager

    @Alka While I don't believe it's formally documented, after looking at the network calls in developer tools in my web browser and setting a dashboard to embed, it looks like you can likely do what you're looking to do.

    For this, you'll need to create a developer token under "Admin" > "Authentication" > "Access tokens".
    Which you can use in your calls to authenticate using the header param "X-DOMO-Developer-Token".


    First, I found that if you make a "GET" call to the "state" endpoint for a page, it will tell you it's current embed settings.

    Check status of pages embed options:

    CALL:

    curl --location 'https://modocorp.domo.com/api/content/v1/pages/embed/1129211334/state' \
    --header 'X-DOMO-Developer-Token: [DEVELOPERTOKENHERE]'{

    (Notice how the call is made against the /v1/pages/embed endpoint, with the page ID before the /state.)

    RESPONSE:

    {
        "id": 3953,
        "entityId": 1129211334,
        "entityType": "PAGE",
        "ownerId": 1499922594,
        "createdBy": "user",
        "name": "",
        "url": "",
        "gatewayToken": "81rEm",
        "publicLink": "OFF",
        "title": true,
        "interactions": true,
        "dataExport": false,
        "dataMaximization": true,
        "filters": false,
        "persistFilters": false,
        "openLinksInNewTab": true,
        "pageFilters": false,
        "filterBarOpen": false,
        "scheduledReport": false,
        "showAiChat": false
    }
    

    (Notice how it currently says there is no public link)

    Set a page to be able to be embedded, and get it's URL in which to embed:

    Now that I know the state of this page, I can swap it to be embeddable, then get the URL to embed it with by making another call against the same endpoint but this time we will make it a "PUT".

    CALL:

    curl --location --request PUT 'https://modocorp.domo.com/api/content/v1/pages/embed/1129211334/state' \
    --header 'X-DOMO-Developer-Token: [DEVELOPERTOKENHERE]' \
    --header 'Content-Type: application/json' \
    --data '{"publicLink":"SEARCHABLE","title":true,"interactions":true,"filters":true,"filterBarOpen":false,"dataExport":true,"scheduledReport":false,"dataMaximization":true,"persistFilters":true,"openLinksInNewTab":true,"entityType":"PAGE","showAiChat":false}'
    

    (Ensure you're doing a PUT, and in the body data, you'll see all those options refer to the same options in the embed modal that pops up in the UI, the most important one is "publicLink", when set to "SEARCHABLE" it'll be able to be embedded publicly.)

    RESPONSE:

    {
        "id": 3953,
        "entityId": 1129211334,
        "entityType": "PAGE",
        "ownerId": 1499922594,
        "createdBy": "user",
        "name": "",
        "url": "https://embed.domo.com/embed/pages/81rEm",
        "gatewayToken": "81rEm",
        "publicLink": "SEARCHABLE",
        "title": true,
        "interactions": true,
        "dataExport": true,
        "dataMaximization": true,
        "filters": true,
        "persistFilters": true,
        "openLinksInNewTab": true,
        "pageFilters": false,
        "filterBarOpen": false,
        "scheduledReport": false,
        "showAiChat": false
    }
    

    (Notice the "URL" value, that's the iframe link which you can now use to inject into an iFrame to embed that page.)

    So, now it's just a case of handling that JSON response, getting the URL value from it, and injecting that value into an iFrame to be embedded.

    For context of how I looked into this, I simply went to a page in our demo instance, and played with the Embed options of the dashboard, while looking at the network calls:

    Cadell Falconer
    Principal Product Manager
  • cadellfalconer
    cadellfalconer Domo Product Manager

    One follow up to this as I didn't mention it, to achieve the "Dataset switching" like behavior, my proposed above would require you to have multiple dashboards, each powered by the different dataset, and your effectively programmatically swapping the dashboard rather than the dataset.

    Cadell Falconer
    Principal Product Manager
  • Alka
    Alka Member

    @cadellfalconer Thank you for your reply. Creating separate dashboards for each client/user is simply out of scope as there are hundreds of those. Creating/managing/maintaining these dashboards will become difficult. That is why we want a DOMO dashboard which will allow us to switch between datasets dynamically. We are looking for multiple datasets because a single client/user is having millions of records and with single dataset for all the clients the dashboard may have performance issue. We are already in talk with DOMO team regarding this. Though thanks for looking into this and replying back with your suggestions.

  • Have you considered other methods of achieving the outcome? What about something like an html page that allows a selection of clients, pointing to Domo dashboards backed up by different datasets?

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dynamic Domo Dashboard</title>
    <style>
    body {
    font-family: Arial, sans-serif;
    margin: 20px;
    }
    iframe {
    width: 100%;
    height: 80vh;
    border: none;
    }
    select {
    margin-bottom: 20px;
    padding: 10px;
    font-size: 16px;
    }
    </style>
    </head>
    <body>
    <h1>Client Dashboard Viewer</h1>
    <label for="clientSelect">Select a Client:</label>
    <select id="clientSelect">
    <option value="" disabled selected>Select a client</option>
    <option value="https://public.domo.com/dashboards/client1">Client 1</option>
    <option value="https://public.domo.com/dashboards/client2">Client 2</option>
    <option value="https://public.domo.com/dashboards/client3">Client 3</option>
    </select>
    <iframe id="dashboardFrame" src="" title="Domo Dashboard"></iframe>

    <script>
    const clientSelect = document.getElementById('clientSelect');
    const dashboardFrame = document.getElementById('dashboardFrame');

    clientSelect.addEventListener('change', () => {
    const selectedDashboard = clientSelect.value;
    dashboardFrame.src = selectedDashboard;
    });
    </script>
    </body>
    </html>

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • cadellfalconer
    cadellfalconer Domo Product Manager

    @Alka - taking a step back, if the dashboard is the same, but with different datasets, I assume that means the schema would also be the same?
    Could you stack the datasets and apply programmatic filtering?

    You'd need to use server side embed to ensure it's secure though.

    https://developer.domo.com/portal/1yafxad1u8azv-programmatic-filtering

    Cadell Falconer
    Principal Product Manager