Skip to content

internet-court/internet-court-skill / vendored/sendaifun/birdeye

birdeye

Verified

Complete Birdeye API integration for real-time DeFi data across Solana and 15 other chains. Use for token prices, OHLCV charts, market discovery, on-chain trader intelligence, holder analysis, wallet portfolio & P&L, and WebSocket streams for live prices and whale alerts.

examples/pair-data/pair-overview.ts

View on GitHub
/**
 * Pair Overview — Birdeye /defi/v2/markets + /defi/v3/pair/overview/single
 * Finds the best liquidity pool for a token and then fetches pair stats.
 *
 * Run: BIRDEYE_API_KEY=xxx npx ts-node examples/pair-data/pair-overview.ts
 */

import { BirdeyeClient } from '../../templates/birdeye-client';

async function run() {
    const apiKey = process.env.BIRDEYE_API_KEY;
    if (!apiKey) { console.error('Set BIRDEYE_API_KEY env var.'); process.exit(1); }

    const client = BirdeyeClient.createWithConfig({ apiKey, chain: 'solana' });
    const tokenAddress = process.env.TOKEN_ADDRESS || 'So11111111111111111111111111111111111111112';

    console.log(`Finding top market for ${tokenAddress}...`);

    try {
        // Step 1: Get all markets (pairs) for this token
        const marketsData = await client.market.getMarkets(tokenAddress);
        const markets = marketsData?.items ?? (Array.isArray(marketsData) ? marketsData : []);

        if (markets.length === 0) {
            console.log('No markets found for this token.');
            return;
        }

        // Step 2: Pick the top-liquidity pair
        const topMarket = markets.sort((a: any, b: any) => (b.liquidity || 0) - (a.liquidity || 0))[0];
        const pairAddress = topMarket.address;

        console.log(`\nTop Market:`);
        console.log(`  Pair address: ${pairAddress}`);
        console.log(`  Source:       ${topMarket.source || topMarket.name || 'Unknown AMM'}`);
        console.log(`  Liquidity:    $${(topMarket.liquidity || 0).toLocaleString()}`);

        // Step 3: Fetch detailed pair overview
        // /defi/v3/pair/overview/single returns snake_case fields:
        // base.symbol, quote.symbol, price, liquidity, volume_24h, trade_24h
        const pair = await client.market.getPairOverview(pairAddress);

        console.log(`\nPair Stats:`);
        console.log(`  Name:       ${pair.name}`);
        console.log(`  Base:       ${pair.base?.symbol} / ${pair.quote?.symbol}`);
        console.log(`  Source:     ${pair.source}`);
        console.log(`  Price:      $${pair.price?.toFixed(6)}`);
        console.log(`  Liquidity:  $${pair.liquidity?.toLocaleString()}`);
        console.log(`  Vol 24h:    $${pair.volume_24h?.toLocaleString()}`);
        console.log(`  Trade 24h:  ${pair.trade_24h?.toLocaleString()}`);

    } catch (e: any) {
        console.error('[Error]', e.message);
    }
}

run();
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall