Skip to main content

blacktop-data

Python client for the Blacktop Data API. The blacktop.f1 module follows FastF1's interface, so most FastF1 scripts run after changing the import.

Install

pip install blacktop-data

Python 3.10 or later. Depends on httpx and pandas.

API key

Create a key in the API Keys section of your profile at ocblacktop.com, then set it in the environment:

export BLACKTOP_API_KEY=your-key

or pass it in code:

import blacktop

blacktop.set_client(blacktop.Client(api_key="your-key"))

Quickstart

FastF1's fastest-lap speed trace, with one import changed:

from matplotlib import pyplot as plt
import blacktop.f1 as fastf1

fastf1.Cache.enable_cache("cache")

session = fastf1.get_session(2019, "Monza", "R")
session.load()
fast_leclerc = session.laps.pick_drivers("LEC").pick_fastest()
lec_car_data = fast_leclerc.get_car_data()
t = lec_car_data["Time"].dt.total_seconds()
vCar = lec_car_data["Speed"]

fig, ax = plt.subplots()
ax.plot(t, vCar, label="Fast")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Speed [km/h]")
ax.set_title("Leclerc is")
ax.legend()
plt.show()

matplotlib is not a dependency; install it to plot. Use .add_distance() on car data for speed against distance.

Laps cover every F1 session from 2018. Car data covers every race and sprint from 2019 to 2025 except 2022, and every session from 2026 (2022 has no car data yet). Lap and car data are served once a session has finished. The routes behind laps, car_data, pos_data and team_radio need a paid plan; on the free plan they raise PlanRequiredError with the API's message.

Coming from FastF1

FastF1 blacktop.f1
Cache.enable_cache(path) Same. The cache is also on by default; see Caching.
get_event_schedule(year) Same columns where the API has them. RoundNumber is counted in date order; testing is round 0.
get_event, get_session, get_testing_session Same. gp is a round number or a name matched against event name, location and country. Identifiers: R, Q, S, SQ, SS, FP1–FP3, full names, or 1–5.
session.load() Accepted. Data loads on first access.
session.results, get_driver(), drivers Same. ClassifiedPosition and Status use the API's values (DNF, DSQ, OK).
session.laps Driver, DriverNumber, Team, LapNumber, LapTime, Sector1Time–Sector3Time, Compound, Position, Stint, plus InPit (in-lap), PitOut (out-lap) and StintLap (laps into the stint, from 1). Stint starts a new stint on each out-lap, as FastF1 does.
pick_drivers, pick_laps, pick_fastest, pick_quicklaps, pick_compounds, pick_tyre, pick_teams, pick_wo_box, pick_box_laps, iterlaps Same. pick_fastest picks by LapTime; the API does not flag deleted laps.
Lap.get_car_data(), Laps.get_car_data(), session.car_data[...] Date, SessionTime, Time, RPM, Speed, nGear, Throttle, Brake, DRS, Source, plus LapNumber. About 4 Hz.
get_telemetry() Car data with Distance and RelativeDistance. No X/Y/Z.
add_distance(), add_relative_distance(), slice_by_lap(), slice_by_time() Same.
session.pos_data[...] Time, TrackFraction (0 at the line), LapNumber. No X/Y/Z; Time is the positions route's own clock.
session.weather_data Same values, timestamped by Date (UTC) instead of Time.
session.race_control_messages Same, without Status.
fastf1.plotting Not included.

Times are tz-naive UTC timestamps and Timedeltas, as in FastF1. A channel the source recorded wrong is withheld and comes back as missing values; car.quality, car.quality_note and car.withheld_channels say which.

These raise NotImplementedError (blacktop.NotServedError, also a KeyError) with a one-line reason:

  • Lap columns: Time, LapStartTime, LapStartDate, PitInTime, PitOutTime (use InPit/PitOut), Sector1SessionTime–Sector3SessionTime, SpeedI1, SpeedI2, SpeedFL, SpeedST, IsPersonalBest, TyreLife (use StintLap), FreshTyre, TrackStatus, Deleted, DeletedReason, IsAccurate, FastF1Generated.
  • Laps methods: pick_not_deleted, pick_accurate, pick_track_status, split_qualifying_sessions, get_pos_data, get_weather_data.
  • Session: track_status, session_status, total_laps, session_start_time, session_info, get_circuit_info().
  • Car data: X, Y, Z, Status, DriverAhead, DistanceToDriverAhead, add_driver_ahead(), merge_channels(), add_track_status().
  • Results: BroadcastName, HeadshotUrl, CountryCode.
  • Schedule: local session times (Session1Date…, get_session_date(utc=False)), F1ApiSupport.

Not in FastF1: session.mini_sectors(driver) (per-lap mini-sector speeds, pedal shares and gap to the car ahead), session.team_radio, and session.t0_date.

Caching

The cache is on by default and stores responses in:

  • macOS: ~/Library/Caches/blacktop-data
  • Linux: $XDG_CACHE_HOME/blacktop-data, or ~/.cache/blacktop-data
  • Windows: %LOCALAPPDATA%\blacktop-data

To use another directory, set BLACKTOP_CACHE_DIR or call Cache.enable_cache(path). Cache.disable_cache() turns caching off and Cache.clear_cache() empties the directory.

Only session routes (/events/{id}/sessions/{id}/...) are cached. Telemetry responses are kept indefinitely, since telemetry does not change once a session is published. Other session routes are refetched after 24 hours. Schedules and /live/ routes (weather, race control) are not cached. A cached response makes no request, so it does not count against your monthly quota.

session.laps is one request for every driver. Lap.get_car_data() fetches that lap only, unless the driver's whole session is already in memory or in the cache. Laps.get_car_data() over several laps and session.car_data[...] fetch the driver's whole session once. With Cache.offline_mode(True), a session route missing from the cache raises CacheMissError instead of making a request.

Low-level client

import blacktop

client = blacktop.Client()                         # reads BLACKTOP_API_KEY
standings = client.get("/v1/formula1/standings/drivers", year=2024)
events = client.get_all("/v1/formula1/events", year=2024)   # follows every page

Errors: AuthenticationError (401), PlanRequiredError (402, with required_tier, current_tier, upgrade_url), NotFoundError (404, with the API's message; withheld sessions say why), RateLimitError (429). A 429 with a short Retry-After is retried once.

License

MIT

Metadata

Release files for blacktop-data 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blacktop-data 0.1.0
File Size Uploaded Provenance Actions
blacktop_data-0.1.0.tar.gz 37.8 kB With provenance Details for blacktop_data-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for blacktop-data 0.1.0
File Interpreter ABI Platform Actions
blacktop_data-0.1.0-py3-none-any.whl Python 3 none any Details for blacktop_data-0.1.0-py3-none-any.whl

Total release size: 67.5 kB

Release files / blacktop_data-0.1.0.tar.gz

Download URL blacktop_data-0.1.0.tar.gz
Size 37.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a68f710156a9ac6a63e77baddb86934d8f94dfe51e455f52dc94f81fee067ad8
BLAKE2b-256 checksum
How to use checksums
caee84f92f90349aac64d941002d38aa1c91fde6aba74921e75af0b5b560080c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / blacktop_data-0.1.0-py3-none-any.whl

Download URL blacktop_data-0.1.0-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
794be65d7e7df514ff068b2ef373bd9cd051f108aa6a31e5a5ca0f79ca6a892b
BLAKE2b-256 checksum
How to use checksums
a446a913dae1fca8f7eaad5dcbbb4403288ae414bf360179e96247857da44c42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for blacktop-data 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for blacktop_data-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page