Onchain Data Access

Access real-time blockchain data through our high-performance WebSocket API. Monitor prices, track transactions, and analyze wallet activities with sub-second latency across multiple chains.

Real-time Price Feeds

Stream Token Prices
import { HexaAI } from '@hexaai/sdk';

// Initialize the SDK
const hexa = new HexaAI('your_api_key');

// Stream real-time token prices
const priceStream = hexa.onchain.streamPrices({
  tokens: ['SOL', 'BONK', 'JUP'],
  vs_currency: 'USDC',
  options: {
    exchanges: ['all'],     // All DEXs
    frequency: '100ms',     // Update frequency
    depth: true            // Include orderbook depth
  }
});

priceStream.on('update', (price) => {
  console.log('Price update:', price);
  // {
  //   token: 'SOL',
  //   price: '103.45',
  //   timestamp: '2024-01-27T12:34:56.789Z',
  //   exchange: 'jupiter',
  //   depth: {
  //     bids: [...],
  //     asks: [...]
  //   }
  // }
});

// Get aggregated price across DEXs
async function getAggregatedPrice() {
  const price = await hexa.onchain.getTokenPrice({
    token: 'SOL',
    options: {
      aggregation: 'vwap',    // Volume-weighted average
      timeWindow: '5m',       // 5-minute window
      excludeOutliers: true   // Remove anomalies
    }
  });
  
  return price;
}

Transaction Monitoring

Monitor Transactions
// Stream transactions for specific addresses
const txStream = hexa.onchain.streamTransactions({
  addresses: ['wallet1', 'wallet2'],
  options: {
    types: ['swap', 'transfer', 'stake'],
    minAmount: 1000,  // Minimum USDC value
    includeMetadata: true
  }
});

txStream.on('transaction', (tx) => {
  console.log('New transaction:', tx);
});

// Monitor DEX transactions
const dexStream = hexa.onchain.streamDEXActivity({
  dexes: ['jupiter', 'raydium'],
  options: {
    minSize: 10000,    // Min transaction size
    tokens: ['SOL', 'BONK'],
    trackFailures: true
  }
});

dexStream.on('swap', (swap) => {
  console.log('Large swap detected:', swap);
});

// Get transaction details
async function getTxDetails(signature) {
  const tx = await hexa.onchain.getTransaction({
    signature: signature,
    options: {
      includeEvents: true,
      decodeInstructions: true
    }
  });
  
  return tx;
}

Wallet Monitoring

Monitor Wallet Activity
// Stream wallet balance changes
const balanceStream = hexa.onchain.streamBalances({
  wallet: 'address_here',
  tokens: ['SOL', 'USDC', 'BONK'],
  options: {
    trackNFTs: true,
    includeDollarValue: true
  }
});

balanceStream.on('change', (balance) => {
  console.log('Balance update:', balance);
});

// Get detailed wallet portfolio
async function getWalletPortfolio(address) {
  const portfolio = await hexa.onchain.getPortfolio({
    wallet: address,
    options: {
      includeNFTs: true,
      includeStaking: true,
      includeLending: true,
      computeDollarValue: true
    }
  });
  
  return portfolio;
}

Key Features

Real-time Updates

Sub-second WebSocket updates for prices, transactions, and wallet activities across multiple chains.

Cross-DEX Coverage

Comprehensive coverage across all major DEXs with real-time price aggregation and liquidity tracking.

Smart Filtering

Advanced filtering options for transactions and events, with support for custom conditions and thresholds.

Data Reliability

Automatic reconnection, message deduplication, and sequence tracking to ensure no data is missed.