Skip to main content

Market Data Guide

What you'll learn
  • How to fetch token market data
  • Track price and market cap information
  • Monitor bonding curve progress
  • Implement real-time price tracking

Introduction

This guide explains how to retrieve and monitor token market data from Pump.Fun using the Market Data API. You can track prices, market caps, and bonding progress for any token.

Access Requirements

Market Data Structure

interface TokenMarketData {
price_usd: string; // Current USD price
price_sol: string; // Current SOL price
current_market_cap: string; // Current market capitalization
bonding_market_cap: string; // Total bonding curve market cap
bonding_progress: number; // Progress as decimal (0-1)
}

interface MarketDataResponse {
success: boolean;
data: TokenMarketData;
}

Implementation Example

class PumpFunMarketDataClient {
private apiKey: string;

constructor(apiKey: string) {
this.apiKey = apiKey;
}

async getTokenMarketData(tokenMint: string): Promise<TokenMarketData> {
const response = await fetch(
`https://api.callstaticrpc.com/pumpfun/v1/token/marketData?token=${tokenMint}`,
{
headers: {
'Authorization': `Bearer ${this.apiKey}`
}
}
);

if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}

const result = await response.json();
if (!result.success || !result.data) {
throw new Error('Failed to fetch market data');
}

return result.data;
}

// Real-time price monitoring
async monitorTokenPrice(
tokenMint: string,
callback: (data: TokenMarketData) => void,
interval: number = 60000, // Default 1 minute
errorCallback?: (error: Error) => void
): Promise<() => void> {
let isRunning = true;

const monitor = async () => {
while (isRunning) {
try {
const data = await this.getTokenMarketData(tokenMint);
callback(data);
await new Promise(resolve => setTimeout(resolve, interval));
} catch (error) {
if (errorCallback) {
errorCallback(error as Error);
}
await new Promise(resolve => setTimeout(resolve, interval));
}
}
};

monitor();
return () => { isRunning = false; };
}

// Price change monitoring
async monitorPriceChanges(
tokenMint: string,
threshold: number, // Percentage change threshold
callback: (change: number, data: TokenMarketData) => void,
interval: number = 60000
): Promise<() => void> {
let lastPrice: number | null = null;

return this.monitorTokenPrice(
tokenMint,
(data) => {
const currentPrice = parseFloat(data.price_usd);
if (lastPrice !== null) {
const changePercent = ((currentPrice - lastPrice) / lastPrice) * 100;
if (Math.abs(changePercent) >= threshold) {
callback(changePercent, data);
}
}
lastPrice = currentPrice;
},
interval
);
}
}

Usage Examples

Basic Market Data Fetch

const client = new PumpFunMarketDataClient('YOUR_API_KEY');

try {
const data = await client.getTokenMarketData('TOKEN_MINT_ADDRESS');

console.log('Token Market Data:');
console.log(`Price (USD): $${data.price_usd}`);
console.log(`Price (SOL): ${data.price_sol} SOL`);
console.log(`Market Cap: $${data.current_market_cap}`);
console.log(`Bonding Progress: ${data.bonding_progress * 100}%`);
} catch (error) {
console.error('Error fetching market data:', error);
}

Real-Time Price Monitoring

const client = new PumpFunMarketDataClient('YOUR_API_KEY');

// Monitor price with 5% change threshold
const stopMonitoring = await client.monitorPriceChanges(
'TOKEN_MINT_ADDRESS',
5.0, // 5% threshold
(changePercent, data) => {
console.log(`Price changed by ${changePercent.toFixed(2)}%`);
console.log(`New price: $${data.price_usd}`);
},
30000 // Check every 30 seconds
);

// Stop monitoring after 1 hour
setTimeout(stopMonitoring, 3600000);

Bonding Progress Monitoring

const client = new PumpFunMarketDataClient('YOUR_API_KEY');

const stopMonitoring = await client.monitorTokenPrice(
'TOKEN_MINT_ADDRESS',
(data) => {
if (data.bonding_progress >= 95) { // 95% complete
console.log('Bonding curve near completion!');
console.log(`Progress: ${(data.bonding_progress).toFixed(2)}%`);
console.log(`Current Market Cap: $${data.current_market_cap}`);
}
},
60000 // Check every minute
);

Best Practices

  1. Rate Limiting

    • Respect API rate limits
    • Use appropriate monitoring intervals
    • Implement exponential backoff for errors
  2. Data Processing

    • Handle string-to-number conversions carefully
    • Validate data before processing
    • Store historical data if needed
  3. Error Handling

    • Implement proper error callbacks
    • Handle network issues gracefully
    • Log errors appropriately

Common Use Cases

  1. Price Alerts

    • Monitor significant price changes
    • Track price thresholds
    • Set up notification systems
  2. Market Analysis

    • Track market cap changes
    • Monitor bonding curve progress
    • Analyze price trends
  3. Trading Automation

    • Trigger trades based on price movements
    • Monitor liquidity levels
    • Track market conditions

Next Steps

Now that you understand market data monitoring, you can:

  1. 📊 Set up price alerts
  2. 📈 Track market trends
  3. 🤖 Build trading bots
  4. 📉 Monitor multiple tokens
Need Help?

For additional support: