Callstatic API para Pumpfun
Callstatic API para Pumpfun
2. Sell Transaction
Create a sell transaction using percentage:
const sellRequest = {
signer: "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
transactionType: "Sell",
mint: "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
amount: "50%", // Sell 50% of holdings
slippage: 3.5, // 3.5% slippage
priorityFee: 1000, // 1000 mLamports
};
Complete Implementation
• TypeScript
import {
Connection,
VersionedTransaction,
VersionedMessage,
Keypair
} from '@solana/web3.js';
import bs58 from 'bs58';
class PumpFunTradeClient {
private connection: Connection;
private apiKey: string;
async createTradeTransaction(
signer: string,
transactionType: 'Buy' | 'Sell',
mint: string,
amount: string,
slippage: number,
priorityFee: number
) {
const response = await fetch(
'https://api.callstaticrpc.com/pumpfun/v1/transactions/getInstruction',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`
},
body: JSON.stringify({
signer,
transactionType,
mint,
amount,
slippage,
priorityFee
})
}
);
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
}
Error Handling
The API returns standard error messages:
try {
const transaction = await client.createTradeTransaction(/* params */);
} catch (error) {
if (error.message.includes('Authentication')) {
console.error('Invalid API key');
} else if (error.message.includes('Invalid parameters')) {
console.error('Invalid transaction parameters');
} else {
console.error('Unknown error:', error);
}
}
Best Practices
1. Transaction Safety
o Always verify transaction contents before signing
o Use appropriate slippage for market conditions
o Monitor transaction status after sending
2. Error Management
o Implement proper error handling
o Use try-catch blocks consistently
o Handle network errors gracefully
3. Security
o Never expose private keys
o Store API keys securely
o Use environment variables for sensitive data
Next Steps
Now that you understand how to create trade transactions, you can:
1. 🚀 Build a trading interface
2. 📊 Implement automated trading strategies
3. ⚡ Create a trading bot
4. 🔄 Monitor transaction status
// Add metadata
formData.append("name", name);
formData.append("symbol", symbol);
formData.append("description", description);
formData.append("showName", "true");
if (!response.ok) {
throw new Error(`Failed to upload metadata: ${response.statusText}`);
}
class PumpFunTokenCreator {
private apiKey: string;
private connection: Connection;
async deployToken(
signerKeypair: Keypair,
name: string,
symbol: string,
description: string,
imagePath: string,
socials: {
twitter?: string,
telegram?: string,
website?: string
} = {},
initialLiquidityLamports: string = "0",
slippage: number = 1.5,
priorityFeeMicroLamports: number = 1000
) {
// Create mint keypair
const mintKeypair = Keypair.generate();
'https://api.callstaticrpc.com/pumpfun/v1/transactions/getCreateInstruction',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`
},
body: JSON.stringify({
signer: signerKeypair.publicKey.toString(),
tokenMetadata: {
name,
symbol,
uri: metadataResponse.metadataUri
},
mint: mintKeypair.publicKey.toString(),
amount: initialLiquidityLamports,
slippage,
priorityFee: priorityFeeMicroLamports
})
}
);
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
transaction.sign([signerKeypair]);
return {
signature,
mint: mintKeypair.publicKey.toString(),
metadataUri: metadataResponse.metadataUri
};
}
console.log(`Transaction: https://solscan.io/tx/${result.signature}`);
console.log(`Token Mint: ${result.mint}`);
console.log(`Metadata URI: ${result.metadataUri}`);
Best Practices
1. Metadata Preparation
o Use high-quality images
o Provide comprehensive token descriptions
o Include relevant social links
o Verify metadata before deployment
2. Token Deployment
o Store mint address and metadata URI
o Monitor transaction status
o Implement proper error handling
o Consider initial liquidity carefully
3. Security
o Never share private keys
o Store API keys securely
o Validate all input data
o Use environment variables for sensitive data
Next Steps
Now that you understand the complete token creation process, you can:
1. 🚀 Prepare token metadata
2. 📊 Deploy your token
3. 💧 Add initial liquidity
4. 🔄 Monitor token performance
Base URL
https://api.callstaticrpc.com/pumpfun/v1
Data Structure
The API returns detailed information about token deployments:
• Response Structure
{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"deployer": "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
"deploy_timestamp": 1679616000000,
"mint": "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
"name": "Sample Token",
"symbol": "SMPL",
"decimals": 9,
"initial_supply": 1000000000000,
"total_supply": 1000000000000,
"description": "A sample token deployment",
"mint_authority": "AaA9aA3aA6aA2aA8aA4aA7aAa1aA5aA9aA3aA6aA2a",
"freeze_authority": "AaA7aA1aA4aA8aA2aA6aA9aAa3aA7aA1aA4aA8aA5a",
"twitter": "@sample_token",
"telegram": "t.me/sample_token",
"website": "https://sample-token.com",
"uri": "https://arweave.net/sample-token-metadata",
"image_uri": "https://arweave.net/sample-token-image",
"is_complete": true,
"complete_timestamp": 1679616100000
}
],
"has_more": false,
"total": 1
}
• TypeScript
• JavaScript
• Python
import axios from 'axios';
interface TokenDeployment {
id: string;
deployer: string;
deploy_timestamp: number;
mint: string;
name: string;
symbol: string;
decimals: number;
initial_supply: number;
total_supply: number;
description: string;
mint_authority: string;
freeze_authority: string;
twitter?: string;
telegram?: string;
website?: string;
uri: string;
image_uri: string;
is_complete: boolean;
complete_timestamp?: number;
}
interface PaginatedResponse {
success: boolean;
data: TokenDeployment[];
has_more: boolean;
total: number;
}
class TokenHistoricalClient {
private readonly baseUrl = 'https://api.callstaticrpc.com/pumpfun/v1';
async getWalletDeployments(params: {
wallet: string;
limit?: number;
offset?: number;
}): Promise<PaginatedResponse> {
const response = await axios.get(`${this.baseUrl}/historical/deployments`,
{
headers: {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
params: {
wallet: params.wallet,
limit: params.limit,
offset: params.offset
}
});
return response.data;
}
while (true) {
const response = await this.getWalletDeployments({
wallet,
limit,
offset
});
if (!response.has_more) break;
offset += limit;
}
return allDeployments;
}
return {
totalDeployments: deployments.length,
deploymentsByMonth: monthlyDeployments,
firstDeployment: new Date(Math.min(...deployments.map(d =>
d.deploy_timestamp))),
lastDeployment: new Date(Math.max(...deployments.map(d =>
d.deploy_timestamp))),
completionRate: deployments.filter(d => d.is_complete).length /
deployments.length
};
}
• TypeScript
async function analyzeSocialPresence(wallet: string) {
const client = new TokenHistoricalClient('your-api-key');
const deployments = await client.getAllDeployments(wallet);
return {
totalTokens: deployments.length,
withTwitter: deployments.filter(d => d.twitter).length,
withTelegram: deployments.filter(d => d.telegram).length,
withWebsite: deployments.filter(d => d.website).length,
withAllSocial: deployments.filter(d =>
d.twitter && d.telegram && d.website
).length,
socialUrls: deployments.map(d => ({
name: d.name,
twitter: d.twitter,
telegram: d.telegram,
website: d.website
}))
};
}
Error Handling
The API returns standard HTTP status codes:
Status Code Description
200 Successful response
400 Bad request
401 Unauthorized - Invalid or missing bearer token
500 Internal server error
Best Practices
1. Implement Pagination
o Use the limit and offset parameters for large datasets
o Default to reasonable page sizes (e.g., 100 records)
o Handle the has_more flag to determine if more data is available
2. Error Handling
try {
const deployments = await client.getWalletDeployments({
wallet: "AaA2...",
});
} catch (error) {
if (error.response?.status === 401) {
console.error("Invalid API key");
} else if (error.response?.status === 400) {
console.error("Invalid parameters");
}
}
Next Steps
Now that you understand how to analyze historical token deployment data, you can:
1. 📊 Build deployment analytics dashboards
2. 🔍 Track wallet deployment patterns
3. 📈 Create token metadata analysis tools
4. Monitor social media presence
interface MarketDataResponse {
success: boolean;
data: TokenMarketData;
}
Implementation Example
• TypeScript
• Python
class PumpFunMarketDataClient {
private apiKey: string;
constructor(apiKey: string) {
this.apiKey = apiKey;
}
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
return result.data;
}
monitor();
return () => { isRunning = false; };
}
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
• TypeScript
• Python
const client = new PumpFunMarketDataClient('YOUR_API_KEY');
try {
const data = await client.getTokenMarketData('TOKEN_MINT_ADDRESS');
Best Practices
1. Rate Limiting
o Respect API rate limits
o Use appropriate monitoring intervals
o Implement exponential backoff for errors
2. Data Processing
o Handle string-to-number conversions carefully
o Validate data before processing
o Store historical data if needed
3. Error Handling
o Implement proper error callbacks
o Handle network issues gracefully
o Log errors appropriately
Common Use Cases
1. Price Alerts
o Monitor significant price changes
o Track price thresholds
o Set up notification systems
2. Market Analysis
o Track market cap changes
o Monitor bonding curve progress
o Analyze price trends
3. Trading Automation
o Trigger trades based on price movements
o Monitor liquidity levels
o 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
Base URL
https://api.callstaticrpc.com/pumpfun/v1
Data Structure
The API returns detailed metadata about token deployments:
• Response Structure
{
"success": true,
"data": {
"id": "dep_123456789",
"deployer": "AaA9aA3aA6aA2aA8aA4aA7aAa1aA5aA9aA3aA6aA2a",
"deploy_timestamp": 1679529600000,
"mint": "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
"name": "Sample Token",
"symbol": "SMPL",
"decimals": 9,
"initial_supply": 1000000000000,
"total_supply": 1000000000000, // Always 1 billion (1,000,000,000) tokens
"description": "A sample token for demonstration purposes",
"mint_authority": "AaA9aA3aA6aA2aA8aA4aA7aAa1aA5aA9aA3aA6aA2a",
"freeze_authority": "AaA7aA1aA4aA8aA2aA6aA9aAa3aA7aA1aA4aA8aA5a",
"twitter": "@sampletoken",
"telegram": "https://t.me/sampletoken",
"website": "https://sampletoken.com",
"uri": "https://arweave.net/abc123",
"image_uri": "https://arweave.net/xyz789",
"is_complete": true, // Indicates bonding curve filled and Raydium
deployment
"complete_timestamp": 1679529605000 // When Raydium deployment completed
}
}
• TypeScript
• Python
import axios from 'axios';
interface TokenMetadata {
id: string;
deployer: string;
deploy_timestamp: number;
mint: string;
name: string;
symbol: string;
decimals: number;
initial_supply: number; // Always 1 billion
total_supply: number; // Always 1 billion
description: string;
mint_authority: string;
freeze_authority: string;
twitter?: string;
telegram?: string;
website?: string;
uri: string;
image_uri: string;
is_complete: boolean; // Bonding curve and Raydium status
complete_timestamp?: number;
}
interface MetadataResponse {
success: boolean;
data: TokenMetadata;
}
class TokenMetadataClient {
private readonly baseUrl = 'https://api.callstaticrpc.com/pumpfun/v1';
return response.data;
}
Error Handling
The API returns standard HTTP status codes:
Status Code Description
200 Successful response
400 Bad request
401 Unauthorized - Invalid or missing bearer token
500 Internal server error
Base URL
https://api.callstaticrpc.com/pumpfun/v1
Data Structure
The API returns volume data with multiple time windows:
• Response Structure
{
"success": true,
"data": {
"token": "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
"name": "Sample Token",
"symbol": "STKN",
// Short-term volumes
"buy_volume_1m": "1000000000", // 1 SOL in buys last minute
"buy_volume_5m": "5000000000",
"buy_volume_15m": "15000000000",
"buy_volume_30m": "30000000000",
// Medium-term volumes
"buy_volume_1h": "60000000000",
"buy_volume_4h": "240000000000",
// Long-term volumes
"buy_volume_24h": "1440000000000",
"buy_volume_1w": "10080000000000",
// Sell volumes follow same pattern
"sell_volume_1m": "900000000",
"sell_volume_5m": "4500000000",
"sell_volume_15m": "13500000000",
"sell_volume_30m": "27000000000",
"sell_volume_1h": "54000000000",
"sell_volume_4h": "216000000000",
"sell_volume_24h": "1296000000000",
"sell_volume_1w": "9072000000000",
// Last trade timestamps
"last_buy_timestamp": 1679529600000,
"last_sell_timestamp": 1679529600000
}
}
Implementation
Here's how to implement volume analysis in your application:
• TypeScript
• Python
import axios from 'axios';
interface TokenVolume {
token: string;
name: string;
symbol: string;
buy_volume_1m: string;
buy_volume_5m: string;
buy_volume_15m: string;
buy_volume_30m: string;
buy_volume_1h: string;
buy_volume_4h: string;
buy_volume_24h: string;
buy_volume_1w: string;
sell_volume_1m: string;
sell_volume_5m: string;
sell_volume_15m: string;
sell_volume_30m: string;
sell_volume_1h: string;
sell_volume_4h: string;
sell_volume_24h: string;
sell_volume_1w: string;
last_buy_timestamp: number;
last_sell_timestamp: number;
}
class VolumeAnalyzer {
private readonly LAMPORTS_PER_SOL = 1_000_000_000;
return {
momentum: avgTrend > 0.1 ? 'increasing' :
avgTrend < -0.1 ? 'decreasing' : 'stable',
strength: Math.abs(avgTrend)
};
}
Analysis Techniques
1. Volume Ratios
Compare buy and sell volumes to identify trading patterns:
• Buy/Sell ratio > 1: More buying pressure
• Buy/Sell ratio < 1: More selling pressure
• Track ratios across timeframes to spot trends
2. Volume Deltas
Calculate volume changes between timeframes:
• Short-term: 5m vs 1h (normalized)
• Medium-term: 1h vs 4h (normalized)
• Long-term: 4h vs 24h (normalized)
3. Volume Momentum
Analyze volume trends to determine market momentum:
• Increasing: Higher recent volume
• Decreasing: Lower recent volume
• Stable: Consistent volume
4. Trade Timing
Monitor time since last trades:
• Recent trades indicate active trading
• Long gaps may indicate low liquidity
• Compare buy vs sell timing patterns
Error Handling
The API returns standard HTTP status codes:
Status Code Description
200 Successful response
400 Bad request
401 Unauthorized - Invalid or missing bearer token
500 Internal server error
Base URL
https://api.callstaticrpc.com/pumpfun/v1
Data Structure
The API returns detailed information about wallet trades:
• Response Structure
{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"hash": "CcC5cC2cC8cC1cC7cC3cC9cC4cC6cC2cC8cC5cC1cC7cC4c",
"timestamp": 1679616000000,
"sol_amount": 1000000000,
"token_amount": 50000000000,
"token": "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
"price": 0.02,
"dex": 1,
"buyer": "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
"virtual_sol_reserves": 100000000000,
"virtual_token_reserves": 5000000000000,
"real_sol_reserves": 98000000000,
"real_token_reserves": 5100000000000,
"is_buy": true
}
],
"has_more": false,
"total": 1
}
• TypeScript
• Python
import axios from 'axios';
interface Trade {
id: string;
hash: string;
timestamp: number;
sol_amount: number;
token_amount: number;
token: string;
price: number;
dex: 1 | 2; // 1 for PumpFun, 2 for Raydium
buyer: string;
virtual_sol_reserves: number;
virtual_token_reserves: number;
real_sol_reserves: number;
real_token_reserves: number;
is_buy: boolean;
}
interface PaginatedResponse {
success: boolean;
data: Trade[];
has_more: boolean;
total: number;
}
class WalletTradesClient {
private readonly baseUrl = 'https://api.callstaticrpc.com/pumpfun/v1';
async getWalletTrades(params: {
wallet: string;
limit?: number;
offset?: number;
}): Promise<PaginatedResponse> {
const response = await
axios.get(`${this.baseUrl}/historical/trades/byWallet`, {
headers: {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
params
});
return response.data;
}
while (true) {
const response = await this.getWalletTrades({
wallet,
limit,
offset
});
if (!response.has_more) break;
offset += limit;
}
return allTrades;
}
Analysis Examples
Here are some common analysis scenarios using the wallet trades data:
• TypeScript
async function analyzeWalletActivity(wallet: string) {
const client = new WalletTradesClient('your-api-key');
const trades = await client.getAllWalletTrades(wallet);
return {
totalTrades: trades.length,
totalVolume: trades.reduce((sum, trade) => sum + trade.sol_amount, 0),
tokenInteractions: new Set(trades.map(t => t.token)).size,
tradingFrequency: {
buys: trades.filter(t => t.is_buy).length,
sells: trades.filter(t => !t.is_buy).length
},
dexUsage: {
pumpfun: trades.filter(t => t.dex === 1).length,
raydium: trades.filter(t => t.dex === 2).length
}
};
}
acc[trade.token].totalVolume += trade.sol_amount;
acc[trade.token].tradeCount++;
acc[trade.token].avgPrice =
(acc[trade.token].avgPrice * (acc[trade.token].tradeCount - 1) +
trade.price)
/ acc[trade.token].tradeCount;
return acc;
}, {});
return tokenStats;
Error Handling
The API returns standard HTTP status codes:
Status Code Description
200 Successful response
400 Bad request
401 Unauthorized - Invalid or missing bearer token
500 Internal server error
Best Practices
1. Implement Pagination
o Use the limit and offset parameters for large datasets
o Default to reasonable page sizes (e.g., 100 records)
o Handle the has_more flag to determine if more data is available
2. Error Handling
try {
const trades = await client.getWalletTrades({
wallet: "AaA2...",
});
} catch (error) {
if (error.response?.status === 401) {
console.error("Invalid API key");
} else if (error.response?.status === 400) {
console.error("Invalid parameters");
}
}
3. Rate Limiting
o Implement exponential backoff for retry logic
o Monitor your API usage through the dashboard
o Consider caching frequently accessed data
Next Steps
Now that you understand how to analyze wallet trading data, you can:
1. 📊 Build wallet activity dashboards
2. 🔍 Track trading patterns and preferences
3. 📈 Monitor trading frequency and volume
4. Analyze token interactions
Base URL
https://api.callstaticrpc.com/pumpfun/v1
Data Structure
The API returns detailed information about token trades:
• Response Structure
{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"hash": "CcC5cC2cC8cC1cC7cC3cC9cC4cC6cC2cC8cC5cC1cC7cC4c",
"timestamp": 1679616000000,
"sol_amount": 1000000000,
"token_amount": 50000000000,
"token": "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB",
"price": 0.02,
"dex": 1,
"buyer": "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
"virtual_sol_reserves": 100000000000,
"virtual_token_reserves": 5000000000000,
"real_sol_reserves": 98000000000,
"real_token_reserves": 5100000000000,
"is_buy": true
}
],
"has_more": false,
"total": 1
}
• TypeScript
• Python
import axios from 'axios';
interface Trade {
id: string;
hash: string;
timestamp: number;
sol_amount: number;
token_amount: number;
token: string;
price: number;
dex: 1 | 2; // 1 for PumpFun, 2 for Raydium
buyer: string;
virtual_sol_reserves: number;
virtual_token_reserves: number;
real_sol_reserves: number;
real_token_reserves: number;
is_buy: boolean;
}
interface PaginatedResponse {
success: boolean;
data: Trade[];
has_more: boolean;
total: number;
}
class TokenTradesClient {
private readonly baseUrl = 'https://api.callstaticrpc.com/pumpfun/v1';
async getTokenTrades(params: {
token: string;
limit?: number;
offset?: number;
}): Promise<PaginatedResponse> {
const response = await
axios.get(`${this.baseUrl}/historical/trades/byToken`, {
headers: {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
params
});
return response.data;
}
while (true) {
const response = await this.getTokenTrades({
token,
limit,
offset
});
if (!response.has_more) break;
offset += limit;
}
return allTrades;
}
}
Analysis Examples
Here are some common analysis scenarios using the historical trades data:
• TypeScript
async function analyzePriceMovement(token: string) {
const client = new TokenTradesClient('your-api-key');
const trades = await client.getAllTokenTrades(token);
return {
totalTrades: trades.length,
volumeInSol: trades.reduce((sum, trade) => sum + trade.sol_amount, 0),
averagePrice: trades.reduce((sum, trade) => sum + trade.price, 0) /
trades.length,
priceRange: {
min: Math.min(...trades.map(t => t.price)),
max: Math.max(...trades.map(t => t.price))
},
buyCount: trades.filter(t => t.is_buy).length,
sellCount: trades.filter(t => !t.is_buy).length
};
}
Error Handling
The API returns standard HTTP status codes:
Status Code Description
200 Successful response
400 Bad request
401 Unauthorized - Invalid or missing bearer token
500 Internal server error
Best Practices
1. Implement Pagination
o Use the limit and offset parameters for large datasets
o Default to reasonable page sizes (e.g., 100 records)
o Handle the has_more flag to determine if more data is available
2. Error Handling
try {
const trades = await client.getTokenTrades({
token: "BbB3...",
});
} catch (error) {
if (error.response?.status === 401) {
console.error("Invalid API key");
} else if (error.response?.status === 400) {
console.error("Invalid parameters");
}
}
3. Rate Limiting
o Implement exponential backoff for retry logic
o Monitor your API usage through the dashboard
o Consider caching frequently accessed data
Next Steps
Now that you understand how to analyze historical token trading data, you can:
1. 📊 Build trading analytics dashboards
2. 🔍 Track price movements and volatility
3. 📈 Monitor liquidity changes
4. Analyze trading patterns
2. Deployer Filter
Monitor deployments from specific wallets:
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
deployer: "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
},
},
};
3. Name Filter
Track tokens by name pattern:
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
name: "AI", // Will match tokens containing "AI"
},
},
};
4. Symbol Filter
Monitor specific token symbols:
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
symbol: "BTC", // Will match tokens with "BTC" in symbol
},
},
};
Combining Filters
You can combine multiple active filters for more precise monitoring:
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
name: "Bitcoin",
symbol: "BTC",
deployer: "AaA2aA5aA8aA4aA7aA1aA9aAa3aA6aA2aA8aA5aA1a",
},
},
};
constructor(apiKey: string) {
this.ws = new WebSocket('wss://api.callstaticrpc.com/pumpfun/v1/streams', {
headers: { Authorization: `Bearer ${apiKey}` }
});
this.setupEventHandlers();
}
private setupEventHandlers() {
this.ws.on('open', () => {
console.log('Connected! Monitoring tokens...');
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
name: "Bitcoin",
symbol: "BTC"
}
}
};
this.ws.send(JSON.stringify(subscribeMessage));
});
if (message.data.twitter) {
console.log(`Twitter: ${message.data.twitter}`);
}
if (message.data.telegram) {
console.log(`Telegram: ${message.data.telegram}`);
}
if (message.data.website) {
console.log(`Website: ${message.data.website}`);
}
}
} catch (error) {
console.error('Error processing message:', error);
}
});
Error Handling
The WebSocket API returns standard error messages:
try {
ws.send(JSON.stringify(subscribeMessage));
} catch (error) {
if (error.message.includes('Authentication')) {
console.error('Invalid API key');
} else if (error.message.includes('Invalid filter')) {
console.error('Invalid filter parameters');
} else {
console.error('Unknown error:', error);
}
}
Best Practices
1. Filter Precision
o Use specific filters to reduce noise
o Combine filters for better accuracy
o Regularly review and update filters
2. Connection Management
o Implement reconnection logic
o Handle connection errors gracefully
o Monitor connection health
3. Data Processing
o Validate incoming messages
o Handle missing fields gracefully
o Log relevant information
Upcoming Features
Future Enhancements
The following filters are coming soon:
1. Count Filter
o Track similar token launches in short timeframes
o Useful for detecting trending token patterns
2. Narrative Filter
o Filter tokens by theme or category
o Match token metadata against specific narratives
3. Tweet Filter
o Monitor tokens related to specific tweets
o Filter by tweet URL instead of content
Next Steps
Now that you understand token event filtering, you can:
1. 🔍 Set up basic token monitoring
2. 📊 Track specific deployer activity
3. 🎯 Monitor tokens by name or symbol
4. ⚡ Implement real-time alerts