cd /Users/anshulmangalapalli/Documents/GitHub/hackprinceton
python3 api_server.pyWait for:
🚀 KALSHI HYBRID ANALYSIS API STARTING
Docs: http://localhost:8000/docs
cd dashboard
npm run dev- Open http://localhost:3000/dashboard in browser
- Open browser console (Press F12 or Right-click → Inspect → Console)
In the browser console, type:
window.testAPI();Press Enter.
================================================================================
🧪 TESTING PYTHON API CONNECTION
================================================================================
API Base URL: http://localhost:8000
Time: 11/9/2025, 2:30:45 PM
================================================================================
📡 Test 1: Health Check
Calling: GET /
✅ Status: 200
📦 Response: {
"status": "online",
"service": "Kalshi Hybrid Analysis API",
"version": "1.0.0"
}
📡 Test 2: Status Check
Calling: GET /api/status
✅ Status: 200
📦 Response: {
"status": "ready",
"isAnalyzing": false,
"lastUpdated": "2025-11-09T14:30:52.123Z",
"count": 12,
"error": null
}
📡 Test 3: Get Recommendations
Calling: GET /api/recommendations
✅ Status: 200
📊 Response Status: success
📦 Opportunities Count: 12
🎯 SAMPLE RECOMMENDATION:
--------------------------------------------------------------------------------
Ticker: KXHIGHCHI-25NOV09-T38
Title: Will the high temp in Chicago be <38° on Nov 9, 2025?
Category: Weather
Action: BUY_YES
Quant Edge: 79.0%
Market Prob: 0.5%
Combined Confidence: 88.0%
🤖 GROK SENTIMENT:
Label: positive
Score: 82%
Confidence: high
Key Themes: cold front, arctic blast, freezing
💡 REASONING:
Statistical analysis shows a 79.0% edge. Models predict 79.5% probability vs
market price of 0.5%. Grok AI sentiment analysis: positive (82%). Key themes:
cold front, arctic blast, freezing. ✅ Both quantitative and sentiment signals
AGREE, increasing confidence.
--------------------------------------------------------------------------------
📊 ALL RECOMMENDATIONS:
1. KXHIGHCHI-25NOV09-T38 - BUY_YES (Edge: 79.0%)
2. KXHIGHDEN-25NOV08-B53.5 - BUY_NO (Edge: -90.9%)
3. KXHIGHCHI-25NOV09-B40.5 - BUY_NO (Edge: -77.5%)
4. KXHIGHDEN-25NOV08-T51 - BUY_YES (Edge: 63.7%)
5. KXHIGHNY-25NOV09-T59 - BUY_YES (Edge: 62.8%)
... (7 more)
================================================================================
✅ API CONNECTION TEST COMPLETE
================================================================================
📡 Test 3: Get Recommendations
Calling: GET /api/recommendations
✅ Status: 200
📊 Response Status: analyzing
📦 Opportunities Count: 0
⏳ Backend is currently analyzing markets
💡 Wait 30-60 seconds and try again
================================================================================
✅ API CONNECTION TEST COMPLETE
================================================================================
================================================================================
❌ API CONNECTION TEST FAILED
================================================================================
🔥 Error: Failed to fetch
💡 Troubleshooting:
1. Is Python backend running? (python3 api_server.py)
2. Is it running on port 8000?
3. Check Terminal 1 for backend errors
4. Try: curl http://localhost:8000/api/status
================================================================================
-
Health Check (
GET /)- Verifies backend is online
- Returns service info
-
Status Check (
GET /api/status)- Checks if analysis is running
- Shows last update time
- Shows recommendation count
-
Get Recommendations (
GET /api/recommendations)- Fetches actual recommendations
- Shows full details of first recommendation
- Shows list of all recommendations
Cause: Backend not running or wrong port
Fix:
- Check Terminal 1 - is
python3 api_server.pyrunning? - Should show:
Docs: http://localhost:8000/docs - Try:
curl http://localhost:8000/api/status
Cause: Backend hasn't finished first analysis yet
Fix: Wait 30-60 seconds, run window.testAPI() again
Cause: Backend is currently analyzing (normal!)
Fix: Wait 30-60 seconds, run window.testAPI() again
Cause: Backend and dashboard on different domains
Fix:
- Ensure backend is on
localhost:8000 - Ensure dashboard is on
localhost:3000 - Restart both if needed
When you run window.testAPI(), you'll see this in Terminal 1:
📥 GET / - Request received at 14:31:20
📥 GET /api/status - Request received at 14:31:20
✅ Returning status: ready
📥 GET /api/recommendations - Request received at 14:31:20
✅ Returning 12 recommendations
📅 Last updated: 14:30:52
This confirms the backend is receiving and responding to requests!
Your API connection is working if:
- ✅ All 3 tests pass (Health, Status, Recommendations)
- ✅ You see recommendations in console
- ✅ Backend terminal shows incoming requests
- ✅ No error messages
You can also test the API directly from terminal:
# Health check
curl http://localhost:8000/
# Status check
curl http://localhost:8000/api/status
# Get recommendations
curl http://localhost:8000/api/recommendations | jq(Install jq for pretty JSON: brew install jq)
Running window.testAPI() proves:
- ✅ Dashboard can reach Python backend
- ✅ Backend is responding correctly
- ✅ API endpoints are working
- ✅ Data is flowing correctly
- ✅ Recommendations are being generated
Perfect for showing judges: "Here's the live API connection!" 🎓
During HackPrinceton demo:
- Open dashboard
- Open console (F12)
- Type:
window.testAPI() - Show judges the output
- Point out:
- Real-time API calls
- Python backend responding
- Actual recommendations with Grok sentiment
- All the data flowing through
This is EXTREMELY impressive! Shows both pretty UI AND technical depth. 🚀