@apicity/ openf1 (中文(简体) )
OpenF1 API 用于公式 1 的历史和认证的活的 REST 数据的提供者.
运行时间依赖性 :
zod@^4.6.6— 请求OpenF1端点方法附加的策略为.schema
安装
npm install @apicity/openf1
# or
pnpm add @apicity/openf1
快速启动
import { createOpenF1 } from "@apicity/openf1";
const openf1 = createOpenF1();
REST 实例
OpenF1历史REST数据公开,不需要API密钥.
import { createOpenF1 } from "@apicity/openf1";
const openf1 = createOpenF1();
const meetings = await openf1.v1.meetings({
year: 2024,
country_name: ["Singapore", "Monaco"],
});
const recentMeetings = await openf1.v1.meetings({
filters: [
{ field: "date_start", op: ">=", value: "2024-01-01T00:00:00Z" },
],
});
使用数组重复平等过滤和 filters 用于 OpenF1
比较运算符,例如 >=, (中文(简体) ), <,以及 >。 。 。 .
认证的 REST
OpenF1 实时 REST 访问使用相同的 /v1/{collection} 结束点为
持枪者标志。 见 OpenF1 认证指南
对于上游标志合同.
import { createOpenF1 } from "@apicity/openf1";
const openf1 = createOpenF1();
const token = await openf1.token({
username: "[email protected]",
password: "placeholder-password",
});
const liveOpenF1 = createOpenF1({
accessToken: token.access_token,
});
const liveSessions = await liveOpenF1.v1.sessions({
session_key: "latest",
});
对于可刷新代币,提供 tokenProvider。供应商被称为
对于 REST 读取, 此软件包不存储证书或符号
在客户实例之外.
declare function fetchTokenSomewhereElse(): Promise<{ access_token: string }>;
const openf1 = createOpenF1({
tokenProvider: async () => {
const token = await fetchTokenSomewhereElse();
return token.access_token;
},
});
API 参考
19个端点横跨了19个组. 每个方法都映射出上游的 URL 路径 .
车数据
GET openf1.v1.carData
GET https://api.openf1.org/v1/car_data{query}
成本等级 : cheap
const res = await openf1.v1.carData({ /* ... */ });
锦标赛司机
GET openf1.v1.championshipDrivers
GET https://api.openf1.org/v1/championship_drivers{query}
成本等级 : cheap
const res = await openf1.v1.championshipDrivers({ /* ... */ });
冠军团队
GET openf1.v1.championshipTeams
GET https://api.openf1.org/v1/championship_teams{query}
成本等级 : cheap
const res = await openf1.v1.championshipTeams({ /* ... */ });
驱动程序
GET openf1.v1.drivers
GET https://api.openf1.org/v1/drivers{query}
成本等级 : cheap
const res = await openf1.v1.drivers({ /* ... */ });
间隔
GET openf1.v1.intervals
GET https://api.openf1.org/v1/intervals{query}
成本等级 : cheap
const res = await openf1.v1.intervals({ /* ... */ });
轮
GET openf1.v1.laps
GET https://api.openf1.org/v1/laps{query}
成本等级 : cheap
const res = await openf1.v1.laps({ /* ... */ });
地点
GET openf1.v1.location
GET https://api.openf1.org/v1/location{query}
成本等级 : cheap
const res = await openf1.v1.location({ /* ... */ });
会议
GET openf1.v1.meetings
GET https://api.openf1.org/v1/meetings{query}
成本等级 : cheap
const res = await openf1.v1.meetings({ /* ... */ });
超过数
GET openf1.v1.overtakes
GET https://api.openf1.org/v1/overtakes{query}
成本等级 : cheap
const res = await openf1.v1.overtakes({ /* ... */ });
隐藏
GET openf1.v1.pit
GET https://api.openf1.org/v1/pit{query}
成本等级 : cheap
const res = await openf1.v1.pit({ /* ... */ });
职位
GET openf1.v1.position
GET https://api.openf1.org/v1/position{query}
成本等级 : cheap
const res = await openf1.v1.position({ /* ... */ });
种族控制
GET openf1.v1.raceControl
GET https://api.openf1.org/v1/race_control{query}
成本等级 : cheap
const res = await openf1.v1.raceControl({ /* ... */ });
会 议
GET openf1.v1.sessionResult
GET https://api.openf1.org/v1/session_result{query}
成本等级 : cheap
const res = await openf1.v1.sessionResult({ /* ... */ });
会议
GET openf1.v1.sessions
GET https://api.openf1.org/v1/sessions{query}
成本等级 : cheap
const res = await openf1.v1.sessions({ /* ... */ });
开始 网格
GET openf1.v1.startingGrid
GET https://api.openf1.org/v1/starting_grid{query}
成本等级 : cheap
const res = await openf1.v1.startingGrid({ /* ... */ });
缩写
GET openf1.v1.stints
GET https://api.openf1.org/v1/stints{query}
成本等级 : cheap
const res = await openf1.v1.stints({ /* ... */ });
团队电台
GET openf1.v1.teamRadio
GET https://api.openf1.org/v1/team_radio{query}
成本等级 : cheap
const res = await openf1.v1.teamRadio({ /* ... */ });
符号
POST openf1.token
POST https://api.openf1.org/token
成本等级 : cheap
const token = await openf1.token({
username: "[email protected]",
password: "placeholder-password",
});
天气
GET openf1.v1.weather
GET https://api.openf1.org/v1/weather{query}
成本等级 : cheap
const res = await openf1.v1.weather({ /* ... */ });
部分 辣点 单相机.
许可证
麻省理工学院——见 自由主义。 。 。 .