Skip to main content

pitstops.py

The pitstops.py script fetches pitstop data for Formula 1 races. It retrieves timing information for every pitstop during a race, including duration and lap number.

Overview

This script uses the PitstopsFetcher class to:
  • Fetch pitstop data from the Ergast API with pagination
  • Automatically skip seasons before 2011 (no pitstop data available)
  • Combine multiple API pages into a single dataset
  • Implement rate limiting and error handling
Pitstop data is only available from 2011 onwards. The script automatically skips earlier seasons.

PitstopsFetcher Class

Initialization

pitstops.py

Key Methods

get_race_info()

Reads race information from the local events.json file.
pitstops.py

fetch_pitstops_for_race()

Fetches all pitstops for a race using pagination.
pitstops.py

run()

Main execution method.
pitstops.py

Usage

Basic Usage

Fetch Multiple Races

API Endpoint

Output Structure

Pitstop data is saved to: {year}/{race-slug}/pitstops.json

Data Availability

See Also