Overview
The Reddit integration detects community buzz for crypto tokens, primarily meme coins. It searches for token symbols (e.g., $SOL) or wallet addresses and calculates engagement based on upvotes and comments.
- Filter tokens with viral potential based on Reddit hype.
- Enhance credibility: store search URL for manual verification.
- Cache results for 5 minutes to improve efficiency while keeping data fresh.
Setup & Configuration
- Create a Reddit App: Go to Reddit Apps and create a "script" type app. Save
client_idandclient_secret. Set a unique User-Agent, e.g.,my_token_tracker/1.0 (by /u/yourusername). - Environment Variables:
Use secrets for deployment. Do not commit sensitive keys.REDDIT_CLIENT_ID=your_client_id_here REDDIT_CLIENT_SECRET=your_client_secret_here REDDIT_THRESHOLD=5 - Install Dependencies:
npm install axios - Deploy & Test: Trigger the cron job manually and verify results in Firestore under
tokens/{address}.
Data Flow
Cron Trigger → Fetch Tokens from Birdeye
↓
For each Token: Authenticate Reddit OAuth
↓
Build Query → /search API
↓
Filter Posts → Calculate Engagement
↓
If engagement ≥ threshold → Save to Firestore
Engagement is calculated as upvotes + comments. Only posts matching regex patterns are considered.
Advanced Regex Filtering
Use regex to match token symbols and names accurately while avoiding false positives. Example patterns:
\b${symbol}\b— exact word match\$${symbol}\b— ticker style\b${name}\b— token name fallback- Context-aware hype match:
(?:pump|moon|buy|hodl|bull)\s+\$${symbol} - Negative lookahead:
(?!scam|rug|dump)\b${symbol}\b
function buildTokenPatterns(symbol, name) {
return [
new RegExp(`\\b${symbol}\\b(?!\\s*(?:scam|rug))`, 'i'),
new RegExp(`\\$${symbol}\\b(?=\\s*(?:pump|moon|to\\s+the))`, 'i'),
new RegExp(`\\b${name}\\b`, 'i')
];
}
Firestore Schema
Each token document stores Reddit engagement metrics:
- redditPostsCount: number of matched posts
- redditTotalUps: total upvotes
- redditTotalComments: total comments
- redditEngagement: sum of ups + comments
- redditTopPost: object with title, url, ups, comments, score, created
- redditQueryUrl: full Reddit search URL
{
"redditEngagement": 12,
"redditPostsCount": 3,
"redditTopPost": {
"title": "Why $SOL is mooning this week!",
"url": "https://reddit.com/r/cryptocurrency/comments/abc123/...",
"ups": 7,
"comments": 5,
"score": 12,
"created": "2025-11-02T10:00:00.000Z"
},
"redditQueryUrl": "https://www.reddit.com/search?q=%22SOL%22+OR+%223WzD...&sort=new&t=month"
}
Troubleshooting & Best Practices
- Invalid credentials: check client_id/secret and regenerate app if needed
- Rate limits: free tier ~100 queries/hour, add delays
- False positives/negatives: tweak regex patterns
- No token data: fallback is safe, but log warning
- Monitoring: check logs for "Reddit: {symbol} → SAVED/SKIP"
Updates
- v1.1 (Nov 02, 2025): Added advanced regex filtering with examples and testing tips
- v1.0 (Nov 02, 2025): Initial integration with Reddit query URL verification