The core module is the heart of tif1, providing the primary interface for loading and working with Formula 1 data. All data access flows through the
Session object, which serves as the central hub for accessing laps, telemetry, weather, race control messages, and driver information. The API is designed for maximum performance with async support, intelligent caching, and lazy loading patterns.Overview
The core API is built around a hierarchical data model that mirrors the structure of Formula 1 sessions:-
Lazy Loading: Data is fetched only when accessed, minimizing unnecessary network requests. Properties like
session.laps,session.weather, andlap.telemetrytrigger data loading on first access. - Intelligent Caching: Multi-layer caching strategy with in-memory LRU cache (instant access) and SQLite persistent cache (survives restarts). Cache keys are session-specific and backend-aware (pandas vs polars).
-
Async Support: All data-intensive operations have async variants (
laps_async(),get_fastest_laps_tels_async()) that use parallel HTTP requests for 4-5x faster loading compared to sequential access. - Backend Flexibility: Choose between pandas (default, maximum compatibility) or polars (faster for large datasets, 10-100x speedup for some operations) for DataFrame operations. Backend selection is per-session and affects all data structures.
-
FastF1 Compatibility: Drop-in replacement for FastF1 with the same API surface. All FastF1 methods (
pick_driver(),pick_fastest(),iterlaps(), etc.) are supported with identical behavior. - Ultra-Cold Mode: Special optimization mode that bypasses cache validation and skips loading unnecessary data for minimal latency. Ideal for serverless environments or when you only need specific data (e.g., fastest lap telemetry).
-
Error Resilience: Comprehensive exception hierarchy (
DataNotFoundError,NetworkError,InvalidDataError) with structured error context. Failed telemetry fetches are tracked per-driver to avoid repeated failures.
| Operation | Cold Cache | Warm Cache | Notes |
|---|---|---|---|
session.laps | 2-4s | <100ms | Auto-async parallel loading |
laps_async() | 0.5-1s | <100ms | Explicit async, 4-5x faster |
get_fastest_lap_tel() | 200-500ms | <50ms | Single telemetry fetch |
get_fastest_laps_tels() | 300-800ms | <100ms | Parallel telemetry for multiple drivers |
ultra_cold=True | 100-300ms | N/A | Skips cache validation |
- Session metadata: ~10-50 KB
- Laps DataFrame (20 drivers, 60 laps): ~500 KB - 2 MB
- Single lap telemetry: ~50-200 KB (varies by track length)
- Full session telemetry (all laps): ~50-200 MB (rarely needed)
- Session objects are thread-safe for read operations
- Internal caches use threading locks for concurrent access
- Async methods can be called from multiple coroutines safely
get_session
The main entry point for loading F1 session data. This function handles event name resolution, session validation, and returns a configured Session object ready to load data.
Season year (2018-current). Must be within the supported range.Valid range: 2018 to current seasonExample:
2024, 2025Grand Prix identifier. Can be specified in multiple ways:
- Full name:
"Monaco Grand Prix","British Grand Prix" - Abbreviated name:
"Monaco","Silverstone"(uses fuzzy matching) - Round number:
6,12(1-indexed, based on calendar order)
"Monaco Grand Prix", "Monaco", 6Session identifier. Can be specified as:
- Full name:
"Practice 1","Qualifying","Race" - Abbreviated:
"FP1","FP2","FP3","Q","S"(Sprint),"R" - Session number:
1(Practice 1),2(Practice 2),3(Practice 3),4(Qualifying),5(Race)
"Qualifying", "Q", 4Enable or disable caching for this session.
True: Enable caching (recommended for production)False: Disable caching (useful for testing or forcing fresh data)None: Use global config value (default behavior)
~/.tif1/cache/tif1_cache.dbDataFrame library choice for data representation.
"pandas": Use pandas DataFrames (default, maximum compatibility)"polars": Use polars DataFrames (faster for large datasets, requirespolarspackage)None: Use global config value (defaults to"pandas")
polars package to be installed. If polars is requested but not available, tif1 automatically falls back to pandas with a warning.A configured
Session object ready to load data. The session is not loaded until you access its properties (lazy loading) or explicitly call session.load().Raised in the following cases:
- Year is outside the supported range (< 2018 or > current season)
- Grand Prix name/round cannot be resolved
- Session name/number doesn’t exist for the specified event
- Session number is out of range for the event
Raised when the specified year, GP, or session doesn’t exist in the data source.
Raised when all CDN sources fail to respond or return errors.
Event Name Resolution: The function uses fuzzy matching to resolve abbreviated event names. For example,
"Silverstone" resolves to "British Grand Prix", and "Spa" resolves to "Belgian Grand Prix". If fuzzy matching fails, the original string is used as-is.Session
TheSession object is the central hub for all data related to a specific F1 weekend session. It provides access to lap timing data, telemetry, weather conditions, race control messages, driver information, and session results.
Design Philosophy:
- Lazy Loading: Properties are loaded on first access, not at construction time
- Caching: All fetched data is cached (when enabled) to minimize network requests
- Immutable Identity: Once created, a session’s year/GP/session cannot be changed
- Thread-Safe: Internal caches use locks for concurrent access
- Memory Efficient: Only requested data is loaded into memory
Constructor
Season year (2018-current). Must be within the supported range.
URL-encoded Grand Prix name (e.g.,
"Monaco_Grand_Prix"). Spaces should be replaced with underscores or %20.Note: get_session() handles this encoding automatically.URL-encoded session name (e.g.,
"Qualifying", "Race").Enable/disable caching. If
None, uses global config value.DataFrame library choice. If
None, uses global config value (defaults to "pandas").Properties
The season year (e.g., 2025).
URL-encoded Grand Prix name (e.g., “Monaco_Grand_Prix”).
URL-encoded session name (e.g., “Qualifying”, “Race”).
The DataFrame lib being used for this session.
Whether caching is enabled for this session.
List of driver numbers as strings in the session (e.g., [“1”, “33”, “44”]).
Loaded lazily on first access.
This returns driver NUMBERS, not driver codes. For driver codes (e.g., “VER”, “HAM”), use
drivers_df["Driver"].Alias for
drivers property. Returns driver numbers as strings.DataFrame with driver information including:
Abbreviation: 3-letter driver code (e.g., “VER”, “HAM”)TeamName: Team nameDriverNumber: Car number as stringFirstName: Driver’s first nameLastName: Driver’s last nameFullName: Full name (FirstName + LastName)TeamColor: Hex color codeHeadshotUrl: URL to driver photo
All laps for all drivers. Includes weather data automatically merged.
Loaded lazily on first access. Use
laps_async() for faster parallel loading.Weather data recorded during the session with columns:
Time: TimestampAirTemp: Air temperature (°C)TrackTemp: Track temperature (°C)Humidity: Relative humidity (%)Pressure: Atmospheric pressure (mbar)WindSpeed: Wind speed (km/h)WindDirection: Wind direction (degrees)Rainfall: Rainfall indicator
Alias for
weather property.Official messages from Race Control with columns:
Time: Message timestampCategory: Message category (e.g., “Flag”, “SafetyCar”)Message: Message textStatus: Track status codeFlag: Flag typeScope: Message scopeSector: Affected sectorRacingNumber: Affected driver number
Final classification/results for the session. Contains:
Position: Final positionDriver: Driver codeTeam: Team namePoints: Championship points earnedStatus: Finish statusTime: Total time or gap
Car telemetry data aggregated across all laps with columns:
Time: TimestampSpeed: Speed (km/h)RPM: Engine RPMnGear: Gear numberThrottle: Throttle position (%)Brake: Brake statusDRS: DRS status
Position data for all cars with columns:
Time: TimestampX,Y,Z: 3D coordinates (meters)Status: Car statusDriver: Driver code
Session metadata including start time, circuit info, and session status.
Human-readable session name (e.g., “Monaco Grand Prix - Qualifying”).
Session date and time.
Event information including circuit details and schedule.
Official session start time.
Reference time (t=0) for the session.
Session status changes throughout the session.
Track status changes (flags, safety car, etc.) with timestamps.
Total number of laps completed in the session.
This property is not yet implemented and currently returns
None.Methods
load()
laps: Load lap timing datatelemetry: Prefetch telemetry for all laps (expensive)weather: Load weather datamessages: Load race control messages
- Self (for method chaining)
laps_async()
- DataFrame with all laps
get_driver()
Driver object for the specified driver.
Parameters:
driver: 3-letter driver code (e.g., “VER”) or driver number (e.g., 33)
Driverobject
DriverNotFoundError: If the driver doesn’t exist in this session
get_fastest_laps()
by_driver: IfTrue, returns fastest lap per driver. IfFalse, returns single overall fastest lapdrivers: Optional list of driver codes to filter. IfNone, includes all drivers
- DataFrame with fastest lap(s)
get_fastest_laps_async()
get_fastest_laps() for parallel data fetching.
get_fastest_lap_tel()
ultra_cold: Enable ultra-low latency mode. IfNone, uses global config
- DataFrame with telemetry data
get_fastest_lap_tel_async()
get_fastest_lap_tel().
get_fastest_laps_tels()
by_driver: IfTrue, gets fastest lap per driver. IfFalse, gets overall fastestdrivers: Optional list of driver codes to filterultra_cold: Enable ultra-low latency mode
- Dictionary mapping driver codes to telemetry DataFrames
get_fastest_laps_tels_async()
get_fastest_laps_tels().
fetch_driver_laps_parallel()
drivers: List of driver codes
- Dictionary mapping driver codes to lap DataFrames
fetch_all_laps_telemetry()
drivers: Optional list of driver codes. IfNone, fetches for all driversultra_cold: Enable ultra-low latency mode
- Dictionary mapping (driver, lap_number) tuples to telemetry DataFrames
fetch_all_laps_telemetry_async()
fetch_all_laps_telemetry(). Fetches telemetry for all laps in parallel, significantly faster than the sync version.
Performance: 5-10x faster than sync version due to parallel HTTP requests.
Example:
get_circuit_info()
CircuitInfoobject with:corners: DataFrame with columnsX, Y, Number, Letter, Angle, Distancemarshal_lights: Empty DataFrame (not available in data source)marshal_sectors: Empty DataFrame (not available in data source)rotation: Circuit rotation in degrees (float)
FastF1 Compatibility: This method returns a
CircuitInfo dataclass that is fully compatible with FastF1’s mvapi.CircuitInfo. The add_marker_distance() method works identically to FastF1’s implementation.Driver
Represents a specific driver’s performance within a session. Provides convenient access to driver-specific lap data and telemetry. TheDriver class extends pd.Series, so driver metadata is accessible as Series data.
Design Philosophy:
- Lazy Loading: Lap data is loaded on first access to
driver.laps - Efficient Filtering: When session laps are already loaded, driver laps are filtered in-place without additional network requests
- Prefetching: The
get_driver()method can prefetch driver laps in parallel with driver metadata for faster initialization - Caching: Lap index maps are cached for O(1) lap number lookups
- First access to
driver.laps: 200-500ms (cold cache), <50ms (warm cache) - Subsequent access: <1ms (in-memory reference)
get_lap(n): O(1) lookup using cached index mapget_fastest_lap(): O(n) scan of lap times (typically <1ms for 60 laps)
Constructor
Use
session.get_driver() instead of constructing Driver directly. The Driver class extends pd.Series and contains driver metadata as Series data.Properties
The 3-letter driver code (e.g., “VER”, “HAM”, “LEC”).
All laps completed by this driver. Loaded lazily on first access.
Contains all lap timing data including sector times, compounds, stint info, etc.
Reference to the parent session object.
Series Data
SinceDriver extends pd.Series, driver metadata is accessed via dictionary-style indexing:
driver["DriverNumber"]: Car number as string (e.g., “33”, “44”, “16”)driver["Abbreviation"]: 3-letter driver code (same asdriver.driver)driver["TeamName"]: Team name (e.g., “Red Bull Racing”, “Mercedes”)driver["TeamColor"]: Hex color codedriver["FirstName"]: Driver’s first namedriver["LastName"]: Driver’s last namedriver["FullName"]: Full name (FirstName + LastName)driver["HeadshotUrl"]: URL to driver photo
Methods
get_lap()
lap_number: The lap number to retrieve (1-indexed)
Lapobject for the specified lap
LapNotFoundError: If the lap doesn’t exist for this driver
get_fastest_lap()
- Single-row DataFrame with the fastest lap data
get_fastest_lap_tel()
- DataFrame with telemetry data (Time, Speed, RPM, Throttle, etc.)
Laps
TheLaps class extends pd.DataFrame and provides a rich set of methods for filtering and analyzing lap timing data. It represents a collection of laps (either for all drivers or a specific driver) with FastF1-compatible filtering methods.
Design Philosophy:
- DataFrame Extension: Inherits all pandas DataFrame methods while adding F1-specific functionality
- Method Chaining: Most methods return new
Lapsobjects, enabling fluent API patterns - FastF1 Compatibility: All
pick_*methods match FastF1’s behavior exactly - Lazy Telemetry: The
telemetryproperty loads telemetry only when accessed
Filtering Methods
pick_driver(identifier) / pick_drivers(identifiers)
Filter laps by driver(s). Accepts driver codes, numbers, or driver objects.
pick_lap(lap_number) / pick_laps(laps)
Filter by lap number(s). Supports individual numbers, lists, or slices.
pick_team(name) / pick_teams(names)
Filter laps by team name(s).
pick_fastest(only_by_time=False)
Get the single fastest lap from the collection.
Lap object (pd.Series) or None if no valid laps.
pick_quicklaps(threshold=1.07)
Filter laps within a percentage of the fastest lap time. Default threshold is 107% (7% slower than fastest).
pick_tyre(compound) / pick_compounds(compounds)
Filter laps by tire compound.
"SOFT", "MEDIUM", "HARD", "INTERMEDIATE", "WET"
pick_track_status(status, how="equals")
Filter laps by track status code.
"1": Green flag (normal racing)"2": Yellow flag"4": Safety Car"5": Red flag"6": Virtual Safety Car (VSC)"7": VSC ending
how="equals": Exact match (default)how="contains": Partial match (useful for compound status codes)
pick_wo_box() / pick_box_laps(which="both")
Filter laps by pit stop activity.
pick_not_deleted() / pick_accurate()
Filter laps by data quality flags.
Data Access Methods
get_telemetry() / get_car_data() / get_pos_data()
Get telemetry data for the laps. All three methods return the same data (FastF1 compatibility).
Telemetry DataFrame with columns: Time, Speed, RPM, Throttle, Brake, nGear, DRS, X, Y, Z, Distance
Note: Only works for single-driver laps. Raises ValueError if laps contain multiple drivers.
get_weather_data()
Get weather data for the session.
split_qualifying_sessions()
Split qualifying laps into Q1, Q2, Q3 sessions.
Laps objects (Q1, Q2, Q3). If qualifying session markers are unavailable, returns three copies of the full laps DataFrame.
iterlaps(require=None)
Iterate over laps with optional column requirements. Yields (index, lap) tuples where lap is a Lap object.
require: Optional list of column names that must be non-null. Laps with null values in these columns are skipped.
_IterLapResult tuples with:
.index: DataFrame index of the lap.lap:Lapobject (pd.Series) with session reference[column_name]: Direct column access (e.g.,result["Driver"])
Utility Methods
reset_index(drop=False, **kwargs)
Reset DataFrame index. Automatically removes level_0 column if created.
Properties
telemetry
Get telemetry for all laps in the collection. Only works for single-driver laps.
Telemetry DataFrame (concatenated telemetry from all laps).
Raises: ValueError if laps contain multiple drivers.
Example: Complex Filtering
Lap
Represents a single lap, providing access to high-frequency telemetry data. This is a lightweight wrapper around lap timing data with lazy telemetry loading. TheLap class extends pd.Series, so lap data is accessible as Series data.
Constructor
Use
driver.get_lap() instead of constructing Lap directly.Properties
The lap number (1-indexed). Access via
lap.lap_number property.The 3-letter driver code. Access via
lap.driver property.High-frequency telemetry data for this lap. Loaded lazily on first access.
Contains Time, Speed, RPM, Throttle, Brake, nGear, DRS, and position data.
Reference to the parent session object.
Series Data
SinceLap extends pd.Series, lap timing data is accessed via dictionary-style indexing or the get() method:
lap.get('LapTime'): Lap time as timedeltalap.get('LapTimeSeconds'): Lap time in seconds as floatlap.get('LapNumber'): Lap number (same aslap.lap_number)lap.get('Driver'): Driver code (same aslap.driver)lap.get('Sector1Time'),lap.get('Sector2Time'),lap.get('Sector3Time'): Sector timeslap.get('Compound'): Tire compoundlap.get('TyreLife'): Tire age in lapslap.get('IsPersonalBest'): Boolean indicating personal best lap
Methods
get_telemetry()
telemetry property.
Returns:
- DataFrame with telemetry samples
get_car_data()
- DataFrame with car telemetry channels
get_pos_data()
- DataFrame with position data
get_weather_data()
- DataFrame with weather information
Complete Examples
Basic session usage
Working with Drivers
Working with Telemetry
Available Telemetry Columns:
Time: Timestamp (timedelta)Speed: Speed in km/hRPM: Engine RPMThrottle: Throttle position (0-100%)Brake: Brake status (boolean or 0-100%)nGear: Gear numberDRS: DRS statusX,Y,Z: 3D position coordinates (meters)Distance: Distance along track (meters)
Parallel data loading
Ultra-cold start mode
Ultra-cold mode bypasses cache validation and skips loading unnecessary data for faster cold starts.
Use when you need minimal latency and don’t need all session data. The trade-off is that some
data validation is skipped.
Error Handling
Performance Comparison
Troubleshooting
Common Issues
Issue:DriverNotFoundError when using driver codes
LapNotFoundError when accessing laps
Related Pages
API Overview
Complete API map
Models
Data structures
Sessions Concept
Understanding sessions
Getting Started
Usage guide