Base URL
https://www.24casts.com/api/predictions/historyEndpoint
GET
/api/predictions/historyFetch historical prediction data with filtering, sorting, and pagination options.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| market_id | string | Filter by specific market ID |
| slug | string | Filter by market slug |
| recommendation | string | STRONG_SIGNAL, MODERATE_SIGNAL, WEAK_SIGNAL, NO_TRADE |
| regime | string | liquid_active, pre_catalyst_event, illiquid_tail_risk |
| min_edge | number | Minimum edge in basis points |
| max_edge | number | Maximum edge in basis points |
| sortBy | string | Field to sort by (default: created_at) |
| sortOrder | number | 1 for ascending, -1 for descending |
| page | number | Page number for pagination |
| limit | number | Number of items per page |
Example Requests
bash
# Get all predictions
curl "https://www.24casts.com/api/predictions/history"
# Get predictions for specific market
curl "https://www.24casts.com/api/predictions/history?market_id=589648"
# Get strong signals with high edge
curl "https://www.24casts.com/api/predictions/history?recommendation=STRONG_SIGNAL&min_edge=1000"
# Get latest predictions (paginated)
curl "https://www.24casts.com/api/predictions/history?sortBy=created_at&sortOrder=-1&page=1&limit=20"Response Schema
json
{
"success": true,
"data": {
"grouped": {
"589648": [
{
"_id": "694d504ad6c267c9d3c5574e",
"market_id": "589648",
"slug": "will-the-us-invade-venezuela-in-2025",
"question": "Will the U.S. invade Venezuela by December 31, 2025?",
"current_prices": {
"Yes": 0.0225,
"No": 0.9775
},
"analysis": {
"prediction": "No",
"confidence": "Medium",
"key_factors": [...]
},
"pricing": {
"regime": "pre_catalyst_event",
"fair_price_yes": 0.21,
"edge_bps": 1870.7,
"recommendation": "STRONG_SIGNAL",
"kelly_fraction": 0.005
},
"created_at": "2025-12-25T09:55:06.919287"
}
]
},
"markets": [
{
"market_id": "589648",
"slug": "will-the-us-invade-venezuela-in-2025",
"question": "Will the U.S. invade Venezuela by December 31, 2025?",
"prediction_count": 5,
"latest_fair_price": 0.21,
"latest_market_price": 0.0225,
"latest_edge_bps": 1870.7,
"latest_recommendation": "STRONG_SIGNAL"
}
]
},
"count": 45,
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"total_pages": 3
}
}Code Examples
JavaScript/TypeScript
typescript
// Fetch all predictions
const response = await fetch('https://www.24casts.com/api/predictions/history')
const result = await response.json()
if (result.success) {
console.log(`Found ${result.data.markets.length} markets`)
console.log(`Total predictions: ${result.count}`)
}
// Fetch with filters
const params = new URLSearchParams({
recommendation: 'STRONG_SIGNAL',
min_edge: '1000',
sortBy: 'created_at',
sortOrder: '-1'
})
const filtered = await fetch(`https://www.24casts.com/api/predictions/history?${params}`)
const data = await filtered.json()Python
python
import requests
API_URL = 'https://www.24casts.com/api/predictions/history'
# Get all predictions
response = requests.get(API_URL)
data = response.json()
if data['success']:
markets = data['data']['markets']
print(f"Found {len(markets)} markets")
for market in markets:
print(f"{market['question']}")
print(f" Edge: {market['latest_edge_bps']} bps")
print(f" Recommendation: {market['latest_recommendation']}")
# Filter by strong signals
params = {
'recommendation': 'STRONG_SIGNAL',
'min_edge': 1000,
'sortBy': 'created_at',
'sortOrder': -1
}
response = requests.get(API_URL, params=params)
print(f"Strong signals: {response.json()['count']}")React Hook
typescript
import { useState, useEffect } from 'react'
export function usePredictionHistory(filters = {}) {
const [data, setData] = useState(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
useEffect(() => {
async function fetchData() {
try {
const params = new URLSearchParams(filters)
const res = await fetch(`https://www.24casts.com/api/predictions/history?${params}`)
const json = await res.json()
if (json.success) {
setData(json.data)
} else {
setError('Failed to fetch data')
}
} catch (err) {
setError(err.message)
} finally {
setLoading(false)
}
}
fetchData()
}, [JSON.stringify(filters)])
return { data, loading, error }
}
// Usage
function MyComponent() {
const { data, loading } = usePredictionHistory({
recommendation: 'STRONG_SIGNAL',
min_edge: 1000
})
if (loading) return <div>Loading...</div>
return (
<div>
{data?.markets.map(market => (
<div key={market.market_id}>
<h3>{market.question}</h3>
<p>Edge: {market.latest_edge_bps} bps</p>
</div>
))}
</div>
)
}Response Status Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request |
| 404 | Not Found |
| 500 | Server Error |
Common Use Cases
📊 Track Model Performance
Filter by market_id to see prediction evolution over time
🎯 Find Trading Opportunities
Filter: recommendation=STRONG_SIGNAL&min_edge=1000
📈 Analyze Market Regimes
Filter by regime to study different market conditions
🔄 Monitor Updates
Sort: sortBy=created_at&sortOrder=-1
Best Practices
- ✓Use pagination: For large result sets, use
pageandlimitparameters - ✓Combine filters: Strategically combine filters (e.g., recommendation + min_edge)
- ✓Always check success: Verify the
successfield before accessing data - ✓Implement caching: Cache results on client side to reduce server load
- ✓Use grouped data: The
groupedobject is ideal for time-series analysis