How to make API calls with the Python SDK [Cognite Official]


Userlevel 5

Hello,

I’m Pierre, data engineer at Cognite. I’ll be posting, on a regular basis, some useful tips about Cognite Data Fusion and its use. If you have any questions or remarks (technical or not), don’t hesitate to reach out to me or to create a new topic in Cognite Hub.

 

 

Some of the features of the Cognite API are not available in the Python SDK. You can still use those features by making a call to the desired endpoint. The SDK facilitates this process thanks to the get, post, put and delete methods of the Cognite client (see: https://cognite-docs.readthedocs-hosted.com/projects/cognite-sdk-python/en/latest/cognite.html#cogniteclient). Once your client is set up, all the auth process is taken care of by itself, it is very straight forward.

 

Example:

payload = {...}

endpoint_url = “https://api.cognitedata.com/api/v1/projects/my-project/context/diagram/detect/”

response = client.post(endpoint_url, payload)

 

When a payload is needed, you can refer to the documentation to get insights on its structure. (Cognite API documentation: https://docs.cognite.com/api/v1/)

 

This tip could broaden your experience with Cognite Data Fusion and facilitate the use of the API. The SDK provides you the ability to make requests to the API in a really straight-forward way. This could help you tackle some challenges, using diagram contextualisation, Cognite functions, and other great features.

 

If you have any questions, don't hesitate to reach out to in this thread or in a new post.


0 replies

Be the first to reply!

Reply