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.
the part worth keeping
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.
Scouting & StrategyWorked Examples & Mini-Projectslesson 3 of 5
Keep going
Take the quiz+10 XP with an accountMore in Worked Examples & Mini-Projects
where this came from
Sources and 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, in public, in the corrections log.
sources and further reading
- thebluealliance.comThe Blue Alliance APIv3 docs
- github.comtbapy - Python wrapper for TBA (frc1418)
- github.comStatbotics Python API + REST (avgupta456)
- statbotics.ioStatbotics REST API reference
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 20 min readBuilding an FRC Scouting App: Data Model, TBA/Statbotics APIs, and PicklistsBuild 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./blogread it
- 18 min readThe Blue Alliance (TBA): How to Use FRC's Match & Team DatabaseThe 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./blogread it
- 19 min readWhat Is Statbotics? FRC EPA (Expected Points Added) ExplainedStatbotics 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./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01How do you authenticate a request to The Blue Alliance Read API v3?
02Which correctly describes the TBA API v3 base URL and request style?
03Compared with TBA, what is distinctive about pulling team data from the Statbotics Python API?
Answer every question to submit.
All 32 lessons in Scouting & Strategyopenclose
01 / prerequisites
02 / scouting-fundamentals
03 / building-a-scouting-system
04 / data-analysis-tba-statbotics
05 / strategy-picklists-and-match-play
06 / worked-examples-and-mini-projects
- Not read yet:Project 1: Configure a QRScout Form for REEFSCAPE
- Not read yet:Project 2: Compute OPR by Hand, Then in a Spreadsheet
- Not read yet:Project 3: Pull Live Data with the TBA and Statbotics APIs
- Not read yet:Project 4: Build an EPA-Component Robot Ranking Sheet
- Not read yet:Project 5: Assemble a One-Page Pre-Match Prep Sheet
07 / common-mistakes-and-troubleshooting
08 / advanced-techniques-and-case-studies