Simulations
Intro
Our API simulations allow you to replay actual games at any time, on your own schedule.
With the replayer, you can:
- Request a list of available recordings (by league)
- Register a session (allows a game to be replayed in natural time, specific to the session)
- Continually request an endpoint as a "live" game progresses
- Open up a continuous Push simulation of a game
Authentication
Simulations do not require an API key or any authentication
League Availability
Replay simulations are currently available for the following APIs:
- Baseball - MLB
- Basketball - NBA, WNBA, NCAA Women's Basketball, NCAA Men's Basketball, NBA G League
- Football - NFL, NCAA, UFL
- Hockey - NHL
Fetch Available Recordings
To see a list of available recordings the below GraphQL endpoint can be used.
curl --location --request POST 'https://playback.sportradar.com/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query getRecordings($league: String){\n recordings(league: $league){\n id\n scheduled\n meta\n league\n start\n end\n title\n apis {\n name\n description\n formats\n }\n }\n}","variables":{"league":"nfl"}}'
The above query is specific to the NFL ("league":"nfl"
). Click here for all available league parameters.
Recording Samples
{
"data": {
"recordings": [
{
"id": "95aa13a0-6538-11ef-9287-d597687b4672",
"title": "Baltimore Ravens AT Kansas City Chiefs",
"meta": {
"gameId": "ebb5f3ac-bb13-4dc4-ab8b-6c65623eac13",
"awayTeam": "6526d38583a47c56303cf1fa",
"homeTeam": "6526d350fb66c7d02dfb8a0f",
"scheduled": "2024-09-06T00:20:00+00:00",
"awayTeamName": "Baltimore Ravens",
"homeTeamName": "Kansas City Chiefs"
},
"league": "nfl",
"scheduled": "2024-09-06T00:20:00.000Z",
"start": 1725583604260,
"end": 1725595789187,
"apis": [
{
"name": "events",
"description": "game events",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "statistics",
"description": null,
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pulse",
"description": "game push pulse",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "boxscore",
"description": "game box score",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "game",
"description": "game statistics",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pbp",
"description": "game play by play",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "rosters",
"description": "game rosters",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
}
]
}
]
}
}
{
"data": {
"recordings": [
{
"id": "fb821410-5fda-11ef-b731-154d1d4eafcf",
"title": "Astros AT Phillies",
"meta": {
"gameId": "9207104d-771d-4aa0-993f-7939d8b8c617",
"awayTeam": 3655,
"homeTeam": 3635,
"scheduled": "2024-08-27T22:40:00+00:00",
"awayTeamName": "Astros",
"homeTeamName": "Phillies"
},
"league": "mlb",
"scheduled": "2024-08-27T22:40:00.000Z",
"start": 1724798370278,
"end": 1724807855106,
"apis": [
{
"name": "boxscore",
"description": "game box score",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "game",
"description": "game statistics",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pbp",
"description": "game play by play",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pitch metrics",
"description": null,
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "events",
"description": "game events",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "statistics",
"description": null,
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "linescore",
"description": "game linescore",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
}
]
},
{
"id": "024fb770-5fdb-11ef-b731-154d1d4eafcf",
"title": "Royals AT Guardians",
"meta": {
"gameId": "f7d3cb9a-9cfe-40a3-8fd1-7714b0ef5654",
"awayTeam": 3651,
"homeTeam": 3650,
"scheduled": "2024-08-28T17:10:00+00:00",
"awayTeamName": "Royals",
"homeTeamName": "Guardians"
},
"league": "mlb",
"scheduled": "2024-08-28T17:10:00.000Z",
"start": 1724864993188,
"end": 1724876267756,
"apis": [
{
"name": "boxscore",
"description": "game box score",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "game",
"description": "game statistics",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pbp",
"description": "game play by play",
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "pitch metrics",
"description": null,
"apiType": "rest",
"formats": [
"json",
"xml"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "events",
"description": "game events",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "statistics",
"description": null,
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
},
{
"name": "linescore",
"description": "game linescore",
"apiType": "push",
"formats": [
"json"
],
"versions": [
"v7"
],
"languages": [
"en"
]
}
]
}
]
}
}
The NFL recording includes the below RESTful endpoints. All are available in json
or xml
.
- Game Boxscore (
boxscore
) - Game Roster (
rosters
) - Game Statistics (
game
) - Play-by-Play (
pbp
)
It also includes these Push feeds, available in json
only:
- Push Events (
events
) - Push Statistics (
statistics
) - Push Pulse (
pulse
)
Available endpoints for other leagues will vary.
Register Your Session
Once you have selected a recording you wish to replay, you may start a session. Start a session using the id
of the desired recording. At this point the specific feed - if multiple feeds are available - does not matter.
Push
Note that this step is unnecessary for our Push simulations. For Push access workflow, click here.
Create a Session Id
Take the recordingId
("id": "95aa13a0-6538-11ef-9287-d597687b4672"
in the above sample) and use it to create a sessionId
.
curl --location --request POST 'https://playback.sportradar.com/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation CreateSession($input: CreateSessionInput!) {\n createSession(input: $input)\n }","variables":{"input":{"recordingId":"95aa13a0-6538-11ef-9287-d597687b4672"}}}'
This request will return your unique sessionId
to be used in subsequent data API requests.
Session Id Sample Response
Here is a sample of a returned sessionId
:
{"data":{"createSession":"60414140-53c7-11ed-bd68-ad2289887b03\_-5507944226"}}
Make an API Request
Now that you have your recordingId
and sessionId
you may create an API call for simulated games.
curl --location --request GET 'https://playback.sportradar.com/replay/nfl/95aa13a0-6538-11ef-9287-d597687b4672?feed=boxscore&contentType=json&sessionId=[sessionId]'
This sample is a Game Boxscore (boxscore
) request for recordingId
95aa13a0-6538-11ef-9287-d597687b4672. Note that you will need to include your unique sessionid
from the previous step.
To receive data updates you can now continually request this path, as you would with live game data in our RESTful APIs. Click here for the complete path parameters.
RESTful Request Path
https://playback.sportradar.com/replay/{league}/{recordingId}?feed={feed}&contentType={contentType}&sessionId={sessionId} |
Path Parameters
Parameter | Description |
---|---|
league | Desired league for the simulation. Baseball: mlb (MLB)Basketball: nba (NBA), nbdl (NBA G League), ncaamb (NCAA Men's Basketball), ncaawb (NCAA Women's Basketball), wnba (WNBA)Football: ncaafb (NCAA Football), nfl (NFL), ufl (UFL)Hockey: nhl (NHL) |
recordingId | ID of the recording. (ex. 95aa13a0-6538-11ef-9287-d597687b4672 ) |
Query String Parameters
Parameter | Description |
---|---|
feed_name | Desired feed for the simulation. Found under apis.name . Feed availability will vary for each API.boxscore , game , pbp , rosters NHL only: analytics , shot_zones , faceoffs , time_on_ice |
contentType | Desired content type.json or xml |
sessionId | Session ID returned by the session request. (ex. aa23f380-2234-11ed-8a8a-cbecc410da60\_-137242789 ) |
Push Request Path
https://playback.sportradar.com/subscribe/{feed_name}?recording_id={recordingId} |
Path Parameters
Parameter | Description |
---|---|
feed_name | Desired feed for the simulation. Found under apis.name .Push feeds are indicated with "apiType": "push" .events , statistics , clock pulse (NFL only), linescore (MLB only) |
recordingId | ID of the recording. (ex. 95aa13a0-6538-11ef-9287-d597687b4672 ) |
Updated 2 months ago