Skip to main content
This page contains practical examples for common use cases with the SolixDB API. Use these examples to build trading bots, analytics dashboards, ML models, and more.

Common Use Cases

Trading Bot Backtesting

Test strategies against historical DEX trades with prices and volumes.

Analytics Dashboards

Monitor protocol performance, volumes, and trends in real-time.

ML Model Training

Export clean datasets for training price prediction and rug pull detection models.

Failed Transaction Analysis

Analyze failed transactions to identify patterns and errors.

JSON-RPC Examples

Get Recent Transactions

Query recent transactions from a specific protocol:
curl -X POST "https://api.solixdb.xyz/v1/rpc" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTransactions",
    "params": [{
      "limit": 10,
      "filters": {
        "protocols": ["jupiter_v6"]
      }
    }]
  }'

Get Transactions for Address

Query transactions for a specific Solana address with filters:
curl -X POST "https://api.solixdb.xyz/v1/rpc" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTransactionsForAddress",
    "params": [
      "YOUR_ADDRESS_HERE",
      {
        "transactionDetails": "full",
        "sortOrder": "asc",
        "limit": 100,
        "filters": {
          "blockTime": {
            "gte": 1735689600,
            "lte": 1738368000
          },
          "status": "succeeded",
          "protocols": ["jupiter_v6"]
        }
      }
    ]
  }'

Get Transaction by Signature

Look up a specific transaction:
curl -X POST "https://api.solixdb.xyz/v1/rpc" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTransaction",
    "params": ["5VERv8NMxzbPDohNpJhHopN2C9R4G5GaPevYf5hLJ8Z7"]
  }'

SQL Query Examples

Basic Query

Simple SELECT query with automatic LIMIT:
curl -X POST "https://api.solixdb.xyz/v1/query" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "query": "SELECT signature, protocol_name, fee FROM transactions WHERE protocol_name = '\''jupiter_v6'\''",
    "format": "json"
  }'
Note: This query will automatically get LIMIT 1000 appended if you don’t specify one.

Protocol Statistics

Get comprehensive statistics for protocols:
SELECT 
  protocol_name,
  COUNT(*) as total_transactions,
  SUM(fee) as total_fees,
  AVG(fee) as avg_fee,
  MIN(fee) as min_fee,
  MAX(fee) as max_fee,
  AVG(compute_units) as avg_compute_units
FROM transactions
WHERE date >= '2025-01-01'
  AND date <= '2025-01-31'
  AND protocol_name IN ('jupiter_v6', 'pump_fun', 'raydium_amm_v3')
GROUP BY protocol_name
ORDER BY total_transactions DESC

Fee Analysis by Day of Week

Analyze fees by day of week to identify patterns:
SELECT 
  toDayOfWeek(date) as day_of_week,
  COUNT(*) as count,
  AVG(fee) as avg_fee,
  quantile(0.95)(fee) as p95_fee,
  quantile(0.99)(fee) as p99_fee
FROM transactions
WHERE protocol_name = 'jupiter_v6'
  AND date >= '2025-01-01'
  AND date <= '2025-01-31'
GROUP BY day_of_week
ORDER BY avg_fee DESC

Hourly Protocol Comparison

Compare multiple protocols by hour:
SELECT 
  protocol_name,
  toHour(toDateTime(block_time)) as hour,
  COUNT(*) as count,
  AVG(fee) as avg_fee
FROM transactions
WHERE protocol_name IN ('jupiter_v6', 'raydium_amm_v3', 'pump_fun')
  AND date >= '2025-01-01'
  AND date <= '2025-01-31'
GROUP BY protocol_name, hour
ORDER BY protocol_name, hour

Failed Transactions Analysis

Analyze failed transactions to identify error patterns:
SELECT 
  protocol_name,
  COUNT(*) as failed_count,
  COUNT(*) * 100.0 / (SELECT COUNT(*) FROM transactions WHERE protocol_name = t.protocol_name) as failure_rate
FROM transactions t
WHERE success = 0
  AND date >= '2025-01-01'
  AND date <= '2025-01-31'
GROUP BY protocol_name
ORDER BY failed_count DESC

Export to CSV

Export query results to CSV format:
curl -X POST "https://api.solixdb.xyz/v1/query" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "query": "SELECT signature, protocol_name, fee FROM transactions WHERE protocol_name = '\''jupiter_v6'\''",
    "format": "csv"
  }' > results.csv

Real-World Use Cases

Trading Bot: Get Recent Swaps

async function getRecentSwaps(protocol, limit = 100) {
  const response = await fetch('https://api.solixdb.xyz/v1/rpc', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.SOLIXDB_API_KEY
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 1,
      method: 'getTransactions',
      params: [{
        limit,
        filters: {
          protocols: [protocol],
          status: 'succeeded'
        }
      }]
    })
  });

  const data = await response.json();
  return data.result.data;
}

// Usage
const swaps = await getRecentSwaps('jupiter_v6', 50);
console.log(`Found ${swaps.length} recent swaps`);

Analytics Dashboard: Protocol Performance

async function getProtocolPerformance(startDate, endDate) {
  const response = await fetch('https://api.solixdb.xyz/v1/query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.SOLIXDB_API_KEY
    },
    body: JSON.stringify({
      query: `
        SELECT 
          protocol_name,
          COUNT(*) as tx_count,
          SUM(fee) as total_fees,
          AVG(fee) as avg_fee,
          AVG(compute_units) as avg_cu,
          COUNT(CASE WHEN success = 1 THEN 1 END) * 100.0 / COUNT(*) as success_rate
        FROM transactions
        WHERE date >= '${startDate}'
          AND date <= '${endDate}'
        GROUP BY protocol_name
        ORDER BY tx_count DESC
      `,
      format: 'json'
    })
  });

  const data = await response.json();
  return data.data;
}

// Usage
const performance = await getProtocolPerformance('2025-01-01', '2025-01-31');
console.table(performance);

ML Dataset: Export Training Data

async function exportTrainingData(protocol, startDate, endDate) {
  const response = await fetch('https://api.solixdb.xyz/v1/query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.SOLIXDB_API_KEY
    },
    body: JSON.stringify({
      query: `
        SELECT 
          signature,
          protocol_name,
          fee,
          compute_units,
          accounts_count,
          success,
          toHour(toDateTime(block_time)) as hour,
          toDayOfWeek(date) as day_of_week
        FROM transactions
        WHERE protocol_name = '${protocol}'
          AND date >= '${startDate}'
          AND date <= '${endDate}'
        ORDER BY block_time
      `,
      format: 'csv'
    })
  });

  const csv = await response.text();
  
  // Save to file
  const fs = require('fs');
  fs.writeFileSync(`training_data_${protocol}.csv`, csv);
  console.log(`Exported ${csv.split('\n').length - 1} rows to training_data_${protocol}.csv`);
}

// Usage
await exportTrainingData('jupiter_v6', '2025-01-01', '2025-01-31');

Next Steps