OpenF1 Client
A lightweight, zero-dependency TypeScript client for the OpenF1 API.
Features
- ✅ Written in TypeScript with full type support.
- ✅ Zero-dependencies.
- ✅ ES Module.
- ✅ Simple and easy to use.
Installation
npm install openf1-client
Usage
Here's a quick example of how to use the client to fetch session data:
import { OpenF1Client } from 'openf1-client'
const client = new OpenF1Client()
async function getSpanishGrandPrixSession() {
try {
const sessions = await client.getSessions({
meetingKey: 1229,
sessionName: 'Race'
})
console.log(sessions)
} catch (error) {
console.error('Error fetching sessions:', error)
}
}
getSpanishGrandPrixSession()
Client Options
By default, the client returns data with snake_case
keys, as provided by the OpenF1 API. You can enable automatic camelCase conversion during client initialization:
const client = new OpenF1Client({ camelize: true })
If you would like additional info about the requests being made by the client, you can enable the debug option:
const client = new OpenF1Client({ debug: true })
API
The client provides methods for all supported OpenF1 API endpoints:
getCarData(params)
getDrivers(params)
getIntervals(params)
getLaps(params)
getLocation(params)
getMeetings(params)
getPit(params)
getPosition(params)
getRaceControl(params)
getSessions(params)
getSessionResults(params)
(beta)
getStartingGrid(params)
(beta)
getStints(params)
getTeamRadio(params)
getWeather(params)
For detailed information on available query parameters for each endpoint, please refer to the official OpenF1 API Documentation.
Contributing
Contributions are welcome! Please open an issue or submit a merge request.
License
MIT