Prerequisites
Before you begin, make sure you have:- Python 3.7 or higher installed
- Git installed on your system
- An internet connection to access the Ergast API
Install dependencies
Install the required Python packages using pip:The project only requires the
requests library for making API calls.Fetch race events
Start by fetching race events for a season. Run the events script to get all races for 2026:This script will:
- Create a directory structure organized by year
- Fetch all race events for the specified season(s)
- Save event data to
events.jsonin each year folder - Create individual folders for each race
By default, the script is configured to fetch 2026 data. You can modify the
start_year and end_year variables in events.py to fetch different seasons.Fetch race results
Now fetch the actual race results for a specific round:The
RaceResultsFetcher class handles:- Rate limiting (4 requests per second)
- Automatic retry on rate limit errors
- Organized folder structure by season and race
Explore the data
Your data is now organized in a structured folder hierarchy:Each race folder contains JSON files with different data types:
results.json- Race finishing positions and detailsquali_results.json- Qualifying session resultsdriverPoints.json- Driver championship standings after this racelaptimes.json- Lap-by-lap timing data
Example: Fetch Complete Race Data
Here’s a complete example to fetch all data for a specific race:Understanding the Data Structure
The Ergast API returns data in a nested JSON structure. Here’s what a typical race result looks like:Next Steps
Installation
Learn about detailed installation and configuration options
API Reference
Explore all available scripts and their parameters