Historical Data Access

Access comprehensive historical blockchain data through our high-performance API. Query historical prices, transactions, and market metrics with millisecond precision for deep market analysis and strategy backtesting.

Price History

Query Price History
import { HexaAI } from '@hexaai/sdk';

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

// Fetch historical price data
async function getPriceHistory() {
  const prices = await hexa.historical.getPrices({
    token: 'SOL',
    vs_currency: 'USDC',
    timeframe: {
      start: '2024-01-01T00:00:00Z',
      end: '2024-01-27T00:00:00Z'
    },
    interval: '1h',  // 1-hour candles
    exchanges: ['all']  // All DEXs
  });
  
  return prices;
}

// Stream real-time with historical context
const priceStream = hexa.historical.streamPrices({
  token: 'SOL',
  vs_currency: 'USDC',
  lookback: '24h',    // Include last 24h of history
  interval: '1m',     // 1-minute updates
  aggregation: {
    type: 'vwap',     // Volume-weighted average price
    exchanges: ['jupiter', 'raydium']
  }
});

priceStream.on('data', (candle) => {
  console.log('New price data:', candle);
});

// Get volume profile
async function getVolumeProfile() {
  const volume = await hexa.historical.getVolumeProfile({
    token: 'SOL',
    timeframe: '7d',    // Last 7 days
    priceRange: {
      min: 80,
      max: 120,
      bins: 20        // Number of price levels
    }
  });
  
  return volume;
}

Transaction History

Query Transaction History
// Get wallet transaction history
async function getWalletHistory(address) {
  const txns = await hexa.historical.getTransactions({
    address: address,
    timeframe: '30d',      // Last 30 days
    options: {
      types: ['swap', 'transfer', 'liquidity'],
      limit: 1000,
      include_metadata: true
    }
  });
  
  return txns;
}

// Analyze DEX interactions
async function analyzeDEXActivity() {
  const activity = await hexa.historical.getDEXActivity({
    dex: 'jupiter',
    timeframe: '24h',
    metrics: [
      'unique_users',
      'transaction_count',
      'volume_by_token'
    ],
    interval: '1h'
  });
  
  return activity;
}

Key Features

Flexible Time Ranges

Query data at any granularity from 1-minute to 1-week intervals, with support for custom time windows and aggregations.

Advanced Analytics

Built-in support for common market metrics including VWAP, liquidity depth analysis, and volume profiling.

Data Export

Export historical data in multiple formats including JSON, CSV, and pandas DataFrames for further analysis.

Real-time Updates

Combine historical data with real-time updates through our WebSocket API for live market analysis.