Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.akka.finance/llms.txt

Use this file to discover all available pages before exploring further.

AKKA aggregates liquidity across every DEX on HyperEVM. As a side effect, the token endpoints provide real-time USD prices derived from actual pool reserves — not a single source, but a volume-weighted view across all indexed markets.

Get all token prices in one call

Fetch the full token list to get prices for every token on the chain:
curl -H "apikey: YOUR_API_KEY" \
  "https://api.akka.finance/999/tokens?verified=true"
Each token includes two price fields:
FieldDescription
buyPriceUsdCost to buy 1 unit of this token (USD)
sellPriceUsdValue received when selling 1 unit of this token (USD)
The spread between buyPriceUsd and sellPriceUsd reflects real market liquidity — tighter spreads indicate deeper liquidity.

Get a single token price

If you only need the price for one token:
curl -H "apikey: YOUR_API_KEY" \
  "https://api.akka.finance/999/tokens/0x5555555555555555555555555555555555555555"
{
  "symbol": "WHYPE",
  "name": "Wrapped HYPE",
  "decimals": 18,
  "address": "0x5555555555555555555555555555555555555555",
  "verified": true,
  "buyPriceUsd": 25.42,
  "sellPriceUsd": 25.38
}

Price polling pattern

Prices are refreshed every ~5 seconds on the backend. For most use cases, polling every 15–30 seconds is sufficient and stays well within the rate limit.
priceService.ts
const API_BASE = 'https://api.akka.finance';
const API_KEY = process.env.AKKA_API_KEY!;
const POLL_INTERVAL = 15_000; // 15 seconds

interface TokenPrice {
  symbol: string;
  address: string;
  buyPriceUsd: number | null;
  sellPriceUsd: number | null;
}

let priceCache = new Map<string, TokenPrice>();

async function refreshPrices(): Promise<void> {
  const res = await fetch(
    `${API_BASE}/999/tokens?verified=true`,
    { headers: { apikey: API_KEY } },
  );
  const { tokens } = await res.json();

  const updated = new Map<string, TokenPrice>();
  for (const [address, token] of Object.entries(tokens) as [string, any][]) {
    updated.set(address.toLowerCase(), {
      symbol: token.symbol,
      address: token.address,
      buyPriceUsd: token.buyPriceUsd,
      sellPriceUsd: token.sellPriceUsd,
    });
  }
  priceCache = updated;
}

// Start polling
refreshPrices();
setInterval(refreshPrices, POLL_INTERVAL);

// Read from cache (instant, no API call)
export function getPrice(tokenAddress: string): TokenPrice | undefined {
  return priceCache.get(tokenAddress.toLowerCase());
}

export function getAllPrices(): Map<string, TokenPrice> {
  return priceCache;
}

React hook for prices

hooks/useTokenPrice.ts
import { useState, useEffect } from 'react';

const API_BASE = 'https://api.akka.finance';
const API_KEY = process.env.NEXT_PUBLIC_AKKA_API_KEY!;

interface TokenPrice {
  symbol: string;
  buyPriceUsd: number | null;
  sellPriceUsd: number | null;
}

export function useTokenPrice(chainId: number, tokenAddress: string) {
  const [price, setPrice] = useState<TokenPrice | null>(null);

  useEffect(() => {
    if (!tokenAddress) return;

    let cancelled = false;

    async function fetchPrice() {
      const res = await fetch(
        `${API_BASE}/${chainId}/tokens/${tokenAddress}`,
        { headers: { apikey: API_KEY } },
      );
      if (!res.ok || cancelled) return;
      const data = await res.json();
      setPrice({
        symbol: data.symbol,
        buyPriceUsd: data.buyPriceUsd,
        sellPriceUsd: data.sellPriceUsd,
      });
    }

    fetchPrice();
    const interval = setInterval(fetchPrice, 30_000);

    return () => { cancelled = true; clearInterval(interval); };
  }, [chainId, tokenAddress]);

  return price;
}
Usage:
const whypePrice = useTokenPrice(999, '0x5555555555555555555555555555555555555555');

return <span>WHYPE: ${whypePrice?.buyPriceUsd?.toFixed(2)}</span>;

USD value helper

Convert a token amount in wei to its USD value:
import { formatUnits } from 'viem';

function toUsdValue(amountWei: string, decimals: number, priceUsd: number | null): string | null {
  if (!priceUsd) return null;
  const amount = Number(formatUnits(BigInt(amountWei), decimals));
  return (amount * priceUsd).toFixed(2);
}

// Example: 1 WHYPE (18 decimals) at $25.42
toUsdValue('1000000000000000000', 18, 25.42);
// → "25.42"

Use cases

Swap UI

Show USD values next to token amounts so users know the dollar value of their swap.

Portfolio tracker

Display wallet holdings in USD by multiplying token balances by their current prices.

Price alerts

Poll prices and trigger notifications when a token crosses a threshold.

Analytics

Track token price movements over time for dashboards and reporting.
Prices are derived from real DEX pool reserves across all indexed markets on HyperEVM. They reflect actual on-chain liquidity, not centralized exchange prices.