Diamond AI API v1

MLB prediction engine powered by logistic regression, Elo ratings, and Claude AI. Programmatic access to predictions, rankings, value bets, and model accuracy.

Authentication

All endpoints require an API key. Pass it as a query parameter or header:

Query Parameter

GET https://diamond.champlinenterprises.com/api/v1/predictions.php?date=2026-04-06&api_key=YOUR_KEY

Header

curl -H "X-Api-Key: YOUR_KEY" https://diamond.champlinenterprises.com/api/v1/predictions.php?date=2026-04-06

API Key Tiers

TierDaily LimitUse Case
Free100 requestsPersonal projects, evaluation
Pro1,000 requestsApps, bots, dashboards
EnterpriseUnlimitedCommercial, high-volume

Get a Key

Free tier issues instantly — no credit card. Sign up here (60 seconds).

Need higher limits? See pricing for Pro and Enterprise tiers.

Code samples and OpenAPI 3.1 spec on GitHub: Kevinchamplin/diamond-api-examples

Predictions

GET /api/v1/predictions.php

Get all predictions for a specific date. Includes Claude AI analysis, model probabilities, confidence scores, value edges, and reasoning.

Parameters

NameTypeDescription
date string optional ISO 8601 date (YYYY-MM-DD). Defaults to today.
api_key string required Your API key.

Example Response

{
  "date": "2026-04-06",
  "model_version": "1.0",
  "count": 13,
  "predictions": [
    {
      "game_id": 352,
      "home_team": "COL",
      "away_team": "HOU",
      "predicted_winner": "HOU",
      "predicted_home_score": 5,
      "predicted_away_score": 8,
      "confidence": 64,
      "confidence_level": "medium",
      "model_probability": 0.677,
      "vegas_probability": 0.648,
      "consensus_probability": 0.662,
      "value_edge": 5.5,
      "reasoning": "Houston's rotation advantage...",
      "key_factors": ["Elo gap: +85 HOU", "Coors Field effect"]
    }
  ]
}

Model

GET /api/v1/model.php

Get a raw statistical model prediction for any matchup. Uses current Elo ratings and logistic regression. No Claude AI, pure math. No game needs to exist in the database.

Parameters

NameTypeDescription
home string required Home team abbreviation (e.g., NYY, LAD, CHC)
away string required Away team abbreviation
season int optional Season year. Defaults to current year.

Example Response

{
  "matchup": {
    "home": {
      "abbreviation": "NYY",
      "name": "New York Yankees",
      "elo": 1567.3,
      "momentum": 12.4
    },
    "away": {
      "abbreviation": "BOS",
      "name": "Boston Red Sox",
      "elo": 1523.1,
      "momentum": -3.2
    }
  },
  "prediction": {
    "predicted_winner": "NYY",
    "home_win_probability": 0.5892,
    "away_win_probability": 0.4108,
    "confidence": 58.9
  },
  "features": {
    "elo_diff": 68.2,
    "pitcher_diff": 0.0,
    "park_adj": 0.049
  }
}

Rankings

GET /api/v1/rankings.php

All 30 MLB teams ranked by Elo rating. Includes peak/floor Elo, recent form (last 5), momentum (last 10 Elo delta), and tier classification.

Parameters

NameTypeDescription
season int optional Season year. Defaults to current year.

Tier Definitions

TierElo Range
elite1580+
contender1540-1579
above_average1500-1539
below_average1460-1499
rebuilding1420-1459
basement<1420

Example Response

{
  "season": 2026,
  "count": 30,
  "baseline_elo": 1500,
  "rankings": [
    {
      "rank": 1,
      "team": "LAD",
      "name": "Los Angeles Dodgers",
      "elo": 1598.2,
      "tier": "elite",
      "momentum": 8.3,
      "last_5": "4-1"
    }
  ]
}

Value Bets

GET /api/v1/value-bets.php

Games where Diamond AI's model probability diverges from Vegas lines. Sorted by edge size (best value first). Updated daily with new predictions.

Parameters

NameTypeDescription
date string optional ISO 8601 date. Defaults to today.
min_edge float optional Minimum edge percentage to include (e.g., 5 for 5%+).

Edge Ratings

RatingEdge
strong10%+
moderate5-9.9%
slight3-4.9%
minimal<3%

Example Response

{
  "date": "2026-04-06",
  "count": 5,
  "value_bets": [
    {
      "game_id": 343,
      "home_team": "CLE",
      "away_team": "KC",
      "model_home_probability": 0.638,
      "vegas_home_probability": 0.520,
      "value_side": "home",
      "edge_pct": 11.8,
      "rating": "strong"
    }
  ],
  "disclaimer": "For entertainment and informational purposes only."
}

