A newer version of the Streamlit SDK is available: 1.62.0
π API Keys Setup Guide - Crypto News Aggregator
π Required API Keys/Tokens
Here are the exact environment variables you need to provide:
# ββββββββββββββββββββββββββββββββββββββββββββββββββββ
# CRYPTO NEWS API KEYS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 1. CryptoPanic (OPTIONAL but recommended)
CRYPTOPANIC_TOKEN=
# 2. Reddit API (REQUIRED for social sentiment)
REDDIT_CLIENT_ID=
REDDIT_CLIENT_SECRET=
# 3. CryptoCompare (OPTIONAL but recommended)
CRYPTOCOMPARE_API_KEY=
π Step-by-Step Setup Instructions
1. CryptoPanic API Token (β οΈ OPTIONAL - Works without it!)
Status: OPTIONAL (public feed works without token) Free Tier: Unlimited Cost: FREE forever
How to Get:
- Go to: https://cryptopanic.com/developers/api/
- Click "Get Your Free API Token"
- Sign up with email
- Copy your token from the dashboard
- Add to
.env:
CRYPTOPANIC_TOKEN=your_token_here
β οΈ NOTE: The aggregator works WITHOUT this token using the public feed. Token gives you:
- Higher rate limits
- Access to more filters
- Priority support
Skip this if you want - public feed is fine!
2. Reddit API Credentials (β REQUIRED)
Status: REQUIRED (for social sentiment) Free Tier: Unlimited (60 requests/min) Cost: FREE
How to Get:
Step 1: Create Reddit App
- Go to: https://www.reddit.com/prefs/apps
- Scroll to bottom, click "create another app..."
- Fill in the form:
- name:
DRL-Trading-Bot(or any name) - App type: Select "script"
- description:
Crypto news sentiment analysis - about url: (leave blank)
- redirect uri:
http://localhost:8080(required but not used)
- name:
- Click "create app"
Step 2: Get Credentials
After creating, you'll see:
βββββββββββββββββββββββββββββββββββββββ
β DRL-Trading-Bot β
β personal use script β
β β
β abc123def456 β β This is your CLIENT_ID
β β
β secret: xyz789abc123def456... β β This is your CLIENT_SECRET
βββββββββββββββββββββββββββββββββββββββ
Step 3: Add to .env
REDDIT_CLIENT_ID=abc123def456
REDDIT_CLIENT_SECRET=xyz789abc123def456
Example:
REDDIT_CLIENT_ID=p-jcoLKBynTLew
REDDIT_CLIENT_SECRET=gko_LXELoV07ZBNUXrvWZfzE3aI
3. CryptoCompare API Key (β οΈ OPTIONAL)
Status: OPTIONAL (but recommended for verified news) Free Tier: 100,000 calls/month (3,333/day) Cost: FREE
How to Get:
- Go to: https://min-api.cryptocompare.com/
- Click "Get Your Free API Key"
- Sign up with email
- Verify email
- Go to dashboard: https://www.cryptocompare.com/cryptopian/api-keys
- Copy your API key
- Add to
.env:
CRYPTOCOMPARE_API_KEY=your_key_here
Example:
CRYPTOCOMPARE_API_KEY=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
β Final .env File
After getting all keys, your .env should have:
# ... existing keys ...
# Crypto News Aggregator
CRYPTOPANIC_TOKEN=your_cryptopanic_token_here # OPTIONAL
REDDIT_CLIENT_ID=your_reddit_client_id_here # REQUIRED
REDDIT_CLIENT_SECRET=your_reddit_secret_here # REQUIRED
CRYPTOCOMPARE_API_KEY=your_cryptocompare_key # OPTIONAL
π― What Works Without API Keys?
Minimum Setup (Only Reddit - 1 source):
# Only these 2 are REQUIRED:
REDDIT_CLIENT_ID=...
REDDIT_CLIENT_SECRET=...
Result:
- β Reddit sentiment (30% weight)
- β οΈ No CryptoPanic (50% weight lost)
- β οΈ No CryptoCompare (20% weight lost)
- Total coverage: 30%
Recommended Setup (All 3 sources):
CRYPTOPANIC_TOKEN=... # FREE, unlimited
REDDIT_CLIENT_ID=... # FREE, unlimited
REDDIT_CLIENT_SECRET=... # FREE, unlimited
CRYPTOCOMPARE_API_KEY=... # FREE, 100K/month
Result:
- β CryptoPanic sentiment (50% weight)
- β Reddit sentiment (30% weight)
- β CryptoCompare sentiment (20% weight)
- Total coverage: 100%
π Verification
After adding keys to .env, test them:
# Test the aggregator
python -c "from src.features.crypto_news_aggregator import CryptoNewsAggregator; agg = CryptoNewsAggregator('BTC'); print(agg.get_aggregated_sentiment())"
Expected output:
β
Reddit client initialized
π° CryptoPanic: 20 posts for BTC
π΄ Reddit: 15 posts for Bitcoin
π CryptoCompare: 30 articles for BTC
π° Aggregated sentiment [BTC]: π’ +0.34 (confidence=0.72, sources=3/3, trend=improving)
If you see errors:
Reddit initialization failedβ Check REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRETCryptoPanic error: 403β Check CRYPTOPANIC_TOKEN (or remove it to use public feed)CryptoCompare error: 401β Check CRYPTOCOMPARE_API_KEY
π API Limits Summary
| Source | Free Tier Limit | Enough for Trading? | Cost if Exceeded |
|---|---|---|---|
| CryptoPanic | Unlimited | β Yes | FREE forever |
| 60 req/min | β Yes (we use ~1/hour) | FREE forever | |
| CryptoCompare | 100K/month (3,333/day) | β Yes (we use ~24/day) | $17/month for 500K |
For hourly trading:
- CryptoPanic: ~24 calls/day (cache: 5 min)
- Reddit: ~24 calls/day (cache: 5 min)
- CryptoCompare: ~24 calls/day (cache: 5 min)
Total: ~72 calls/day across all sources
π¨ Troubleshooting
Error: "praw.exceptions.ResponseException: received 401 HTTP response"
Cause: Reddit credentials are wrong
Solution:
- Double-check
REDDIT_CLIENT_IDandREDDIT_CLIENT_SECRET - Make sure you created a "script" app (not "web app")
- Recreate the app if needed
Error: "Reddit client not available"
Cause: praw library not installed
Solution:
pip install praw
Error: "CryptoPanic error: 429"
Cause: Rate limit exceeded (unlikely with caching)
Solution:
- Increase
cache_ttlincrypto_news_aggregator.pyto 600 (10 min) - Get API token to increase limits
Warning: "Reddit credentials not set - using fallback"
Cause: Missing REDDIT_CLIENT_ID or REDDIT_CLIENT_SECRET
Solution:
- Add both variables to
.env - Restart the application
β Quick Test Checklist
Run these commands to verify everything works:
# 1. Check .env file
cat .env | grep -E "REDDIT|CRYPTOPANIC|CRYPTOCOMPARE"
# Should output:
# REDDIT_CLIENT_ID=...
# REDDIT_CLIENT_SECRET=...
# CRYPTOPANIC_TOKEN=...
# CRYPTOCOMPARE_API_KEY=...
# 2. Test Reddit
python -c "import praw; r = praw.Reddit(client_id='YOUR_ID', client_secret='YOUR_SECRET', user_agent='test'); print('β
Reddit OK')"
# 3. Test CryptoPanic
curl "https://cryptopanic.com/api/v1/posts/?public=true¤cies=BTC" | head -20
# 4. Test CryptoCompare
curl "https://min-api.cryptocompare.com/data/v2/news/?categories=BTC" | head -20
# 5. Test full aggregator
python test_crypto_news.py
π Summary
Exact variables you need to add to .env:
# REQUIRED (Reddit)
REDDIT_CLIENT_ID=your_reddit_app_client_id
REDDIT_CLIENT_SECRET=your_reddit_app_client_secret
# OPTIONAL (CryptoPanic - works without it)
CRYPTOPANIC_TOKEN=your_cryptopanic_token
# OPTIONAL (CryptoCompare - recommended)
CRYPTOCOMPARE_API_KEY=your_cryptocompare_key
Next step: Get these keys and add them to .env, then run the test!
π Quick Links
- Reddit Apps: https://www.reddit.com/prefs/apps
- CryptoPanic API: https://cryptopanic.com/developers/api/
- CryptoCompare API: https://min-api.cryptocompare.com/
Questions? Run the test script and check the output:
python test_crypto_news.py
The script will tell you exactly which keys are missing!