Table of Contents
This project contains a number of scripts that help us prepare for upcoming FRC events by leveraging data from The Blue Alliance. These scripts include:
- Pull all events for a competition year from The Blue Alliance and cache locally as JSON.
- Pull data for an Event from The Blue Alliance and cache locally as JSON.
- Pull the data from the stored Event JSON into Excel to provide a rich experience for tracking Scouting sessions.
- Pull the data from the stored Event JSON to produde a much smaller JavaScript file for use in the ScoutingPASS Application.
- Python (latest version)
- Microsoft Excel or Libre Office (for using spreadsheets)
- The Blue Alliance API Key (Refer to How To for instructions)
The required Python packages can be installed by executing the command below:
pip install -r requirements.txtAlternatively, you can install needed packages manually:
pip install pandas
pip install requests
pip install load_dotenv
pip install openpyxl| File | Description |
|---|---|
| event_initialize.py | Retrieves event data from The Blue Alliance and caches the JSON output to:The Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY |
| event_push_to_excel.py | Reads cached TBA_EVENT_KEY.json, TBA_EVENT_KEY.matches.json and TBA_EVENT_KEY.teams.json and uses .\Templates\scouting-template.xlsx to populateThe Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY\TBA_EVENT_KEY.xlsx. |
| event_to_scouting_app.py | Reads cached TBA_EVENT_KEY.matches.json and writes a ScoutingPass-friendly JavaScript file toThe Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY\matches.js |
| fabricate_scouting_data.py | Generates bogus and random data (comma delimited and tab delimited) and writes toThe Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY\TBA_EVENT_KEY.fake-data.csvand The Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY\TBA_EVENT_KEY.fake-data.tsv |
| year_initialize.py | Downloads all the currently registered events for a Competition year and writes the JSON toThe Blue Alliance\Game Years\TBA_EVENT_YEAR\TBA_EVENT_KEY\TBA_EVENT_KEY.json |
Create or validate the existence of the file The Blue Alliance\.env. This is a simple file which is used to store
settings and secrets or use by the scripts. This file is included in the .gitignore as we do not want the file to be
added to source control.
The conents of the file should follow what you see in .env.example and currently looks something like:
TBA_AUTH_KEY="blue-alliance-api-key"
TBA_EVENT_YEAR="2026"
TBA_EVENT_KEY="2026abcde"
TBA_AUTH_KEY is the TBA key acquired from The Blue Alliance Accounts Page. TBA_EVENT_YEAR is the FRC competition year for which we want to manage scouting data. TBA_EVENT_KEY will be explained later.
Once you have set TBA_AUTH_KEY and TBA_EVENT_YEAR, open the file year_initialize.py and execute it.
This script queries the TBA API, provides the authorization key and the desired year, and receives the list of events for the year.
The script then creates a folder in The Blue Alliance\Game Years for that year and saves the JSON as YEAR.json.
For example, if you wanted to get the data for the year 1234, you would:
- Update
.envwith TBA_EVENT_YEAR="1234" - Execute
initialize_year.py - Navigate to
The Blue Alliance\Game Years\1234. - Observe the file
1234.jsonexists and contains all the events for that year.
To prepare for a specific Event, update The Blue Alliance\.env to include the TBA Event key from
TBA_EVENT_YEAR.json. Look for the "key" property in that JSON. For example, for Rocket City Regional, the key is
2026alhu:
[
{
"key": "2026alhu",
"name": "Rocket City Regional"
/* Lots more JSON */
},
{
"key": "2026arc",
"name": "Archimedes Division"
/* Lots more JSON */
},
{
"key": "2026nyro",
"name": "Finger Lakes Regional"
/* Lots more JSON */
}
/* Lots more JSON */
]For example, if you wanted to get the data for the Rocket City Regional, you would:
- Update
.envwith TBA_EVENT_KEY="2026alhu" - Execute
event_initialize.py - Navigate to
The Blue Alliance\Game Years\2026\2026alhu. - Observe the folder contains data related to the event:
- 2026alhu.json
- 2026alhu.matches.json
- 2026alhu.teams.json
The files and scripts related to the Event are as follows:
| File | Description |
|---|---|
| TBA_EVENT_KEY.json | This file contains meta data about the event itself. This is roughly the same information as you would find in The Blue Alliance\Game Years\2026.json. |
| TBA_EVENT_KEY.matches.json | This file contains all the known information about the matches designated for the Event. Note that this file might not be populated. Typically, TBA will publish the final Match data the day before or the morning of the Event. |
| TBA_EVENT_KEY.teams.json | This file contains all the known information about the Teams competing at the Event. Note that this file might not be populated. TBA updates this data long before the Event takes place. |
Now that we have initialized an Event, we can start to prepare the Excel spreadsheet for receiving and reporting on Scouting data.
- Navigate to The Blue Alliance
- Click myTBA
- FOllow the instructions to either create a new account or log into an existing account.
- Scroll down to the Read API Keys section.
- Enter a value for Description
- Click Add New Key
- Copy the X-TBA-Auth-Key value into
.envfiles where desired.
- Work with members working on the ScoutingPASS and update the MatchScoutingData tab in the
The Blue Alliance\Templates\scouting_template.xlsxspreadsheet. - Work with members working on the ScoutingPASS and update the script
The Blue Alliance\Templates\event_push_to_excel.pyto account for how we want to consume and report on scouting data. - Follow the guidance in Initialize Competition Year
Continually refresh cached Event JSON until we have the Event, Matches and Teams.
- Confirm that
.envcontains the property settings for the API Key, the Year and the Event Key. - Execute
event_initialize.py - Check
TBA_EVENT_KEY.json,TBA_EVENT_KEY.matches.jsonandTBA_EVENT_KEY.matches.jsonand repeat Step 2 periodically until all three files contain data. The Blue Alliance typically publishes the Matches schedules the day before, or the morning of a competition.
Update the spreadsheet and script to reflect any changes to questions or answers implemented within the ScoutingPASS application.
- Work with members working on the ScoutingPASS and update the MatchScoutingData tab in the
The Blue Alliance\Templates\scouting_template.xlsxspreadsheet. - Work with members working on the ScoutingPASS and update the script
The Blue Alliance\Templates\event_push_to_excel.pyto account for how we want to consume and report on scouting data. - Execute
event_push_to_excel.pyto populate the scouting spreadsheet.