SofaScore API endpoint
Returns a baseball match's at-bat timeline from SofaScore, in play order: for each plate appearance the inning and half (`top` or `bottom`), pitcher, hitter, their teams, when it ended and the home and away win probabilities before and after it. Use an at-bat `id` with sofascore-event-at-bat-pitches to read its pitches. Returns 404 when SofaScore has no at-bat data for the match, which includes matches that have not started and sports other than baseball.
/sofascore/event-at-batsQuery parameters:
id: required. Numeric SofaScore event (match) id of a baseball match, e.g. 17199139 (an MLB game).Notable response behavior:
id, the inning and inning_half (top or bottom), the pitcher and hitter with their teams, and end_timestamp/end_time (when the at-bat finished, which equals the end of its last pitch).home_win_probability_start and away_win_probability_start are percentages before the at-bat, home_win_probability and away_win_probability after it.sofascore/event-at-bat-pitches (at_bat_over, outcome, hit) for how it ended.at_bats array is a valid response (a match that has not started its first at-bat). Returns 404 when SofaScore has no at-bat data for the match, which includes matches that have not started and sports other than baseball.Example response (shortened):
{
"code": 200,
"msg": "OK",
"data": {
"event_id": 17199139,
"source_url": "https://api.sofascore.com/api/v1/event/17199139/at-bats",
"fetched_at": "2026-10-07T17:00:00Z",
"count": 73,
"at_bats": [
{
"id": 2595879,
"inning": 1,
"inning_half": "top",
"pitcher": {
"id": 960737,
"name": "Chris Sale",
"short_name": "C. Sale",
"slug": "sale-chris",
"position": "SP",
"jersey_number": "51"
},
"pitcher_team": {
"id": 3656,
"name": "Atlanta Braves",
"short_name": "Braves",
"slug": "atlanta-braves"
},
"hitter": {
"id": 960736,
"name": "Mookie Betts",
"short_name": "M. Betts",
"slug": "betts-mookie",
"position": "SS",
"jersey_number": "50"
},
"hitter_team": {
"id": 3638,
"name": "Los Angeles Dodgers",
"short_name": "Dodgers",
"slug": "los-angeles-dodgers"
},
"end_timestamp": 1791324839,
"end_time": "2026-10-06T22:13:59Z",
"home_win_probability_start": 51,
"away_win_probability_start": 49,
"home_win_probability": 47.9,
"away_win_probability": 52.1
},
{
"id": 2595880,
"inning": 1,
"inning_half": "top",
"pitcher": {
"id": 960737,
"name": "Chris Sale",
"short_name": "C. Sale",
"slug": "sale-chris",
"position": "SP",
"jersey_number": "51"
},
"pitcher_team": {
"id": 3656,
"name": "Atlanta Braves",
"short_name": "Braves",
"slug": "atlanta-braves"
},
"hitter": {
"id": 961444,
"name": "Freddie Freeman",
"short_name": "F. Freeman",
"slug": "freeman-freddie",
"position": "1B",
"jersey_number": "5"
},
"hitter_team": {
"id": 3638,
"name": "Los Angeles Dodgers",
"short_name": "Dodgers",
"slug": "los-angeles-dodgers"
},
"end_timestamp": 1791324949,
"end_time": "2026-10-06T22:15:49Z",
"home_win_probability_start": 47.9,
"away_win_probability_start": 52.1,
"home_win_probability": 48.2,
"away_win_probability": 51.8
},
"..."
]
}
}
| Field | Filled in, of 73 checked | Values in the sample |
|---|---|---|
| id | 73 | |
| inning | 73 | 1 to 9, median 5 |
| inning_half | 73 | top (39), bottom (34) |
| pitcher | 73 | |
| pitcher_team | 73 | |
| hitter | 73 | |
| hitter_team | 73 | |
| end_timestamp | 73 | 2026-10-06 to 2026-10-07 |
| end_time | 73 | 2026-10-06 to 2026-10-07 |
| home_win_probability_start | 73 | 3.5 to 51.9, median 14.4 |
| away_win_probability_start | 73 | 48.1 to 96.5, median 85.6 |
| home_win_probability | 73 | 0 to 51.9, median 14 |
| away_win_probability | 73 | 48.1 to 100, median 86 |
| Parameter | Type | Required | Default | Description | Example |
|---|---|---|---|---|---|
| id | string | Yes | Numeric SofaScore baseball event (match) id | 17199139 | |
| x-api-key (header) | string | Yes | API key required |
curl -X GET "https://api.crawlora.net/api/v1/sofascore/event-at-bats?id=17199139" \ -H "x-api-key: $CRAWLORA_API_KEY"
{
"code": 200,
"msg": "OK",
"data": {
"event_id": 17199139,
"source_url": "https://api.sofascore.com/api/v1/event/17199139/at-bats",
"fetched_at": "2026-10-07T17:00:00Z",
"count": 73,
"at_bats": [
{
"id": 2595879,
"inning": 1,
"inning_half": "top",
"pitcher": {
"id": 960737,
"name": "Chris Sale",
"short_name": "C. Sale",
"slug": "sale-chris",
"position": "SP",
"jersey_number": "51"
},
"pitcher_team": {
"id": 3656,
"name": "Atlanta Braves",
"short_name": "Braves",
"slug": "atlanta-braves"
},
"hitter": {
"id": 960736,
"name": "Mookie Betts",
"short_name": "M. Betts",
"slug": "betts-mookie",
"position": "SS",
"jersey_number": "50"
},
"hitter_team": {
"id": 3638,
"name": "Los Angeles Dodgers",
"short_name": "Dodgers",
"slug": "los-angeles-dodgers"
},
"end_timestamp": 1791324839,
"end_time": "2026-10-06T22:13:59Z",
"home_win_probability_start": 51,
"away_win_probability_start": 49,
"home_win_probability": 47.9,
"away_win_probability": 52.1
},
{
"id": 2595880,
"inning": 1,
"inning_half": "top",
"pitcher": {
"id": 960737,
"name": "Chris Sale",
"short_name": "C. Sale",
"slug": "sale-chris",
"position": "SP",
"jersey_number": "51"
},
"pitcher_team": {
"id": 3656,
"name": "Atlanta Braves",
"short_name": "Braves",
"slug": "atlanta-braves"
},
"hitter": {
"id": 961444,
"name": "Freddie Freeman",
"short_name": "F. Freeman",
"slug": "freeman-freddie",
"position": "1B",
"jersey_number": "5"
},
"hitter_team": {
"id": 3638,
"name": "Los Angeles Dodgers",
"short_name": "Dodgers",
"slug": "los-angeles-dodgers"
},
"end_timestamp": 1791324949,
"end_time": "2026-10-06T22:15:49Z",
"home_win_probability_start": 47.9,
"away_win_probability_start": 52.1,
"home_win_probability": 48.2,
"away_win_probability": 51.8
},
"..."
]
}
}Request schema
No body schema
Response schema
#/definitions/sofascore.eventAtBatsResponseDoc
| Field | Type | Required | Enum | Bounds | Example | Description |
|---|---|---|---|---|---|---|
| code | integer | No | 200 | |||
| data | sofascore.EventAtBatsResponse | No | ||||
| data.at_bats | array | No | ||||
| data.at_bats[].away_win_probability | number | No | 52.1 | |||
| data.at_bats[].away_win_probability_start | number | No | 49 | |||
| data.at_bats[].end_time | string | No | 2026-10-06T22:13:59Z | |||
| data.at_bats[].end_timestamp | integer | No | 1791324839 | EndTimestamp is the Unix time the at-bat finished (it matches the end of its last pitch); EndTime is the same instant in RFC 3339. | ||
| data.at_bats[].hitter | sofascore.PlayerBrief | No | PlayerBrief record, 6 fields: id, jersey_number, name, position, short_name, slug. Described under SofaScore event at-bat pitches API. | |||
| data.at_bats[].hitter_team | sofascore.TeamRef | No | TeamRef record, 6 fields: country, id, name, national, short_name, slug. Described under SofaScore venue API. | |||
| data.at_bats[].home_win_probability | number | No | 47.9 | |||
| data.at_bats[].home_win_probability_start | number | No | 51 | Win probabilities are percentages. The *Start values are before the at-bat, the others after it. | ||
| data.at_bats[].id | integer | No | 2595879 | |||
| data.at_bats[].inning | integer | No | 1 | |||
| data.at_bats[].inning_half | string | No | top | InningHalf is `top` or `bottom`. | ||
| data.at_bats[].pitcher | sofascore.PlayerBrief | No | PlayerBrief record, 6 fields: id, jersey_number, name, position, short_name, slug. Described under SofaScore event at-bat pitches API. | |||
| data.at_bats[].pitcher_team | sofascore.TeamRef | No | TeamRef record, 6 fields: country, id, name, national, short_name, slug. Described under SofaScore venue API. | |||
| data.count | integer | No | ||||
| data.event_id | integer | No | 17199139 | |||
| data.fetched_at | string | No | ||||
| data.source_url | string | No | ||||
| msg | string | No | OK |
| Status | Description | Schema |
|---|---|---|
| 400 | Bad Request | #/definitions/app.Response |
| 404 | Not Found | #/definitions/app.Response |
| 429 | Too Many Requests | #/definitions/app.Response |
| 503 | Service Unavailable | #/definitions/app.Response |
Use environment variables for secrets and keep Crawlora API keys server-side.
curl -X GET "https://api.crawlora.net/api/v1/sofascore/event-at-bats?id=17199139" \
-H "x-api-key: $CRAWLORA_API_KEY"