token_price
Retrieve current price, market cap, and 24-hour trading volume for Hedera tokens using a HederaIntel API key and token ID.
Instructions
Get the current price, market cap, and 24h trading volume for a Hedera token. Costs 0.05 HBAR.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | Your HederaIntel API key | |
| token_id | Yes | Hedera token ID (e.g. 0.0.123456) |
Implementation Reference
- src/modules/token/tools.js:98-163 (handler)Handler for the token_price tool. Fetches token data, holder counts, and price information from Hedera mirror node and SaucerSwap API.
if (name === "token_price") { const payment = chargeForTool("token_price", args.api_key); const base = getMirrorNodeBase(); // Fetch token metadata from mirror node const tokenRes = await axios.get(`${base}/api/v1/tokens/${args.token_id}`); const token = tokenRes.data; const decimals = parseInt(token.decimals || 0); const totalSupply = parseInt(token.total_supply || 0); const adjustedSupply = totalSupply / Math.pow(10, decimals); // Fetch holder count — fetch max and sort client-side by balance desc const balRes = await axios.get( `${base}/api/v1/tokens/${args.token_id}/balances?limit=100&account.balance.gt=0` ).catch(() => ({ data: { balances: [] } })); const holders = (balRes.data.balances || []).sort((a, b) => parseInt(b.balance || 0) - parseInt(a.balance || 0)); // Fetch all tokens + price change data in parallel const [saucerTokens, priceChangeMap, defaultTokens] = await Promise.all([ getSaucerSwapTokens(), getSaucerSwapPriceChange(), getSaucerSwapDefaultTokens(), ]); const saucerToken = saucerTokens.find(t => t.id === args.token_id); const defaultToken = defaultTokens.find(t => t.id === args.token_id); // Convert price from tinybars to HBAR let priceHbar = null; let priceUsd = null; if (saucerToken?.price) { priceHbar = (parseInt(saucerToken.price) / 100000000).toFixed(8); priceUsd = saucerToken.priceUsd || null; } // 24h price change from /tokens/price-change map const rawChange = priceChangeMap[args.token_id]; const priceChange24h = rawChange != null ? rawChange.toFixed(2) + "%" : null; // Extended data from /tokens/default (only available for default-listed tokens) const liquidityUsd = defaultToken?.liquidityUsd || null; const priceChangeHour = defaultToken?.priceChangeHour != null ? defaultToken.priceChangeHour.toFixed(2) + "%" : null; const priceChangeWeek = defaultToken?.priceChangeWeek != null ? defaultToken.priceChangeWeek.toFixed(2) + "%" : null; return { token_id: args.token_id, name: token.name || "Unknown", symbol: token.symbol || "?", decimals, total_supply: adjustedSupply.toLocaleString(), type: token.type || "FUNGIBLE_COMMON", treasury: token.treasury_account_id, holder_count: holders.length, price_hbar: priceHbar, price_usd: priceUsd, price_change_1h_pct: priceChangeHour, price_change_24h_pct: priceChange24h, price_change_7d_pct: priceChangeWeek, liquidity_usd: liquidityUsd ? "$" + liquidityUsd.toLocaleString() : null, price_source: saucerToken ? "SaucerSwap DEX" : "Not listed on SaucerSwap DEX", due_diligence_complete: saucerToken?.dueDiligenceComplete ?? null, created_timestamp: token.created_timestamp, memo: token.memo || null, payment, timestamp: new Date().toISOString(), }; } - src/modules/token/tools.js:56-67 (schema)Input schema definition for the token_price tool.
{ name: "token_price", description: "Get the current price, market cap, and 24h trading volume for a Hedera token. Costs 0.1 HBAR.", inputSchema: { type: "object", properties: { token_id: { type: "string", description: "Hedera token ID (e.g. 0.0.123456)" }, api_key: { type: "string", description: "Your HederaIntel API key" }, }, required: ["token_id", "api_key"], }, },