Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TracingInsights/tif1/llms.txt

Use this file to discover all available pages before exploring further.

Function Signature

def get_session(
    year: int,
    gp: str | int,
    session: str | int,
    enable_cache: bool | None = None,
    lib: Literal["pandas", "polars"] | None = None,
) -> Session

Description

Get a session object for accessing lap timing, telemetry, weather, and race control message data from an F1 session. This is the primary entry point for accessing tif1 data. The function returns a Session object that provides access to all session data including laps, telemetry, weather information, and race control messages.

Parameters

year
int
required
Season year (2018-current). Must be within the supported data range.
gp
str | int
required
Grand Prix identifier. Can be either:
  • Event name (e.g., "Abu Dhabi Grand Prix", "British Grand Prix")
  • Round number (e.g., 1 for the first race of the season)
  • Partial/abbreviated name with fuzzy matching (e.g., "Silverstone", "Monaco")
session
str | int
required
Session identifier. Can be either:
  • Full session name: "Practice 1", "Practice 2", "Practice 3", "Qualifying", "Sprint", "Sprint Shootout", "Sprint Qualifying", "Race"
  • Abbreviation: "FP1", "FP2", "FP3", "Q", "S", "SS", "SQ", "R"
  • Session number (1-5) corresponding to the session order for that event
enable_cache
bool | None
default:"None"
Enable persistent caching of fetched data. If None, uses the configured default from config. When enabled, data is cached to disk to speed up subsequent access.
lib
Literal['pandas', 'polars'] | None
default:"None"
DataFrame library choice. If None, uses the configured default (pandas). Options:
  • "pandas": Use pandas DataFrames (default)
  • "polars": Use polars DataFrames for better performance (requires polars installation)

Returns

Session
Session
A Session object with the following key attributes and methods:Attributes:
  • year (int): Season year
  • gp (str): Grand Prix name (URL encoded)
  • session (str): Session name (URL encoded)
  • laps (Laps): DataFrame with all lap timing data
  • drivers (list[str]): List of driver numbers as strings
  • weather (DataFrame): Weather data throughout the session
  • race_control_messages (DataFrame): Race control messages
  • results (SessionResults): Final session results
  • circuit_info (CircuitInfo): Circuit layout information
Methods:
  • load(laps=True, telemetry=True, weather=True, messages=True): Load specific data types
  • get_driver(identifier): Get driver information by number or code

Raises

  • ValueError: If year is out of the supported range (before 2018)
  • ValueError: If the session doesn’t exist for the specified event
  • DataNotFoundError: If data cannot be found for the requested session
  • NetworkError: If network request fails

Examples

Basic Usage

import tif1

# Get a session by event name
session = tif1.get_session(2025, "Abu Dhabi Grand Prix", "Practice 1")

# Access lap data
laps = session.laps
print(laps.head())

# Get driver list
print(session.drivers)

Using Round Number

# Get session using round number (1 = first race of the season)
session = tif1.get_session(2025, 1, "Race")

Using Session Abbreviations

# Using abbreviations for session names
fp1 = tif1.get_session(2025, "Monaco", "FP1")  # Practice 1
qual = tif1.get_session(2025, "Monaco", "Q")    # Qualifying
race = tif1.get_session(2025, "Monaco", "R")    # Race

Using Polars Backend

# Use polars for better performance (requires: pip install polars)
session = tif1.get_session(
    2025, 
    "British Grand Prix", 
    "Qualifying",
    lib="polars"
)

# laps will be a polars DataFrame
laps = session.laps

Selective Data Loading

# Create session but only load specific data types
session = tif1.get_session(2025, "Silverstone", "Race")

# Load only laps and weather, skip telemetry and messages
session.load(laps=True, telemetry=False, weather=True, messages=False)

# Access the loaded data
laps = session.laps
weather = session.weather

Disable Caching

# Disable cache for one-time data access
session = tif1.get_session(
    2025,
    "Monaco Grand Prix",
    "Qualifying",
    enable_cache=False
)

See Also

Build docs developers (and LLMs) love