Solved

List projects method not available in Python SDK - any specific reason ?

  • 22 September 2023
  • 2 replies
  • 39 views

Userlevel 1

List Projects API (https://{cluster}.cognitedata.com/api/v1/projects) - no corresponding way to use this from Python SDK.

Is there any specific reason why this method to get the CDF Projects is not available in python sdk.

If it is present I was not able to find it in the documentation. https://cognite-sdk-python.readthedocs-hosted.com/en/latest

icon

Best answer by Murad Sæter 22 September 2023, 10:08

View original

2 replies

Userlevel 4
Badge

I like to use the token inspect endpoint, available at:

token_obj = client.iam.token.inspect()

It comes with a lot of info, but if you just want the CDF projects you have access to, copy this code:

[proj.url_name for proj in token_obj.projects]

Userlevel 2

It’s not implemented in the python SDK yet, it has not been a need (most customers only have 1-2 projects).

You can however use it in the python SDK with generic get function against the REST-API:

client.get("/api/v1/projects")

 

Reply