Accuracy

GET /api/v1/accuracy.php

Model performance metrics: overall accuracy, Brier score, calibration curve, performance by confidence level, and recent daily form. Compare against benchmarks (coin flip, Vegas consensus).

Parameters

NameTypeDescription
season int optional Season year. Defaults to current year.
last int optional Get accuracy for last N predictions (1-500).

Key Metrics

MetricDescriptionGood Target
accuracy_pct% of winners picked correctly>55%
brier_scoreProbability calibration (lower = better)<0.24
score_rmseScore prediction error<3.0
run_line_accuracy_pctRun line (spread) accuracy>45%

Example Response

{
  "season": 2026,
  "overall": {
    "total_predictions": 156,
    "correct": 91,
    "accuracy_pct": 58.3,
    "brier_score": 0.2318
  },
  "calibration": [
    { "bucket": "55-59", "predictions": 42, "actual_win_pct": 54.8 },
    { "bucket": "60-64", "predictions": 38, "actual_win_pct": 63.2 }
  ],
  "recent_form": [
    { "date": "2026-04-05", "games": 15, "correct": 10, "accuracy_pct": 66.7 }
  ],
  "benchmarks": {
    "coin_flip": 50.0,
    "vegas_consensus": 56.0
  }
}

Health

GET /api/v1/health.php

Public health check (no API key required). Returns liveness, model freshness, last grading time, and last data sync timestamps. Designed for status pages and customer monitoring.

Status Values

StatusHTTPMeaning
ok200All checks passing.
degraded200Service is up but one or more freshness checks are stale (e.g., model_weights > 14 days, Elo > 48h).
critical503A required component is unreachable (database down, model_weights missing).

Example Response

{
  "status": "ok",
  "timestamp": "2026-05-08T11:00:27-05:00",
  "api_version": "1.0",
  "model": {
    "version": "2.0",
    "trained_at": "2026-05-03 05:00:35",
    "training_games": 10616,
    "test_accuracy": 57,
    "test_brier": 0.2408
  },
  "checks": {
    "model_weights": { "status": "ok", "age_days": 5.25 },
    "grading":       { "status": "ok", "age_hours": 11.3 },
    "predictions":   { "status": "ok", "age_hours": 2.9 },
    "team_elo":      { "status": "ok", "age_hours": 0 },
    "database":      { "status": "ok" }
  },
  "response_time_ms": 5.1
}

Error Handling

All errors return JSON with a consistent structure:

{
  "error": true,
  "code": "UNAUTHORIZED",
  "message": "Invalid API key."
}

Status Codes

CodeMeaning
200Success
400Bad request (invalid parameters)
401Unauthorized (missing or invalid API key)
405Method not allowed (use GET)
429Rate limit exceeded
500Internal server error

Rate Limits

Every response includes rate limit headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1743998400

Limits reset daily at midnight Central Time. The X-RateLimit-Reset value is a Unix timestamp.

Response Headers

HeaderDescription
X-Model-VersionCurrent prediction model version
X-API-VersionAPI version (1.0)
X-RateLimit-LimitMax requests per day for your tier
X-RateLimit-RemainingRequests remaining today
X-RateLimit-ResetUnix timestamp when limit resets

Service Level Objectives

Diamond AI commits to the following SLOs for the public API. They apply to /api/v1/predictions.php, /api/v1/accuracy.php, and the other v1 endpoints. Health checks at /api/v1/health.php are not subject to the latency SLO (they're meant to run faster — see below).

Latency

Endpointp95 targetp99 target
Cached prediction reads (same date, repeated)200 ms500 ms
Uncached reads (cold cache, joins to games/teams)800 ms1500 ms
/api/v1/health.php50 ms150 ms

Latency is measured at the application boundary (after TLS termination), excluding network round-trip from your client.

Availability

99.5% monthly for v1 endpoints. That works out to roughly 3.6 hours of allowed downtime per month. Scheduled maintenance is excluded from this calculation.

Maintenance Window

Sundays, 4:00–6:00 AM Central Time. This is when Diamond's weekly model retraining and model-promotion job run. The API may briefly return cached or older model versions during this window. We'll announce any planned outage that exceeds 5 minutes via the /api/v1/health.php response (status: "degraded").

Rate Limits

Documented separately above. Rate-limit responses (HTTP 429) do not count against the availability SLO.

What we monitor and alert on

Any of those tripping their thresholds emits a degraded status from /api/v1/health.php. If the database or model weights are unreachable, status becomes critical and the endpoint returns HTTP 503.

Status

Real-time status: https://diamond.champlinenterprises.com/api/v1/health.php