Skip to main content
Haris vk
Seasoned ⭐️⭐️
Seasoned ⭐️⭐️
May 3, 2025
Solved

Working with cdf demo project

  • May 3, 2025
  • 28 replies
  • 387 views

Hi Cognite Team,
I'm building a React dashboard using Cognite Data Fusion for my portfolio and would like to know if there are any demo projects available for working with CDF data.

Best answer by Mithila Jayalath

Hi ​@Haris vk,

I am working on a development project and want to explore the full asset data. Many assets in the publicdata project have time series, but they lack 3D models.

Can you please let me know what sort of help that you need from our end?

Also, regarding  Fusion.cognite.com , do I need access to the publicdata project there to explore it?

You should have access to the publicdata project. You can login to the project via https://publicdata.fusion.cognite.com/

28 replies

Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 3, 2025

Check out the Open Industrial Data (OID) project. You can find more information about the project here.

Haris vk
Seasoned ⭐️⭐️
Haris vkAuthor
Seasoned ⭐️⭐️
May 7, 2025

hi ​@Mithila Jayalath 

Are there any documents or guides available for accessing public data from the Open Industrial Data (OID) project?

I’ve created a React dashboard to display the data, and I’m using FastAPI on the backend to access the API. For authentication, I initially generated a secret ID from the OID dashboard for a JavaScript SPA. However, I believe authentication is now handled through the Azure AD portal.

Could you please guide me on how to correctly authenticate and access the OID API using Azure AD?

Here’s the code I’m currently using for authentication:
import { CogniteClient, ClientOptions } from "@cognite/sdk";

export const getCDFClient = (
  clientId: string,
  clientSecret: string,
  cluster: string,
  project: string
): CogniteClient => {
  const baseUrl = `https://${cluster}.cognitedata.com`;
  const tenantId = "48d5043c-cf70-4c49-881c-c638f5796997";

  const options: ClientOptions = {
    appId: "cdf-dashboard",
    baseUrl,
    project,
    getToken: async () => {
      try {
        const formBody = new URLSearchParams();
        formBody.append("client_id", clientId);
        formBody.append("client_secret", clientSecret);
        formBody.append("grant_type", "client_credentials");
        formBody.append("scope", "https://api.cognitedata.com/.default");

        const response = await fetch(
          `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`,
          {
            method: "POST",
            headers: {
              "Content-Type": "application/x-www-form-urlencoded",
            },
            body: formBody.toString(),
          }
        );

        if (!response.ok) {
          const errorText = await response.text();
          throw new Error(`OIDC Auth failed: ${response.status} - ${errorText}`);
        }

        const data = await response.json();
        return data.access_token;
      } catch (error) {
        console.error("Failed to obtain OIDC access token:", error);
        throw error;
      }
    },
  };

  return new CogniteClient(options);
};

export const OID_PROJECT = "publicdata";
export const OID_CLUSTER = "api";
export const OID_ROOT_ASSET_ID = 6687602007296940;


Thank you

Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 7, 2025

@Haris vk Please find the sample authentication codes here. If you observe any errors, please let me know.

Haris vk
Seasoned ⭐️⭐️
Haris vkAuthor
Seasoned ⭐️⭐️
May 7, 2025

hi ​@Mithila Jayalath  Thanks for the guidance. I have completely moved authentication to my FastAPI project. On the frontend, I just pass the client ID, tenant ID, and secret ID, which I generated using the OIDC widget for the Python SDK. Now, in FastAPI, I use the Cognito Python SDK for authentication. It's working fine now.

Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 7, 2025

@Haris vk thank you for the update. I’ll mark this question as resolved.

Haris vk
Seasoned ⭐️⭐️
Haris vkAuthor
Seasoned ⭐️⭐️
May 9, 2025

HI ​@Mithila Jayalath again, 


 

Why is get_time_series() returning no data for a valid asset ID using the Cognite Python SDK?


I'm learning to use the Cognite Python SDK with FastAPI. I can successfully retrieve children assets from a known root asset ID (6687602007296940 — from the OID test data for Valhall). Here's the route that works:


@router.get("/assets/{asset_id}/children", response_model=AssetList)
async def get_children_assets(...):
    ...
However, when I try to retrieve time series data for this same asset using:


@router.get("/timeseries", response_model=TimeSeriesList)
async def get_time_series(asset_id: Optional[int] = Query(None), ...):
    client = get_cognite_client(...)
    ts_list = get_timeseries(client, asset_id)
    return {"items": [ts.dump() for ts in ts_list]}
I get no results — the list is empty. The asset is definitely valid and exists:


{
  "id": 4650652196144007,
  "name": "VAL",
  "root_id": 6687602007296940,
  "parent_id": 6687602007296940,
  "description": "Valhall platform"
}
I’m using the publicdata project with the OID dataset. Any idea why get_time_series() doesn’t return anything?

Things I’ve tried:

Verified asset ID is valid

Checked for time series manually in the Cognite Data Fusion UI (still learning how)

Used the same client config (publicdata, OID) for both asset and time series endpoints

Anders  Albert
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 9, 2025

Why is get_time_series() returning no data for a valid asset ID using the Cognite Python SDK?

The most common reason for this is that the service principal you identified with (either interactive - identified as yourself, or client ID/secret identified as a service principal from for example Azure, AWS,Google) do not have access to the time series. 

Haris vk
Seasoned ⭐️⭐️
Haris vkAuthor
Seasoned ⭐️⭐️
May 9, 2025

Hi @anders alber

 

So how can I get acess time series sdk for oid project for learning.

Anders  Albert
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
May 9, 2025

First, I would check that is the problem by checking your token, for example, something like this

from pprint import pprint
from cognite.client.data_classes.capabilities import TimeSeriesAcl
my_token = client.iam.token.inspect()

#Alternative print the entire token
# pprint(my_token.dump())

timeseries_access = [project_capability.capability for project_capability in my_token.capabilities if isinstance(project_capability.capability, TimeSeriesAcl)]

For my case I have access to all TimeSeries in the entire project. Note you might only have access to TimeSeries in certain dataset:

If you lack access you need to add the missing TimeSeries capability to the group associated with your service principal. For example, I am using a service principal from EntraID (Azure) with group id ‘cb93285a-b545-4d6c-abc0-d77faf11ff5e’. This is connected to ‘myGroup’ in CDF which needs to have the TimeSeries capability

 

Haris vk
Seasoned ⭐️⭐️
Haris vkAuthor
Seasoned ⭐️⭐️
August 12, 2025

Hi ​@Anders Albert ,

I’m trying to use the OID Project public data, pick any asset, and display that asset’s data.

Since authentication is already working, what steps do I need to take next to access the data?