Goal
A short Python script that, given an event key, pulls (a) the qualification schedule and results from The Blue Alliance (TBA) and (b) Statbotics EPA ratings, so your analysis sheet can refresh itself instead of being retyped.
Get a TBA Read API key
Go to your TBA account dashboard and generate a key under Read API Keys. Every direct request to the base URL https://www.thebluealliance.com/api/v3 must include the header X-TBA-Auth-Key. Event keys look like 2025cc (the 2025 Chezy Champs off-season event; the event code is the part after the year in the event URL, e.g. thebluealliance.com/event/2025cc).
TBA with the tbapy wrapper
pip3 install tbapy
import tbapy
tba = tbapy.TBA('YOUR_TBA_KEY')
event = '2025cc'
# Every match at the event (objects with alliances + score_breakdown)
matches = tba.event_matches(event)
# OPR / DPR / CCWM that TBA already computed
oprs = tba.event_oprs(event) # dict with 'oprs', 'dprs', 'ccwms'
rankings = tba.event_rankings(event) # qualification ranking + RP
for m in matches:
if m['comp_level'] != 'qm':
continue
red = m['alliances']['red']['team_keys'] # e.g. ['frc254','frc1678','frc2713']
red_score = m['alliances']['red']['score']
print(m['key'], red, red_score)
The score_breakdown on each match is gold: for REEFSCAPE it splits out auto vs teleop coral counts by level, algae, and barge points, which you can feed straight into component OPR (Project 2).
Statbotics for EPA
EPA (Expected Points Added) is Statbotics' rating; it was built to replace OPR/Elo and is designed to be predictive, expressed in point units, and split into auto/teleop/endgame component EPAs.
pip install statbotics==3.0.0
import statbotics
sb = statbotics.Statbotics()
print(sb.get_team(254)) # team profile incl. EPA summary
print(sb.get_team_year(254, 2025)) # one team's 2025 EPA
ty = sb.get_team_event(254, '2025cc') # EPA at a specific event
ms = sb.get_matches(team=254, year=2025) # match-level EPA records
Use the fields parameter (e.g. sb.get_team(254, fields=['team','norm_epa'])) to request only what you need so responses stay small.
Putting it together
A practical pattern: pull TBA event_rankings for ranking-point standings, TBA event_oprs for a no-scouting power baseline, and Statbotics get_team_event for predictive EPA, then join all three on team number in a DataFrame. When TBA OPR and Statbotics EPA agree with your own scouting averages, you have high confidence; when they disagree, that team is worth a super-scout's eyes. Cache responses (TBA returns an ETag; send it back as If-None-Match to get a cheap 304 Not Modified) so you are polite to the API and fast on refresh.
Key takeaways
- TBA requires the X-TBA-Auth-Key header; tbapy wraps event_matches, event_oprs, and event_rankings into one-line calls.
- TBA score_breakdown gives per-phase REEFSCAPE counts (auto vs teleop coral by level) you can feed into component OPR.
- Statbotics v3 (pip install statbotics==3.0.0) exposes get_team, get_team_year, get_team_event, and get_matches for predictive EPA with auto/teleop/endgame components.
Keep going
Take the quiz · +10 XP with an accountMore in Worked Examples & Mini-Projects
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
- The Blue Alliance APIv3 docsthebluealliance.com
- tbapy - Python wrapper for TBA (frc1418)github.com
- Statbotics Python API + REST (avgupta456)github.com
- Statbotics REST API referencestatbotics.io
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 20 min read
Building an FRC Scouting App: Data Model, TBA/Statbotics APIs, and Picklists
Build an FRC scouting app: match and pit scouting, a simple data model, pulling schedules and EPA from the TBA and Statbotics APIs, and building a picklist.
Read - 18 min read
The Blue Alliance (TBA): How to Use FRC's Match & Team Database
The Blue Alliance (TBA) is FRC's free match and team database. Navigate team, event, and match pages, set up myTBA notifications, and use its read API.
Read - 19 min read
What Is Statbotics? FRC EPA (Expected Points Added) Explained
Statbotics explained: what EPA (Expected Points Added) means in FRC, how it's calculated, how EPA compares to OPR, and how to use it for scouting.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
01.How do you authenticate a request to The Blue Alliance Read API v3?
02.Which correctly describes the TBA API v3 base URL and request style?
03.Compared with TBA, what is distinctive about pulling team data from the Statbotics Python API?
Answer every question to submit.
All 32 lessons in Scouting & Strategy
- Not started:Project 1: Configure a QRScout Form for REEFSCAPE
- Not started:Project 2: Compute OPR by Hand, Then in a Spreadsheet
- Not started:Project 3: Pull Live Data with the TBA and Statbotics APIs
- Not started:Project 4: Build an EPA-Component Robot Ranking Sheet
- Not started:Project 5: Assemble a One-Page Pre-Match Prep Sheet