FastF1

3.8.2 · active · verified Sat Apr 11

FastF1 is a Python package (version 3.8.2) designed for accessing and analyzing Formula 1 results, schedules, timing data, and telemetry. It provides access to F1 timing data, telemetry, and session results, along with full support for the Ergast-compatible jolpica-f1 API for historical data. All data is provided in extended Pandas DataFrames, facilitating analysis and visualization with Matplotlib integration. It features intelligent caching to optimize performance and minimize API requests.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import FastF1, enable local caching for performance, load a specific Formula 1 race session, and then access basic lap data. The `session.load()` call fetches the data from the API, and caching ensures subsequent calls are faster. It's recommended to load only necessary data (e.g., `telemetry=False` if not needed) to speed up the process.

import fastf1
import os

# Enable caching to a local directory (e.g., 'cache')
cache_dir = os.path.join(os.getcwd(), 'fastf1_cache')
os.makedirs(cache_dir, exist_ok=True)
fastf1.Cache.enable_cache(cache_dir)

# Load a race session (e.g., 2023 Austrian Grand Prix, Race session)
session = fastf1.get_session(2023, 'Austria', 'R')
session.load(telemetry=False, weather=False)

# Print basic session information and first few laps
print(f"Loaded session: {session.event.EventName} - {session.name}")
print(f"Number of laps: {len(session.laps)}")
print("First 5 laps:\n", session.laps.head())

view raw JSON →