nascar-api
A typed Python client for NASCAR's undocumented Content Feed (CF) API. Provides access to both historical and live race data across the Cup, Xfinity, and Truck series.
Built with Pydantic for data validation and tenacity for automatic retry logic.
Installation
pip install nascar-api
Or with Poetry:
poetry add nascar-api
Quick Start
from nascar_api.repos import HistoricNascarRepo
from nascar_api.enums import Series
repo = HistoricNascarRepo()
# Get all Cup Series races from 2024
races = repo.get_races(2024, Series.CUP)
for race in races:
print(f"{race.race_name} at {race.track_name} — Winner ID: {race.winner_driver_id}")
Features
Historical Data
from nascar_api.repos import HistoricNascarRepo
from nascar_api.enums import Series
repo = HistoricNascarRepo()
# Race schedules and results for any year/series
races = repo.get_races(2024, Series.CUP)
# Lap-by-lap timing data
lap_times = repo.get_lap_times(2024, Series.CUP, race_id=5161)
# Lap notes (cautions, incidents, flags)
lap_notes = repo.get_lap_notes(2024, Series.CUP, race_id=5161)
# Pit stop data with detailed timing and tire info
pit_stops = repo.get_pit_data(Series.CUP, race_id=5161)
# Full weekend feed (results, cautions, leaders, stages, pit reports)
weekend = repo.get_weekend_data(2024, Series.CUP, race_id=5161)
# Loop statistics (driver performance metrics)
loop_stats = repo.get_loopstats(2024, Series.CUP, race_id=5161)
Live Race Data
from nascar_api.repos import LiveNascarFeedRepo
from nascar_api.enums import Series
repo = LiveNascarFeedRepo()
# Current flag state across all active races
flags = repo.get_live_flags()
# Full live race feed (positions, speeds, pit stops, vehicle data)
feed = repo.get_live_feed()
for vehicle in feed.vehicles:
print(f"#{vehicle.vehicle_number} — P{vehicle.running_position}, "
f"Last Lap: {vehicle.last_lap_speed:.1f} mph")
# Live points standings
points = repo.get_live_points(Series.CUP, race_id=5161)
API Reference
Repositories
| Class | Description |
|---|---|
HistoricNascarRepo |
Historical race data (schedules, results, lap times, pit stops, weekend feeds, loop stats) |
LiveNascarFeedRepo |
Real-time race data (live flags, race feed, points standings) |
Models
| Model | Description |
|---|---|
RaceInfo |
Race metadata — schedule, track, distance, laps, cautions, speed, purse, broadcast info |
RaceLaps |
Per-driver lap-by-lap timing (lap times, speeds, running position) |
LapData |
Lap notes with flag states, incident notes, and involved drivers |
PitData |
Pit stop details — timing, tire changes, positions gained/lost |
WeekendInfo |
Full weekend container with race results and practice/qualifying runs |
WeekendRaceInfo |
Detailed race results, caution segments, race leaders, stage results, pit reports |
WeekendRunInfo |
Practice/qualifying session results |
LiveInfo |
Live race state — flag, lap, timing, and all vehicle telemetry |
FlagData |
Live flag state with timing and beneficiary info |
PointsData |
Championship points standings with stage breakdowns |
RaceLoopStat |
Race-level loop statistics with per-driver performance metrics |
Enums
| Enum | Values |
|---|---|
Series |
CUP (1), XFINITY (2), TRUCK (3) |
Flag |
GREEN (1), YELLOW (2), RED (3), WHITE (4), CHECKERED (5), HOT_TRACK (8), COLD_TRACK (9) |
Retry Behavior
All API requests automatically retry up to 3 times with a 2-second delay on transient failures (5xx errors, JSON decode errors). Requests that receive a 403 (data not available for that endpoint/year) do not retry.
Requirements
- Python 3.11+
- No API key required — NASCAR's CF API is publicly accessible
License
Metadata
Release files for nascar-api 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nascar_api-0.1.3.tar.gz | 14.1 kB | With provenance | Details for nascar_api-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nascar_api-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for nascar_api-0.1.3-py3-none-any.whl |
Total release size: 35.2 kB
Release files / nascar_api-0.1.3.tar.gz
| Download URL | nascar_api-0.1.3.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f9be43d28f5b55abbc0b21f31b6f2c3509c303d3619aabad723bb7b9fb7b513
|
|
BLAKE2b-256 checksum How to use checksums |
95d944000e2ad09cbd6749ba1e1dca893f5f0751d1793682d0b56ebb0697c4cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 23, 2026.
Transparency logRelease files / nascar_api-0.1.3-py3-none-any.whl
| Download URL | nascar_api-0.1.3-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4dcf64bb74e43d65b1332bdfa2a27445096f29e3b6a4545ccccdc6bdec4ec465
|
|
BLAKE2b-256 checksum How to use checksums |
e20f039349ae703c104dd638163a286e02635cb3e9101588e956df025ceb2d54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 23, 2026.
Transparency logSecurity for nascar-api 0.1.3
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nascar_api-0.1.3.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 Sep 23, 2026.
Transparency logA 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.