f1-cli — Formula 1 Data CLI
A Go CLI wrapping the OpenF1 API for querying F1 telemetry, timing, and session data.
Installation
CODEBLOCK0
Or from source:
CODEBLOCK1
The binary name is f1.
Quick Reference
Global Flags (apply to all commands)
| Flag | Description |
|---|
| INLINECODE1 | Output as JSON (default: table) |
| INLINECODE2 |
Output as CSV |
|
--session KEY | Session key — number or
latest |
|
--meeting KEY | Meeting key — number or
latest |
|
--driver DRIVER | Driver number (44) or 3-letter acronym (HAM) |
|
--limit N | Limit results returned |
|
--filter EXPR | Raw API filter, repeatable (e.g.
speed>=300) |
Commands → API Endpoints
| Command | Endpoint | What it returns |
|---|
| INLINECODE11 | INLINECODE12 | Driver info: name, team, number, acronym |
| INLINECODE13 |
/sessions | Session list (FP1-3, Quali, Sprint, Race) |
|
f1 meetings |
/meetings | Grand Prix weekends (extra:
--year,
--country) |
|
f1 laps |
/laps | Lap times, sector times, speed traps |
|
f1 telemetry |
/car_data | Speed, RPM, gear, throttle, brake, DRS at ~3.7 Hz |
|
f1 pit |
/pit | Pit stop timing and duration |
|
f1 positions |
/position | Position changes throughout session |
|
f1 intervals |
/intervals | Gap to leader and car ahead (race only) |
|
f1 standings drivers |
/championship_drivers | Driver championship points (race sessions) |
|
f1 standings teams |
/championship_teams | Constructor standings (race sessions) |
|
f1 weather |
/weather | Track temp, air temp, humidity, wind, rain |
|
f1 race-control |
/race_control | Flags, safety car, incidents |
|
f1 radio |
/team_radio | Team radio recording URLs |
|
f1 stints |
/stints | Tire compound and stint laps |
|
f1 overtakes |
/overtakes | Position exchanges between drivers |
|
f1 location |
/location | Car XYZ position on track (~3.7 Hz) |
|
f1 doctor | — | API connectivity check |
Usage Patterns
Finding the right session
Most commands need --session. Start with latest for the most recent session, or find a specific one:
CODEBLOCK2
Driver identification
The --driver flag accepts either a number or a 3-letter acronym. The CLI resolves acronyms automatically via the API.
CODEBLOCK3
Common driver acronyms: VER (Verstappen), NOR (Norris), HAM (Hamilton), LEC (Leclerc), PIA (Piastri), SAI (Sainz), RUS (Russell), ALO (Alonso).
Filtering with comparison operators
The --filter flag passes raw query params to the API. Supports >=, <=, >, < operators. Can be repeated.
CODEBLOCK4
Output formats
CODEBLOCK5
Common Workflows
"Who won the last race?"
# Always use standings for final race results
f1 standings drivers --session latest
Do NOT use f1 positions for race results. Positions is a time series — it records every position change throughout the session. Using
--limit on positions gives you the
start of the race, not the finish. Use
f1 standings drivers for the final classification.
"Compare two drivers' lap times"
CODEBLOCK7
"What happened during the race?" (incidents, flags)
CODEBLOCK8
"Tire strategy breakdown"
CODEBLOCK9
"Weather conditions during the session"
CODEBLOCK10
"Fastest pit stops"
CODEBLOCK11
Important Gotchas
- -
--limit is client-side only. The OpenF1 API does not support a limit query parameter. The CLI fetches all results then truncates locally. This means large telemetry/location queries still hit the API fully — use --filter to narrow server-side when possible. --filter is server-side. Filters like speed>=300 are sent to the API and reduce the response. Always prefer --filter over --limit for performance.positions is a time series, not a result. It records every position change during a session. To get final race results, use f1 standings drivers --session <key>, not f1 positions. Using positions --limit N gives you lap 1 grid order, not the finish.- Driver numbers change between seasons. Don't hardcode driver numbers — use acronyms (VER, HAM, NOR) which the CLI resolves automatically per session.
- Norris is now #1. For the 2026 season, Lando Norris drives car #1 (as reigning champion). Verstappen is #3.
API Notes
- - Data availability: Historical data from 2023 season onwards. No auth needed.
- Rate limits: 3 requests/second, 30 requests/minute (free tier). The CLI handles rate limiting internally with retry on 429.
latest keyword: Works for both --session and --meeting to get the most recent.- Intervals and overtakes: Only available during race sessions, not practice or qualifying.
- Championship standings: Only available for race sessions.
- Telemetry and location: High-frequency data (~3.7 Hz) — use
--filter to narrow results server-side, then --limit to cap output. - Off-season:
--session latest returns 404 when no sessions exist. Use a known session_key from a past season instead.
f1-cli — 一级方程式数据命令行工具
一个封装了 OpenF1 API 的 Go 语言命令行工具,用于查询 F1 遥测数据、计时数据和赛段信息。
安装
bash
brew tap barronlroth/tap
brew install f1-cli
或从源码安装:
bash
go install github.com/barronlroth/f1-cli/cmd/f1@latest
二进制文件名为 f1。
快速参考
全局标志(适用于所有命令)
| 标志 | 描述 |
|---|
| --json | 以 JSON 格式输出(默认:表格) |
| --csv |
以 CSV 格式输出 |
| --session KEY | 赛段键值 — 数字或 latest |
| --meeting KEY | 会议键值 — 数字或 latest |
| --driver DRIVER | 车手编号(44)或3字母缩写(HAM) |
| --limit N | 限制返回结果数量 |
| --filter EXPR | 原始 API 过滤器,可重复使用(例如 speed>=300) |
命令 → API 端点
| 命令 | 端点 | 返回内容 |
|---|
| f1 drivers | /drivers | 车手信息:姓名、车队、编号、缩写 |
| f1 sessions |
/sessions | 赛段列表(练习赛1-3、排位赛、冲刺赛、正赛) |
| f1 meetings | /meetings | 大奖赛周末(额外:--year、--country) |
| f1 laps | /laps | 单圈时间、分段时间、速度陷阱 |
| f1 telemetry | /car_data | 速度、转速、档位、油门、刹车、DRS(约3.7 Hz) |
| f1 pit | /pit | 进站时间和时长 |
| f1 positions | /position | 赛段中的位置变化 |
| f1 intervals | /intervals | 与领先者和前车的差距(仅正赛) |
| f1 standings drivers | /championship_drivers | 车手锦标赛积分(正赛赛段) |
| f1 standings teams | /championship_teams | 制造商积分榜(正赛赛段) |
| f1 weather | /weather | 赛道温度、空气温度、湿度、风速、降雨 |
| f1 race-control | /race_control | 旗帜、安全车、事故 |
| f1 radio | /team_radio | 车队无线电录音链接 |
| f1 stints | /stints | 轮胎配方和赛段圈数 |
| f1 overtakes | /overtakes | 车手之间的位置交换 |
| f1 location | /location | 赛车在赛道上的XYZ位置(约3.7 Hz) |
| f1 doctor | — | API 连接检查 |
使用模式
查找正确的赛段
大多数命令需要 --session。使用 latest 获取最近的赛段,或查找特定赛段:
bash
列出最近会议的所有赛段
f1 sessions --meeting latest
查找特定大奖赛
f1 meetings --year 2025 --country Singapore
然后使用输出中的 session_key
f1 laps --session 9161 --driver VER
车手识别
--driver 标志接受数字或3字母缩写。CLI 通过 API 自动解析缩写。
bash
以下命令等效
f1 laps --session latest --driver 1
f1 laps --session latest --driver VER
常用车手缩写:VER(维斯塔潘)、NOR(诺里斯)、HAM(汉密尔顿)、LEC(勒克莱尔)、PIA(皮亚斯特里)、SAI(塞恩斯)、RUS(拉塞尔)、ALO(阿隆索)。
使用比较运算符过滤
--filter 标志将原始查询参数传递给 API。支持 >=、<=、>、< 运算符。可重复使用。
bash
速度超过315 km/h的赛车
f1 telemetry --session 9159 --driver 55 --filter speed>=315
进站时间低于2.5秒
f1 pit --session latest --filter stop_duration<2.5
组合多个过滤器
f1 telemetry --session latest --driver VER --filter speed>=300 --filter throttle>=95
单圈时间低于90秒
f1 laps --session latest --filter lap_duration<90
输出格式
bash
默认:对齐表格
f1 drivers --session latest
JSON格式,便于管道传输到jq或其他工具
f1 telemetry --session latest --driver VER --json | jq .[0].speed
CSV格式,用于电子表格
f1 laps --session latest --driver HAM --csv > hamilton_laps.csv
常见工作流程
上一场比赛谁赢了?
bash
始终使用 standings 获取最终比赛结果
f1 standings drivers --session latest
不要使用 f1 positions 获取比赛结果。 Positions 是一个时间序列——它记录赛段中每一次位置变化。在 positions 上使用 --limit 会得到比赛的开始,而不是结束。使用 f1 standings drivers 获取最终排名。
比较两位车手的单圈时间
bash
f1 laps --session latest --driver VER --json > /tmp/ver.json
f1 laps --session latest --driver NOR --json > /tmp/nor.json
然后比较这两个JSON文件
比赛中发生了什么?(事故、旗帜)
bash
f1 race-control --session latest
轮胎策略分析
bash
f1 stints --session latest --driver VER
赛段期间的天气状况
bash
f1 weather --session latest --limit 10
最快进站
bash
f1 pit --session latest --filter stop
duration<3 --json | jq sortby(.stop_duration)
重要注意事项
- - --limit 仅限客户端。 OpenF1 API 不支持 limit 查询参数。CLI 会获取所有结果,然后在本地截断。这意味着大型遥测/位置查询仍然会完整请求 API——尽可能使用 --filter 在服务端缩小范围。
- --filter 在服务端生效。 像 speed>=300 这样的过滤器会发送到 API 并减少响应数据。为了性能,始终优先使用 --filter 而非 --limit。
- positions 是时间序列,不是结果。 它记录赛段中每一次位置变化。要获取最终比赛结果,使用 f1 standings drivers --session ,而不是 f1 positions。使用 positions --limit N 会得到第一圈的发车顺序,而不是完赛结果。
- 车手编号在不同赛季会变化。 不要硬编码车手编号——使用缩写(VER、HAM、NOR),CLI 会根据赛段自动解析。
- 诺里斯现在是1号。 对于2026赛季,兰多·诺里斯驾驶1号赛车(作为卫冕冠军)。维斯塔潘是3号。
API 说明
- - 数据可用性: 2023赛季及之后的历史数据。无需认证。
- 速率限制: 3次请求/秒,30次请求/分钟(免费层)。CLI 内部处理速率限制,遇到429状态码会自动重试。
- latest 关键字: 适用于 --session 和 --meeting,用于获取最新数据。
- 间隔和超车: 仅在正赛赛段可用,练习赛和排位赛不可用。
- 锦标赛积分榜: 仅适用于正赛赛段。
- 遥测和位置: 高频数据(约3.7 Hz)——使用 --filter 在服务端缩小结果范围,然后使用 --limit 限制输出。
- 休赛期: 当没有赛段时,--session latest 会返回404。请使用过去赛季的已知 session_key。