Assets
Assets are things or items that are owned or assigned to a twin, that a twin can reference and use.
Tasks can be associate or linked to a twin’s asset.
Examples of assets could be a car, menu item or any item for sale.
An asset has a name, a category type (string), and attributes (json object) that can take any key value pair.
A twin has access to the data contained within the asset.
List All Assets Associated with My Twin
Get Details about a Specific Twin
§List All Assets
To view all public assets including assets owned or assigned to your twin
curl --location --request GET '<API_URL>/assets/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
This will return a response similar to the following:
{
"links": {
"first": "https://api.fetch.ai/assets/?page_number=1",
"last": "https://api.fetch.ai/assets/?page_number=1",
"next": null,
"prev": null
},
"data": [
{
"type": "assets",
"id": "<ASSET_ID>>",
"attributes": {
"created": "2022-08-24T17:23:50.979287Z",
"modified": "2022-08-24T19:03:39.904110Z",
"category": "shipments",
"attributes": {
"<KEY>": "<VALUE>",
},
"image_url": null,
"name": "Asset",
"public": true
},
"relationships": {
"image": {
"data": null
},
"twin": {
"data": {
"type": "twins",
"id": "<TWIN_ID>>"
}
}
}
},
],
"meta": {
"pagination": {
"page": 1,
"pages": 1,
"count": <COUNT>
}
}
}
§List All Assets Associated with My Twin
To see what assets are assigned to your twin, you can use the following request:
curl --location --request GET '<API_URL>/my/assets/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
§Get Details about a Specific Asset
You can query a specific asset by appending the asset ID to the /assets/ URL as shown below:
curl --location --request GET '<API_URL>/assets/<ASSET_ID>' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
§Add an Asset
To add an asset to a twin, you need to define a name, a category and add custom attribute values and PSOT to the /my/assets/ URL.
curl --location --request POST '<API_URL>/my/assets/'
--header 'Content-Type: application/vnd.api+json'
--header 'X-Organization: <ORG_ID>'
--header 'X-Twin: <TWIN_ID>'
--header 'Authorization: Token <ACCESS_TOKEN>'
--data-raw '{
"data": {
"type": "assets",
"attributes": {
"name": "<VALUE>",
"category": "<VALUE>",
"attributes": {
"<VALUE>": "<VALUE>"
}
}
}
}'
§Update an Asset
You can update an individual asset by sending a PATH request to the specific asset ID as shown below:
curl --location --request PATCH '<API_URL>/my/assets/<ASSET_ID>/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>' \
--data-raw '{
"data": {
"type": "assets",
"id" : "<ASSET_ID>",
"attributes": {
"attributes": {
"<VALUE>": "<VALUE>"
}
}
}
}'
§Delete an Asset
To delete an asset, you can do a DELETE request to the specific Asset ID url
curl --location --request DELETE '<API_URL>/my/assets/<ASSET_ID>' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
§Query Parameters
Query Parameter | Expected Input | Description |
---|---|---|
category | String | Filter assets by the category |
name | String | Filter & search assets by name |