API Documentation

Historical Predictions API

Base URL

https://www.24casts.com/api/predictions/history

Endpoint

GET/api/predictions/history

Fetch historical prediction data with filtering, sorting, and pagination options.

Query Parameters

ParameterTypeDescription
market_idstringFilter by specific market ID
slugstringFilter by market slug
recommendationstringSTRONG_SIGNAL, MODERATE_SIGNAL, WEAK_SIGNAL, NO_TRADE
regimestringliquid_active, pre_catalyst_event, illiquid_tail_risk
min_edgenumberMinimum edge in basis points
max_edgenumberMaximum edge in basis points
sortBystringField to sort by (default: created_at)
sortOrdernumber1 for ascending, -1 for descending
pagenumberPage number for pagination
limitnumberNumber 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

CodeMeaning
200Success
400Bad Request
404Not Found
500Server 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 page and limit parameters
  • ✓Combine filters: Strategically combine filters (e.g., recommendation + min_edge)
  • ✓Always check success: Verify the success field before accessing data
  • ✓Implement caching: Cache results on client side to reduce server load
  • ✓Use grouped data: The grouped object is ideal for time-series analysis