AgentSkillsCN

odds-api

从 The Odds API 获取实时体育赛事投注赔率。

SKILL.md
--- frontmatter
name: odds-api
description: Fetch live sports betting odds from The Odds API

The Odds API

The ODDS_API_KEY environment variable is available. Use it with curl to fetch data.

Efficient Querying

API quota costs 1 per market per region requested. To minimize usage:

  • Only request needed markets (don't request spreads if you only need moneyline)
  • Use bookmakers param to filter to specific sportsbooks
  • Limit regions to what's relevant (us for US sports, uk for EPL)
  • Use eventIds param to fetch specific games instead of all

Sport Keys

US Sports

KeySport
basketball_nbaNBA
basketball_ncaabNCAA Basketball
basketball_wnbaWNBA
americanfootball_nflNFL
americanfootball_ncaafNCAA Football
baseball_mlbMLB
icehockey_nhlNHL
mma_mixed_martial_artsMMA/UFC

Soccer

KeyLeague
soccer_eplEnglish Premier League
soccer_spain_la_ligaLa Liga
soccer_germany_bundesligaBundesliga
soccer_italy_serie_aSerie A
soccer_france_ligue_oneLigue 1
soccer_usa_mlsMLS
soccer_mexico_ligamxLiga MX
soccer_uefa_champs_leagueChampions League

Other

KeySport
golf_pga_championshipPGA Golf
tennis_atp_aus_openATP Tennis
boxing_boxingBoxing

Markets Reference

Featured Markets (most common)

MarketDescription
h2hMoneyline / head-to-head winner
spreadsPoint spreads / handicaps
totalsOver/under game totals
outrightsFutures / championship winner

Additional Markets

MarketDescription
alternate_spreadsAlternate point spreads
alternate_totalsAlternate over/unders
bttsBoth teams to score (soccer)
draw_no_betDraw no bet (soccer)
team_totalsIndividual team totals

Period Markets

MarketDescription
h2h_q1First quarter moneyline
h2h_h1First half moneyline
spreads_q1First quarter spread
spreads_h1First half spread
totals_q1First quarter total
totals_h1First half total

Player Props

MarketDescription
player_pointsPlayer points (NBA)
player_reboundsPlayer rebounds (NBA)
player_assistsPlayer assists (NBA)
player_threesPlayer 3-pointers (NBA)
player_pass_ydsPlayer passing yards (NFL)
player_rush_ydsPlayer rushing yards (NFL)
player_reception_ydsPlayer receiving yards (NFL)
pitcher_strikeoutsPitcher strikeouts (MLB)
batter_total_basesBatter total bases (MLB)

API Endpoints

List Available Sports

bash
curl -s "https://api.the-odds-api.com/v4/sports/?apiKey=${ODDS_API_KEY}"

Get Odds for a Sport

bash
curl -s "https://api.the-odds-api.com/v4/sports/{sport_key}/odds/?apiKey=${ODDS_API_KEY}&regions=us&markets=h2h,spreads,totals&oddsFormat=american"

Parameters:

ParamValuesDescription
regionsus, us2, uk, eu, auComma-separated regions
marketsh2h, spreads, totals, etc.Comma-separated markets
oddsFormatamerican, decimalOdds display format
bookmakersdraftkings, fanduel, etc.Filter to specific books
eventIdsUUIDFetch specific events only

Get Odds for a Specific Event

bash
curl -s "https://api.the-odds-api.com/v4/sports/{sport_key}/events/{event_id}/odds/?apiKey=${ODDS_API_KEY}&regions=us&markets=h2h,spreads,totals&oddsFormat=american"

Get Scores (Live & Recent)

bash
curl -s "https://api.the-odds-api.com/v4/sports/{sport_key}/scores/?apiKey=${ODDS_API_KEY}&daysFrom=1"

Parameters:

ParamValuesDescription
daysFrom1-3Include completed games from past N days

Response Structure

json
{
  "id": "event-uuid",
  "sport_key": "basketball_nba",
  "sport_title": "NBA",
  "commence_time": "2024-01-15T00:00:00Z",
  "home_team": "Los Angeles Lakers",
  "away_team": "Boston Celtics",
  "bookmakers": [
    {
      "key": "draftkings",
      "title": "DraftKings",
      "markets": [
        {
          "key": "h2h",
          "outcomes": [
            { "name": "Los Angeles Lakers", "price": -150 },
            { "name": "Boston Celtics", "price": +130 }
          ]
        }
      ]
    }
  ]
}

Best Practices

  1. Compare odds across sportsbooks - Look for the best line/price
  2. Check for line movement - Note if odds have shifted
  3. Cite your sources - Always mention which sportsbooks you're quoting
  4. Explain the odds - American odds format: +150 means $100 wins $150, -150 means bet $150 to win $100

Troubleshooting

Empty results from an API call

Empty results ([]) mean the requested market does not exist for that event. This is normal, NOT a credential issue.

Common causes: off-season (no events), wrong market type for the game stage (e.g., outrights after a championship matchup is set — use h2h,spreads,totals instead), or invalid eventId.

Empty results are not a credential issue — adjust your query parameters instead.