Live Timing Client - fastf1.livetiming


The live timing client does only support Python 3.8 or 3.9!

This module can be used to save live timing data during a session. It is not possible to do real-time processing of the data.

There are two ways to interact with this module.

  • From a python script by creating an instance of SignalRClient

  • From the command line by calling python -m fastf1.livetiming

Usage Example

  1. Record live timing data during a session

python -m fastf1.livetiming save saved_data.txt
  1. Load this data into FastF1 after the session has finished

import fastf1
from import LiveTimingData

livedata = LiveTimingData('saved_data.txt')
session = fastf1.get_testing_session(2021, 1, 1)

optionally you can load live timing data from two or more files

livedata = LiveTimingData('saved_data_1.txt', 'saved_data_2.txt')

Important Notes

  • You should try to record a full session whenever possible. Recording should start 2-3 minutes before a sessions starts. The api parser may not be able to deal with the data correctly if the beginning of a session is missing. Your mileage may vary depending on what and how much data is missing.

  • You should not mix recorded live timing data and data requested from the api after a session. The data will likely not be synchronized correctly.

  • You should use the cache with saved live timing data too. This will speed up loading of the data considerably after the first run.

  • You need to use different cache directories if you want to cache saved live timing data and api data for the same session! The cache cannot tell the data sources apart. If cached data from one source already exists it will not be reloaded automatically from a different source. See fastf1.req.Cache for details on how to configure a custom cache directory. One simple way is to add the following line to your code:

  • You need to force a cache update if you modify the LiveTimingData (e.g. by adding a second file). The cache cannot tell that the input source was modified and will still use the old cached data.

    You can force-refresh the cache:

    fastf1.Cache.enable_cache('path/to/cache/directory', force_renew=True)

    You only need to use forece_renew=True once after modifying the input data.

  • The SignalR Client seems to get disconnected after 2 hours of recording. It looks like the connection is terminated by the server. You need to manually start a second recording before the first one disconnects if you want to have no gap in your recording.

    Use a different output file name for the second (or any subsequent) recording. You can then load data.LiveTimingData from multiple files. The files need to be provided in chronological order. The content of the files may overlap. Data from overlapping recordings is recognized and will not be loaded as a duplicate.

Command Line Interface

Available commands and options when calling python -m fastf1.livetiming

The module has two main commands

  save          Save live timing data
  extract       Extract messages from saved debug-mode data


The main command for recording live timing data during a session

usage: python -m fastf1.livetiming save [-h] [--append] [--debug]
       [--timeout TIMEOUT] file

positional arguments:
  file               Output file name

optional arguments:
  -h, --help         show this help message and exit
  --append           Append to output file. By default the file is
                     overwritten if it exists already.
  --debug            Enable debug mode: save full SignalR message, not
                     just the data.
  --timeout TIMEOUT  Timeout in seconds after which the client will
                     automatically exit if no data is received


Only for when data was saved with the optional ‘–debug’ argument

Recording in debug mode saves the full SignalR messages as received. The non debug mode saves only the important data part of a message. The data part of each message needs to be extracted to utilize the debug-mode data. The extracted data is the same data you get when saving without the ‘–debug’ argument.

usage: python -m fastf1.livetiming extract [-h] input output

positional arguments:
  input       Input file name
  output      Output file name

optional arguments:
  -h, --help  show this help message and exit

Live Timing Client


Extract data messages from raw recorded SignalR data.

This function can be used to extract message data from raw SignalR data which was saved using SignalRClient in debug mode.


r (Iterable) – Iterable containing raw SignalR responses.

class fastf1.livetiming.client.SignalRClient(filename, filemode='w', debug=False, timeout=60, logger=None)[source]

Bases: object

A client for receiving and saving F1 timing data which is streamed live over the SignalR protocol.

During an F1 session, timing data and telemetry data are streamed live using the SignalR protocol. This class can be used to connect to the stream and save the received data into a file.

The data will be saved in a raw text format without any postprocessing. It is not possible to use this data during a session. Instead, the data can be processed after the session using the fastf1.api and fastf1.core

  • filename – filename (opt. with path) for the output file

  • filemode – one of ‘w’ or ‘a’; append to or overwrite file content it the file already exists. Append-mode may be useful if the client is restarted during a session.

  • debug – When set to true, the complete SignalR message is saved. By default, only the actual data from a message is saved.

  • timeout – Number of seconds after which the client will automatically exit when no message data is received. Set to zero to disable.

  • logger – By default, errors are logged to the console. If you wish to customize logging, you can pass an instance of logging.Logger (see: logging).


Connect to the data stream and start writing the data to a file.

Live Timing Data Object

Data object for livetiming data

class*files, remove_duplicates=True)[source]

Bases: object

Live timing data object for using saved livetiming data as data source.

This object is created from data that was recorded using SignalRClient. It can be passed to various api calling functions using the livedata keyword.

Usually you will only instantiate this function and pass it to other functions.

See fastf1.livetiming for a usage example.

If you want to load data from multiple files you can simply pass multiple filenames:

livedata = LiveTimingData('file1.txt', 'file2.txt', 'file3.txt')

The files need to be in chronological order but may overlap. I.e. if the last five minutes of file1 are the same as the first 5 minutes of file2 this will be recognized while loading the data. No duplicate data will be loaded.

  • *files (str) – One or multiple file names

  • remove_duplicates (bool) – Remove duplicate lines. Mainly useful when loading multiple overlapping recordings. (Checking for duplicates is currently very slow for large files. Therefore, it can be disabled if this may cause problems.)


Read all files, parse the data and store it by category.

Should usually not be called manually. This is called automatically the first time get(), has() or list_categories() are called.


Return data for category name.

Will load data on first call, this will take a bit.


name (str) – name of the category


Check if data for a category name exists.

Will load data on first call, this will take a bit.


name (str) – name of the category


List all available data categories.

Will load data on first call, this will take a bit.


list of category names