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
- Valid API key (visit https://app.callstatic.com for tier information)
- Rate limits vary by subscription tier
Market Data Structure
- Market Data Interface
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
- TypeScript
- Python
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
);
}
}
import requests
import time
from typing import Callable, Optional
from dataclasses import dataclass
@dataclass
class TokenMarketData:
price_usd: str
price_sol: str
current_market_cap: str
bonding_market_cap: str
bonding_progress: float
class PumpFunMarketDataClient:
def **init**(self, api_key: str):
self.api_key = api_key
def get_token_market_data(self, token_mint: str) -> TokenMarketData:
response = requests.get(
f"https://api.callstaticrpc.com/pumpfun/v1/token/marketData",
params={"token": token_mint},
headers={"Authorization": f"Bearer {self.api_key}"}
)
if response.status_code != 200:
raise Exception(f"API error: {response.text}")
result = response.json()
if not result["success"] or "data" not in result:
raise Exception("Failed to fetch market data")
return TokenMarketData(**result["data"])
def monitor_token_price(
self,
token_mint: str,
callback: Callable[[TokenMarketData], None],
interval: int = 60, # Default 1 minute
error_callback: Optional[Callable[[Exception], None]] = None
):
is_running = True
def stop_monitoring():
nonlocal is_running
is_running = False
while is_running:
try:
data = self.get_token_market_data(token_mint)
callback(data)
time.sleep(interval)
except Exception as e:
if error_callback:
error_callback(e)
time.sleep(interval)
return stop_monitoring
def monitor_price_changes(
self,
token_mint: str,
threshold: float, # Percentage change threshold
callback: Callable[[float, TokenMarketData], None],
interval: int = 60
):
last_price = None
def price_callback(data: TokenMarketData):
nonlocal last_price
current_price = float(data.price_usd)
if last_price is not None:
change_percent = ((current_price - last_price) / last_price) * 100
if abs(change_percent) >= threshold:
callback(change_percent, data)
last_price = current_price
return self.monitor_token_price(
token_mint,
price_callback,
interval
)
Usage Examples
Basic Market Data Fetch
- TypeScript
- Python
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);
}
client = PumpFunMarketDataClient('YOUR_API_KEY')
try:
data = client.get_token_market_data('TOKEN_MINT_ADDRESS')
print('Token Market Data:')
print(f"Price (USD): ${data.price_usd}")
print(f"Price (SOL): {data.price_sol} SOL")
print(f"Market Cap: ${data.current_market_cap}")
print(f"Bonding Progress: {data.bonding_progress * 100}%")
except Exception as error:
print('Error fetching market data:', error)
Real-Time Price Monitoring
- TypeScript
- Python
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);
client = PumpFunMarketDataClient('YOUR_API_KEY')
# Monitor price with 5% change threshold
def price_change_callback(change_percent: float, data: TokenMarketData):
print(f"Price changed by {change_percent:.2f}%")
print(f"New price: ${data.price_usd}")
stop_monitoring = client.monitor_price_changes(
'TOKEN_MINT_ADDRESS',
5.0, # 5% threshold
price_change_callback,
30 # Check every 30 seconds
)
# Run for 1 hour then stop
time.sleep(3600)
stop_monitoring()
Bonding Progress Monitoring
- TypeScript
- Python
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
);
client = PumpFunMarketDataClient('YOUR_API_KEY')
def bonding_progress_callback(data: TokenMarketData):
if data.bonding_progress >= 95: # 95% complete
print('Bonding curve near completion!')
print(f"Progress: {data.bonding_progress}%")
print(f"Current Market Cap: ${data.current_market_cap}")
stop_monitoring = client.monitor_token_price(
'TOKEN_MINT_ADDRESS',
bonding_progress_callback,
60 # Check every minute
)
Best Practices
-
Rate Limiting
- Respect API rate limits
- Use appropriate monitoring intervals
- Implement exponential backoff for errors
-
Data Processing
- Handle string-to-number conversions carefully
- Validate data before processing
- Store historical data if needed
-
Error Handling
- Implement proper error callbacks
- Handle network issues gracefully
- Log errors appropriately
Common Use Cases
-
Price Alerts
- Monitor significant price changes
- Track price thresholds
- Set up notification systems
-
Market Analysis
- Track market cap changes
- Monitor bonding curve progress
- Analyze price trends
-
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:
- 📊 Set up price alerts
- 📈 Track market trends
- 🤖 Build trading bots
- 📉 Monitor multiple tokens
Need Help?
For additional support:
- Email us at [email protected]
- Visit our Support Portal