Real-Time Token Event Filtering Guide
What you'll learn
- How to filter token events in real-time
- Implement basic and advanced filtering strategies
- Combine multiple filters effectively
Introduction
This guide explains all available filtering options for token events. You can use these filters across any subscription type (Deployment, Trade, or Completed events).
Access Requirements
- Valid API key (visit https://app.callstatic.com for tier information)
- Rate limits and data access vary by subscription tier
Available Filters
- Filter Interface
interface EventFilters {
// Basic Filters - Currently Active
mint?: string; // Filter by token's mint address
deployer?: string; // Filter by deployer's wallet address
name?: string; // Filter by token name
symbol?: string; // Filter by token symbol
// Advanced Filters - Coming Soon
count?: number; // [UPCOMING] Filter for similar tokens launched in short timeframe
narrative?: string; // [UPCOMING] Filter by token narrative/theme
tweet?: string; // [UPCOMING] Filter by tweet URL
}
Basic Filter Usage
1. Mint Address Filter
Track specific tokens by their mint address:
const subscribeMessage = {
type: "Subscribe",
payload: {
sub_type: "Deployment",
filter: {
mint: "BbB3bB7bB2bB9bB4bB8bB1bBb5bB2bB6bB3bB9bB4bB"
}
}
};
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",
},
},
};
Complete Example Implementation
- TypeScript
import WebSocket from 'ws';
class TokenMonitor {
private ws: WebSocket;
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));
});
this.ws.on('message', (data: string) => {
try {
const message = JSON.parse(data);
if (message.data) {
console.log('\n🔔 Token Deployment Detected!');
console.log(`Name: ${message.data.name}`);
console.log(`Symbol: ${message.data.symbol}`);
console.log(`Deployer: ${message.data.deployer}`);
console.log(`Mint: ${message.data.mint}`);
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);
}
});
this.ws.on('error', (error) => {
console.error('WebSocket error:', error);
});
this.ws.on('close', () => {
console.log('Connection closed. Attempting to reconnect...');
setTimeout(() => this.setupEventHandlers(), 5000);
});
}
}
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
-
Filter Precision
- Use specific filters to reduce noise
- Combine filters for better accuracy
- Regularly review and update filters
-
Connection Management
- Implement reconnection logic
- Handle connection errors gracefully
- Monitor connection health
-
Data Processing
- Validate incoming messages
- Handle missing fields gracefully
- Log relevant information
Upcoming Features
Future Enhancements
The following filters are coming soon:
-
Count Filter
- Track similar token launches in short timeframes
- Useful for detecting trending token patterns
-
Narrative Filter
- Filter tokens by theme or category
- Match token metadata against specific narratives
-
Tweet Filter
- Monitor tokens related to specific tweets
- Filter by tweet URL instead of content
Next Steps
Now that you understand token event filtering, you can:
- 🔍 Set up basic token monitoring
- 📊 Track specific deployer activity
- 🎯 Monitor tokens by name or symbol
- ⚡ Implement real-time alerts
Need Help?
For additional support:
- Email us at [email protected]
- Visit our Support Portal