A Python toolkit for seamless access to live and historical Formula 1 data.
Project description
LiveF1 - An Open-Source Formula 1 Data Processing Toolkit
LiveF1 is a powerful Python toolkit for accessing and analyzing Formula 1 data in real-time or from historical archives. It's designed for developers, analysts, and F1 fans building applications around Formula 1 insights.
Features
- Real-Time Race Data: Provides live telemetry, timing, and position updates, ideal for powering dashboards and live analytics.
- Historical Data Access: Includes comprehensive race data from past seasons, perfect for performance analysis and comparisons.
- Data Processing Modules: Built-in ETL tools make raw data immediately usable, supporting analysis and seamless data storage.
- Easy Integration: Simple API for both real-time and historical data
In a nutshell:
Using LiveF1, you can access real-time and historical racing data, making it easy to feed analytics and visualizations.
Installation
Install using pip:
pip install livef1
Quick Start
Historical Data
Access data from past races:
import livef1
# Get a specific race session
session = livef1.get_session(
season=2024,
meeting_identifier="Spa",
session_identifier="Race"
)
# Load position data
position_data = session.get_data(
dataNames="Position.z"
)
print(position_data.head())
| | SessionKey | timestamp | Utc | DriverNo | Status | X | Y | Z |
|---:|-------------:|:-------------|:-----------------------------|-----------:|:---------|----:|----:|----:|
| 0 | 9574 | 00:01:45.570 | 2024-07-28T12:10:22.7877313Z | 1 | OnTrack | 0 | 0 | 0 |
| 1 | 9574 | 00:01:45.570 | 2024-07-28T12:10:22.7877313Z | 2 | OnTrack | 0 | 0 | 0 |
| 2 | 9574 | 00:01:45.570 | 2024-07-28T12:10:22.7877313Z | 3 | OnTrack | 0 | 0 | 0 |
| 3 | 9574 | 00:01:45.570 | 2024-07-28T12:10:22.7877313Z | 4 | OnTrack | 0 | 0 | 0 |
| 4 | 9574 | 00:01:45.570 | 2024-07-28T12:10:22.7877313Z | 10 | OnTrack | 0 | 0 | 0 |
Data Processing
LiveF1 uses a medallion architecture to process F1 data into analysis-ready formats:
# Generate processed data tables
session.generate(silver=True)
# Access refined data
laps_data = session.get_laps()
telemetry_data = session.get_car_telemetry()
print(laps_data.head())
| | lap_number | lap_time | in_pit | pit_out | sector1_time | sector2_time | sector3_time | None | speed_I1 | speed_I2 | speed_FL | speed_ST | no_pits | lap_start_time | DriverNo | lap_start_date |
|---:|-------------:|:-----------------------|:-----------------------|:----------|:-----------------------|:-----------------------|:-----------------------|:-------|-----------:|-----------:|-----------:|-----------:|----------:|:-----------------------|-----------:|:---------------------------|
| 0 | 1 | NaT | 0 days 00:17:07.661000 | NaT | NaT | 0 days 00:00:48.663000 | 0 days 00:00:29.571000 | | 314 | 204 | | 303 | 0 | NaT | 16 | 2024-07-28 13:03:52.742000 |
| 1 | 2 | 0 days 00:01:50.240000 | NaT | NaT | 0 days 00:00:31.831000 | 0 days 00:00:48.675000 | 0 days 00:00:29.734000 | | 303 | 203 | 219 | | 0 | 0 days 00:57:07.067000 | 16 | 2024-07-28 13:05:45.045000 |
| 2 | 3 | 0 days 00:01:50.519000 | NaT | NaT | 0 days 00:00:31.833000 | 0 days 00:00:49.132000 | 0 days 00:00:29.554000 | | 311 | 202 | 215 | 304 | 0 | 0 days 00:58:57.307000 | 16 | 2024-07-28 13:07:35.285000 |
| 3 | 4 | 0 days 00:01:49.796000 | NaT | NaT | 0 days 00:00:31.592000 | 0 days 00:00:48.778000 | 0 days 00:00:29.426000 | | 312 | 201 | 217 | 309 | 0 | 0 days 01:00:47.870000 | 16 | 2024-07-28 13:09:25.848000 |
| 4 | 5 | 0 days 00:01:49.494000 | NaT | NaT | 0 days 00:00:31.394000 | 0 days 00:00:48.729000 | 0 days 00:00:29.371000 | | 313 | 197 | 217 | 311 | 0 | 0 days 01:02:37.721000 | 16 | 2024-07-28 13:11:15.699000 |
Real-Time Data
Stream live race data:
from livef1.adapters import RealF1Client
# Initialize client with topics to subscribe
client = RealF1Client(
topics=["CarData.z", "Position.z"],
log_file_name="race_data.json" # Optional: log data to file
)
# Define callback for incoming data
@client.callback("telemetry_handler")
async def handle_data(records):
for record in records:
print(record) # Process incoming data
# Start receiving data
client.run()
Documentation
For detailed documentation, examples, and API reference, visit our documentation page.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Report bugs and request features in GitHub Issues
- For questions and discussions, use GitHub Discussions
FEEL FREE TO CONTACT ME
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livef1-0.1.43.tar.gz.
File metadata
- Download URL: livef1-0.1.43.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1924a7107fa76b1de5bf54417e75514b650710636495743cb390f2c67ebd8f46
|
|
| MD5 |
5ee149b10da27cf3bf7ffcf5cf33d193
|
|
| BLAKE2b-256 |
5066bfb79ab5822cb2c4e7185eb9616c701d78fed280590776b21954ad955c5d
|
Provenance
The following attestation bundles were made for livef1-0.1.43.tar.gz:
Publisher:
publish.yml on GoktugOcal/LiveF1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livef1-0.1.43.tar.gz -
Subject digest:
1924a7107fa76b1de5bf54417e75514b650710636495743cb390f2c67ebd8f46 - Sigstore transparency entry: 179908049
- Sigstore integration time:
-
Permalink:
GoktugOcal/LiveF1@01eb9f5941b3d3b64d00bc7fec3aa7b2ad3ed990 -
Branch / Tag:
refs/tags/v0.1.43 - Owner: https://github.com/GoktugOcal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01eb9f5941b3d3b64d00bc7fec3aa7b2ad3ed990 -
Trigger Event:
release
-
Statement type:
File details
Details for the file livef1-0.1.43-py3-none-any.whl.
File metadata
- Download URL: livef1-0.1.43-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a1e020436d3a17ff52fa17fa9282d8aa5724aa08ffb8620c071967a22bfbcf6
|
|
| MD5 |
fd29a293f8b1f551de30e0e4c26c5442
|
|
| BLAKE2b-256 |
62f4cf4071cd46caa7088ee676099739acb94b985175fcfc6d4b00301266e59e
|
Provenance
The following attestation bundles were made for livef1-0.1.43-py3-none-any.whl:
Publisher:
publish.yml on GoktugOcal/LiveF1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livef1-0.1.43-py3-none-any.whl -
Subject digest:
6a1e020436d3a17ff52fa17fa9282d8aa5724aa08ffb8620c071967a22bfbcf6 - Sigstore transparency entry: 179908053
- Sigstore integration time:
-
Permalink:
GoktugOcal/LiveF1@01eb9f5941b3d3b64d00bc7fec3aa7b2ad3ed990 -
Branch / Tag:
refs/tags/v0.1.43 - Owner: https://github.com/GoktugOcal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01eb9f5941b3d3b64d00bc7fec3aa7b2ad3ed990 -
Trigger Event:
release
-
Statement type: