Getting Assets
On this page
GET /assets/{assetId}
Code example
export async function getAsset(apiKey: string, token: string, assetId: string, details = true): Promise<IResponse<AssetResponse>> {
let url = `${process.env.NOTARDEC_URL}/assets/${assetId}`;
if (details) {
url = `${process.env.NOTARDEC_URL}/assets/${assetId}?details=true`;
}
const result = await axios.get<IResponse<AssetResponse>>(url, {
headers: token
? {
Authorization: `Bearer ${token}`,
'X-API-KEY': apiKey,
}
: {
'X-API-KEY': apiKey,
},
});
return result.data;
}
Here, the first parameter we pass is the Notardec Key, the second is the token (optional parameter, the record can be created using the TEOS key), the third is the asset id, the fourth is details. The asset id must be string and the response body will have the following form:
export interface IResponse<T> {
value: T | null;
meta?: MetaResponse;
error?: ErrorResponse;
}
export interface AssetResponse {
id: string;
author: string;
name: string;
description: string;
language: string;
jurisdiction: string;
unotOfMeasure: string;
sparkFactor: string;
sparkFactorModifier: string;
assetClass: string;
createdOn: Date;
updatedOn: Date;
blockchainHash: string;
documentDbHash: string;
transactionId: string;
customDefinitionItems?: AssetCustomDefinitionItems[];
}
Real asset example
{
id: '0d80c1ea41b73a57db90a0001',
name: 'Hello world asset 1',
author: '0x943d7c1b12d7241598f1bf3fcc5d27a8ad2cc096',
description: 'Notardec Asset',
language: 'en',
jurisdiction: 'EARTH',
unitOfMeasure: 'token',
sparkFactor: '1',
sparkFactorModifier:
'{"type":"FORMULA","start":"2021-09-21T12:11:08Z","t":"1d","f":"1"}',
assetClass: 'A017',
createdOn: '2021-09-21T14:27:44.7828091+02:00',
updatedOn: '2021-09-21T14:27:44.7828091+02:00',
blockchainHash:
'0xa21d0889b90e745516416e13adbb9a8fbfe9fde20e92bd9ee2f728028ae50fcc',
documentDbHash:
'a21d0889b90e745516416e13adbb9a8fbfe9fde20e92bd9ee2f728028ae50fcc',
customDefinitionItems: [
{
key: 'data',
type: 'TEXT',
value: 'Lorem ipsum 111',
name: 'Data',
sectionsPath: '[documentation]',
sectionsPathNames: '[Documentation]',
},
],
transactionId: '03e1da13-aed0-4b46-4708-08d97cc96d25',
assetLinkIds: ['0cf3e2e5f35b8d6cf47aa0001'],
}