# ESPN API 比赛实时监控

## 接口

```
https://site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard
```

### 参数
- `dates=YYYYMMDD` — 筛选特定日期的比赛（推荐，否则默认当天）
- `limit=N` — 返回数量限制

### 返回结构

```json
{
  "events": [
    {
      "id": "760431",
      "name": "Jordan at Austria",
      "date": "2026-06-17T04:00Z",
      "competitions": [{
        "status": {
          "type": {
            "id": "26",
            "name": "STATUS_SECOND_HALF",
            "state": "in",
            "completed": false,
            "description": "Second Half",
            "detail": "90'+8'",
            "shortDetail": "90'+8'"
          }
        },
        "competitors": [
          {
            "team": { "displayName": "Austria" },
            "score": "2",
            "winner": false
          },
          {
            "team": { "displayName": "Jordan" },
            "score": "1",
            "winner": false
          }
        ],
        "details": [
          {
            "type": { "id": "70", "text": "Goal" },
            "clock": { "value": 1201, "displayValue": "21'" },
            "team": { "id": "474" },
            "scoreValue": 1,
            "scoringPlay": true,
            "ownGoal": false
          }
        ]
      }]
    }
  ]
}
```

### 状态值
| state | description | 含义 |
|-------|------------|------|
| `pre` | Scheduled | 赛前 |
| `in` | First Half | 上半场 |
| `in` | Halftime | 中场休息 |
| `in` | Second Half | 下半场 |
| `in` | Second Half (+ 90'+X') | 伤停补时 |
| `post` | Full Time | 已结束 |

### 事件类型 (details[].type.id)
| id | text | 含义 |
|----|------|------|
| 70 | Goal | 进球 |
| 97 | Own Goal | 乌龙球 |
| 94 | Yellow Card | 黄牌 |
| 95 | Red Card | 红牌 |
| 98 | Penalty | 点球 |
| 96 | Substitution | 换人 |

## 轮询策略

1. **比赛进行中**：每3分钟轮询一次（太频繁会被限速）
2. **伤停补时阶段**：可缩短到每1分钟（如shortDetail显示90'+'）
3. **比赛结束后**：停止轮询

## 注意点
- goal details的`team.id`是球队内部ID，不是标准队名，需从competitors列表反查
- `scoringPlay: true` + `ownGoal: true` = 乌龙球导致对方得分
- 同一场次的比分更新时间约1-2分钟延迟（ESPN CDN缓存）
- 如果指定日期没有比赛，events返回空数组
