Retrieve instances by id(s)

async AsyncCogniteClient.data_modeling.instances.retrieve(
nodes: NodeId | Sequence[NodeId] | tuple[str, str] | Sequence[tuple[str, str]] | None = None,
edges: EdgeId | Sequence[EdgeId] | tuple[str, str] | Sequence[tuple[str, str]] | None = None,
sources: SourceSelector | View | ViewId | tuple[str, str] | tuple[str, str, str] | Sequence[SourceSelector | View | ViewId | tuple[str, str] | tuple[str, str, str]] | None = None,
include_typing: bool = False,
) InstancesResult[Node, Edge]

Retrieve one or more instance by id(s).

Parameters:
  • nodes (NodeId | Sequence[NodeId] | tuple[str, str] | Sequence[tuple[str, str]] | None) – Node ids

  • edges (EdgeId | Sequence[EdgeId] | tuple[str, str] | Sequence[tuple[str, str]] | None) – Edge ids

  • sources (Source | Sequence[Source] | None) – Retrieve properties from the listed - by reference - views.

  • include_typing (bool) – Whether to return property type information as part of the result.

Returns:

Requested instances.

Return type:

InstancesResult[Node, Edge]

Examples

Retrieve instances by id:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> res = client.data_modeling.instances.retrieve(
...     nodes=("mySpace", "myNodeExternalId"),
...     edges=("mySpace", "myEdgeExternalId"),
...     sources=("mySpace", "myViewExternalId", "myViewVersion"),
... )

Retrieve nodes an edges using the built in data class

>>> from cognite.client.data_classes.data_modeling import NodeId, EdgeId, ViewId
>>> res = client.data_modeling.instances.retrieve(
...     NodeId("mySpace", "myNode"),
...     EdgeId("mySpace", "myEdge"),
...     ViewId("mySpace", "myViewExternalId", "myViewVersion"),
... )

Retrieve nodes an edges using the the view object as source

>>> from cognite.client.data_classes.data_modeling import NodeId, EdgeId
>>> res = client.data_modeling.instances.retrieve(
...     NodeId("mySpace", "myNode"),
...     EdgeId("mySpace", "myEdge"),
...     sources=("myspace", "myView"),
... )