Retrieve assets
deprecated
Retrieves assets by internal or external ID. Requires assetsAcl:READ. See Assets.
POST
/
assets
/
byids
JavaScript SDK
const assets = await client.assets.retrieve([{id: 123}, {externalId: 'abc'}]);res = client.assets.retrieve_multiple(ids=[1, 2, 3])
res = client.assets.retrieve_multiple(external_ids=["abc", "def"], ignore_unknown_ids=True)
List<Item> byExternalIds = List.of(Item.newBuilder().setExternalId("10").build());
List<Asset> retrievedAssets = client.assets().retrieve(byExternalIds);// by list of items
List<Asset> retrievedAssets = client.assets().retrieve("10", "20");// by varargs of String
List<Item> byInternalIds = List.of(Item.newBuilder().setId(10).build());
List<Asset> retrievedAssets = client.assets().retrieve(byInternalIds);// by list of items
List<Asset> retrievedAssets = client.assets().retrieve(10, 20);// by varargs of Long
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496
}
],
"ignoreUnknownIds": false,
"aggregatedProperties": []
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 4503599627370496
]
],
'ignoreUnknownIds' => false,
'aggregatedProperties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496\n }\n ],\n \"ignoreUnknownIds\": false,\n \"aggregatedProperties\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 4503599627370496\n }\n ],\n \"ignoreUnknownIds\": false,\n \"aggregatedProperties\": []\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"rootId": 4503599627370496,
"name": "<string>",
"id": 4503599627370496,
"aggregates": {
"childCount": 1,
"depth": 1,
"path": [
{
"id": 4503599627370496
}
]
},
"parentId": 4503599627370496,
"parentExternalId": "my.known.id",
"externalId": "my.known.id",
"description": "<string>",
"dataSetId": 4503599627370496,
"metadata": {},
"source": "<string>",
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}Authorizations
oidc-tokenoauth2-client-credentialsoauth2-open-industrial-dataoauth2-auth-code
Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Scopes
Body
application/json
All provided IDs and external IDs must be unique.
⌘I
JavaScript SDK
const assets = await client.assets.retrieve([{id: 123}, {externalId: 'abc'}]);res = client.assets.retrieve_multiple(ids=[1, 2, 3])
res = client.assets.retrieve_multiple(external_ids=["abc", "def"], ignore_unknown_ids=True)
List<Item> byExternalIds = List.of(Item.newBuilder().setExternalId("10").build());
List<Asset> retrievedAssets = client.assets().retrieve(byExternalIds);// by list of items
List<Asset> retrievedAssets = client.assets().retrieve("10", "20");// by varargs of String
List<Item> byInternalIds = List.of(Item.newBuilder().setId(10).build());
List<Asset> retrievedAssets = client.assets().retrieve(byInternalIds);// by list of items
List<Asset> retrievedAssets = client.assets().retrieve(10, 20);// by varargs of Long
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496
}
],
"ignoreUnknownIds": false,
"aggregatedProperties": []
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 4503599627370496
]
],
'ignoreUnknownIds' => false,
'aggregatedProperties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496\n }\n ],\n \"ignoreUnknownIds\": false,\n \"aggregatedProperties\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/byids")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 4503599627370496\n }\n ],\n \"ignoreUnknownIds\": false,\n \"aggregatedProperties\": []\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"rootId": 4503599627370496,
"name": "<string>",
"id": 4503599627370496,
"aggregates": {
"childCount": 1,
"depth": 1,
"path": [
{
"id": 4503599627370496
}
]
},
"parentId": 4503599627370496,
"parentExternalId": "my.known.id",
"externalId": "my.known.id",
"description": "<string>",
"dataSetId": 4503599627370496,
"metadata": {},
"source": "<string>",
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}