The snippet uses the NODE_URL environment variable to set the Symbol API node.
If no value is provided, a default testnet node is used.
The NAMESPACE_NAME environment variable specifies which namespace to query.
If not set, it defaults to symbol.xym, the namespace linked to the network's native currency XYM.
# Generate namespace ID from namepath=generate_namespace_path(NAMESPACE_NAME)namespace_id=path[-1]namespace_id_hex=f'{namespace_id:x}'print(f'Namespace ID: {namespace_id} (0x{namespace_id_hex})')
// Generate namespace ID from nameconstpath=generateNamespacePath(NAMESPACE_NAME);constnamespaceId=path[path.length-1];constnamespaceIdHex=namespaceId.toString(16);console.log('Namespace ID:',`${namespaceId} (0x${namespaceIdHex})`);
Namespace IDs are computed locally from the namespace name using .
This function takes a fully qualified name like symbol.xym, splits it by ., and returns an array of namespace IDs
for each level in the hierarchy.
The last element is the ID of the deepest namespace.
# Display alias informationalias=ns['alias']alias_type=alias['type']print(f' Alias type: {alias_type}')ifalias_type==1:print(f' Linked mosaic ID: {alias["mosaicId"]}')elifalias_type==2:linked_address=(Address.from_decoded_address_hex_string(alias['address']))print(f' Linked address: {linked_address}')else:print(' No alias linked')
// Display alias informationconstalias=ns.alias;console.log(' Alias type:',alias.type);if(alias.type===1){console.log(' Linked mosaic ID:',alias.mosaicId);}elseif(alias.type===2){constlinkedAddress=Address.fromDecodedAddressHexString(alias.address);console.log(' Linked address:',linkedAddress.toString());}else{console.log(' No alias linked');}
Each level in a namespace hierarchy is an independent namespace that can have its own
alias.
The response includes alias information for the queried level, indicating whether it is linked to a mosaic or an
account:
Alias type 0: No alias is linked.
Alias type 1: The namespace is linked to a mosaic. The response includes the linked mosaic ID.
Alias type 2: The namespace is linked to an account. The response includes the linked address.
Using node https://reference.symboltest.net:3001
Namespace name: symbol.xym
Namespace ID: 16666583871264174062 (0xe74b99ba41f4afee)
Fetching namespace information from /namespaces/e74b99ba41f4afee
Namespace information:
Registration type: 1
Owner address: TCEUGLPCMO5Y72EEISSNUKGTMCN5RO4PVYMK5FI
Depth: 2
Level 0 ID: A95F1F8A96159516
Level 1 ID: E74B99BA41F4AFEE
Start height: 1
End height: 18446744073709551615 (0xFFFFFFFFFFFFFFFF)
Alias type: 1
Linked mosaic ID: 72C0212E67A08BCE
Some highlights from the output:
Namespace ID (line 3): The computed ID for symbol.xym is 0xe74b99ba41f4afee.
Registration type (line 6): The value 1 confirms this is a subnamespace (child of symbol).
Owner address (line 7): The account that registered the symbol namespace hierarchy.
Depth (line 8): The value 2 indicates a two-level hierarchy: symbol (level 0) and xym (level 1).
Level IDs (lines 9-10): level0 is the root symbol namespace ID (A95F1F8A96159516), and level1 is the xym
subnamespace ID (E74B99BA41F4AFEE).
The last level ID matches the namespace ID on line 3, confirming it is the namespace being queried.
End height (line 12): The value 18446744073709551615 (0xFFFFFFFFFFFFFFFF) means this namespace never expires.
Alias (lines 13-14): The alias type 1 confirms the namespace is linked to the XYM mosaic (72C0212E67A08BCE).