get_position_changes
Retrieve lap-by-lap positions and gaps to leader to see how an F1 race unfolded, who gained places, and when leads changed.
Instructions
Get how a race unfolded: lap-by-lap positions, gaps to the leader, positions gained from the grid, laps led and lead changes.
Data source: FastF1 Live Timing Coverage: 2018-present
Use for "how did the race unfold", "who gained the most places", "when did X take the lead", "how far behind was Y at half distance", or "how many places did Z make up on lap 1".
Args:
year: Season year (2018+)
event: Race name or round number
session: "R" (race, default) or "S" (sprint)
drivers: Optional driver codes to include (e.g. ["VER", "NOR"]).
The session-wide summary always covers the full field.
include_laps: Include the per-lap positions and gapsToLeaderSec
arrays for each driver (default True). Set False for
a compact grid→finish movement table.
export_path: If True (or a directory / .csv path), write a long
format CSV (one row per driver per lap: lap, driver,
position, gapToLeaderSec) and omit the per-lap arrays.
Returns: { "totalLaps": 57, "summary": { "winner": "VER", "lapLeaders": {"VER": 50, "LEC": 7}, "leadChanges": [{"lap": 21, "from": "VER", "to": "LEC"}, ...], "biggestGainers": [{"driver": "HAM", "grid": 18, "finish": 6, "positionsGained": 12}, ...], "biggestLosers": [...] }, "drivers": [ {"driver": "VER", "fullName": "Max Verstappen", "teamName": "Red Bull Racing", "grid": 1, "finish": 1, "status": "Finished", "positionsGained": 0, "lap1Gain": 0, "lapsLed": 50, "bestPosition": 1, "worstPosition": 2, "positions": [1, 1, 1, ...], "gapsToLeaderSec": [0.0, 0.0, ...]}, ... ] }
Note:
positions[i] / gapsToLeaderSec[i] are for lap i+1. The gap is
the time between the leader completing that lap and this driver
completing the same lap (the classic "race history" gap, so lapped
cars show their full deficit). Pit-lane starters have grid 0 in
the source data; their gain is computed from the back of the grid.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"year": "<year>",
"event": "<event>"
},
"name": "get_position_changes"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | ||
| event | Yes | ||
| drivers | No | ||
| session | No | R | |
| export_path | No | ||
| include_laps | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||