Retrieve an asset by id

async AsyncCogniteClient.assets.retrieve(
id: int | None = None,
external_id: str | None = None,
) → Asset | None

Retrieve a single asset by id.

Deprecated since version 8.23.0: The Assets API is deprecated and is scheduled for removal on 2027-12-31. Move asset hierarchies to CogniteAsset in the core data model. See https://docs.cognite.com/cdf/deprecated for details and migration guidance.

Parameters:
  • id (int | None) – ID

  • external_id (str | None) – External ID

Returns:

Requested asset or None if it does not exist.

Return type:

Asset | None

Examples

Get asset by id:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> res = client.assets.retrieve(id=1)

Get asset by external id:

>>> res = client.assets.retrieve(external_id="1")