# Interact With Node
Use you can Assets and Address API methods.
# Assets API
You can get:
- Asset Balance Distribution.
- All Asset Balances for an Address.
- Balance of a Specific Asset.
- Asset Details.
- Non-Fungible Tokens (NFTs) at an Address.
# Asset Balance Distribution
Endpoint: GET /assets/{assetId}/distribution/{height}/limit/{limit}
# Necessary imports.
import requests
import re
# Specify an asset ID.
asset_id = "PASTE AN ASSET ID"
# Specify the maximum number of entries to return.
limit = 100
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Get the latest block height.
height_response = requests.get(f"{node_url}/blocks/height").json()
height = height_response["height"] - 1
# Build the URL for asset distribution.
url = f"{node_url}/assets/{asset_id}/distribution/{height}/limit/{limit}"
# Get the distribution data.
response = requests.get(url)
text = response.text
# Analyze the output.
pattern = re.compile(r'"([1-9A-HJ-NP-Za-km-z]{30,})":(\d+)')
print("––––––––––––––––––––––––––––––––––––––")
print("Asset Distribution (address: quantity):")
for match in pattern.finditer(text):
address = match.group(1)
balance_lamports = int(match.group(2))
balance_in_waves = balance_lamports / 100.0
print(f"{address}: {balance_in_waves:.2f}")
# Check for pagination.
if '"hasNext":true' in text:
last_item = re.search(r'"lastItem":"(.*?)"', text)
if last_item:
print(f"\nMore pages available. Last item: {last_item.group(1)}")
# All Asset Balances for an Address
Endpoint: GET /assets/balance/{address}
# Necessary imports.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/assets/balance/{address}"
# Get the response.
response = requests.get(url)
data = response.json()
# Extract balances.
balances = data.get("balances", [])
# Print the results.
print("––––––––––––––––––––––––––––––––––––––")
print(f"All Asset Balances for Address: {address}")
for b in balances:
asset_id = b["assetId"]
raw_balance = int(b["balance"])
formatted_balance = raw_balance / 1e2
print(f"Asset ID: {asset_id}, Balance: {formatted_balance:.2f}")
# Balance of a Specific Asset
Endpoint: GET /assets/balance/{address}/{assetId}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
# Specify an asset ID.
asset_id = "PASTE AN ASSET ID"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/assets/balance/{address}/{asset_id}"
# Get the response.
response = requests.get(url)
data = response.json()
# Extract and format balance.
raw = int(data["balance"])
formatted = raw / 1e2
# Print the results.
print("––––––––––––––––––––––––––––––––––––––")
print(f"Asset {data['assetId']} balance at {data['address']}: {formatted:.2f}")
# Asset Details
Endpoint: GET /assets/details/{assetId}
# Necessary import.
import requests
# Specify an asset ID.
asset_id = "PASTE AN ASSET ID"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/assets/details/{asset_id}"
# Get the response.
response = requests.get(url)
d = response.json()
# Print the results.
print("––––––––––––––––––––––––––––––––––––––")
print(f"Name: {d['name']}")
print(f"Description: {d['description']}")
print(f"Decimals: {d['decimals']}")
print(f"Reissuable: {d['reissuable']}")
print(f"Issuer: {d['issuer']}")
# Non-Fungible Tokens (NFTs) at an Address
Endpoint: GET /assets/nft/{address}/limit/{limit}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
# Specify the maximum number of entries to return.
limit = 100
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/assets/nft/{address}/limit/{limit}"
# Get the response.
response = requests.get(url)
nfts = response.json()
# Print the results.
print("––––––––––––––––––––––––––––––––––––––")
print(f"NFTs at Address: {address}")
for nft in nfts:
print(f"ID: {nft['assetId']} | Name: {nft['name']} | Description: {nft['description']} | Quantity: {nft['quantity']}")
# Addresses API
You can get:
- All Addresses in the Node Wallet.
- A Range of Addresses.
- WAVES Balance of an Address.
- WAVES Balance with Confirmations.
- Detailed Balance Information.
- Balances for Multiple Addresses.
- Account Data Entries by Address.
- Data Entry by Key.
- Script Information of an Account.
# All Addresses in the Node Wallet
Endpoint: GET /addresses
# Necessary import.
import requests
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses"
# Get the response.
response = requests.get(url)
addresses = response.json()
# Print the results.
print("Node Wallet Addresses:")
for addr in addresses:
print(addr)
# Range of Addresses
Endpoint: GET /addresses/seq/{from}/{to}
# Necessary import.
import requests
# Wallet index numbers.
from_idx = 0
to_idx = 4
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/seq/{from_idx}/{to_idx}"
# Get the response.
response = requests.get(url)
addresses = response.json()
# Print the results.
print(f"Addresses {from_idx} to {to_idx}:")
for addr in addresses:
print(addr)
# WAVES Balance of an Address
Endpoint: GET /addresses/balance/{address}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/balance/{address}"
# Get the response.
response = requests.get(url)
resp = response.json()
raw = resp["balance"]
# Print the results.
print(f"Balance at {address}: {raw / 1e8:.8f} WAVES")
# WAVES Balance with Confirmations
Endpoint: GET /addresses/balance/{address}/{confirmations}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
# Enter the number of confirmations.
confirmations = 2 # Number example.
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/balance/{address}/{confirmations}"
# Get the response.
response = requests.get(url)
resp = response.json()
raw = resp["balance"]
# Print the results.
print(f"Balance at {address} (>= {confirmations} confirmations): {raw / 1e8:.8f} WAVES")
# Detailed Balance Information
Endpoint: GET /addresses/balance/details/{address}
NOTE: The method shows the available, regular, generating, and effective account balances.
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/balance/details/{address}"
# Get the response.
response = requests.get(url)
info = response.json()
# Print the results.
print(f"Regular: {info['regular'] / 1e8:.8f} WAVES")
print(f"Available: {info['available'] / 1e8:.8f} WAVES")
print(f"Generating: {info['generating'] / 1e8:.8f} WAVES")
print(f"Effective: {info['effective'] / 1e8:.8f} WAVES")
# Balances for Multiple Addresses
Endpoint: POST /addresses/balance
NOTE: This endpoint returns account balances in WAVES.
# Necessary imports.
import requests
import json
# Specify account addresses.
addresses = [
"PASTE 1ST ADDRESS",
"PASTE 2ND ADDRESS"
# ...
]
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/addresses/balance"
- Testnet: "https://nodes-testnet.wavesnodes.com/addresses/balance"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/addresses/balance"
'''
node_url = "https://nodes-testnet.wavesnodes.com/addresses/balance"
# Build the request.
headers = {"Content-Type": "application/json"}
data = {"addresses": addresses}
# Send the POST request.
response = requests.post(node_url, headers=headers, data=json.dumps(data))
results = response.json()
# Print the results.
for addr, entry in zip(addresses, results):
balance = entry["balance"] / 1e8
print(f"{addr}: {balance:.8f} WAVES")
# Account Data Entries by Address
Endpoint: GET /addresses/data/{address}
NOTE: This endpoint returns data entries if there are any.
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/data/{address}"
# Get the response.
response = requests.get(url)
entries = response.json()
# Print the results.
for e in entries:
print(f"{e['key']} ({e['type']}): {e['value']}")
# Data Entry by Key
Endpoint: GET /addresses/data/{address}/{key}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
# Specify an account key.
key = "PASTE AN ACCOUNT KEY"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/data/{address}/{key}"
# Get the response.
response = requests.get(url)
entry = response.json()
# Print the result.
print(f"{entry['key']} ({entry['type']}): {entry['value']}")
# Script Information of an Account
Endpoint: GET /addresses/scriptInfo/{address}
# Necessary import.
import requests
# Specify an account address.
address = "PASTE AN ADDRESS"
'''
Specify the network:
- Mainnet: "https://nodes.wavesnodes.com/"
- Testnet: "https://nodes-testnet.wavesnodes.com/"
- Stagenet: "https://nodes-stagenet.wavesnodes.com/"
'''
node_url = "https://nodes-testnet.wavesnodes.com"
# Build the request URL.
url = f"{node_url}/addresses/scriptInfo/{address}"
# Get the response.
response = requests.get(url)
info = response.json()
# Print the results.
has_script = info.get("script") is not None
print(f"Has Script: {has_script}")
if has_script:
print(f"Complexity: {info['complexity']}")
print(f"Extra Fee: {info['extraFee']}")