bluealliance 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bluealliance-0.1.0/.gitattributes +2 -0
- bluealliance-0.1.0/.gitignore +181 -0
- bluealliance-0.1.0/LICENSE +21 -0
- bluealliance-0.1.0/PKG-INFO +190 -0
- bluealliance-0.1.0/README.md +144 -0
- bluealliance-0.1.0/pyproject.toml +49 -0
- bluealliance-0.1.0/src/bluealliance/__init__.py +141 -0
- bluealliance-0.1.0/src/bluealliance/client.py +431 -0
- bluealliance-0.1.0/src/bluealliance/collector.py +540 -0
- bluealliance-0.1.0/src/bluealliance/py.typed +0 -0
- bluealliance-0.1.0/src/bluealliance/schemas.py +775 -0
- bluealliance-0.1.0/tests/__init__.py +0 -0
- bluealliance-0.1.0/tests/smoke_test.py +33 -0
- bluealliance-0.1.0/tests/test_imports.py +87 -0
- bluealliance-0.1.0/tests/test_usage.py +6 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
.vscode/
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
175
|
+
|
|
176
|
+
# Cursor
|
|
177
|
+
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
|
|
178
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
179
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
180
|
+
.cursorignore
|
|
181
|
+
.cursorindexingignore
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaique
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bluealliance
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for The Blue Alliance API v3 — typed, schema-validated, zero boilerplate.
|
|
5
|
+
Project-URL: Repository, https://github.com/Kaique-Sique/BlueAlliancePy
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Kaique
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: api-client,first-robotics,frc,tba,the-blue-alliance
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
36
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
|
+
Requires-Dist: pydantic>=2.7
|
|
39
|
+
Requires-Dist: requests>=2.32
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# BlueAlliancePy
|
|
48
|
+
|
|
49
|
+
Python client for [The Blue Alliance](https://www.thebluealliance.com) API v3.
|
|
50
|
+
Typed, schema-validated, zero boilerplate.
|
|
51
|
+
|
|
52
|
+
Built for FRC Team 7563 (Megazord) scouting infrastructure.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install bluealliance
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or directly from the repository:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install git+https://github.com/Kaique-Sique/BlueAlliancePy.git
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
Get your API key at https://www.thebluealliance.com/account.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from bluealliance import TBACollector
|
|
72
|
+
|
|
73
|
+
c = TBACollector("YOUR_TBA_KEY")
|
|
74
|
+
|
|
75
|
+
# team profile
|
|
76
|
+
team = c.team("frc7563")
|
|
77
|
+
print(team.nickname, team.city) # Megazord, Jundiaí
|
|
78
|
+
|
|
79
|
+
# all teams at an event (typed, not raw dicts)
|
|
80
|
+
for team in c.event_teams("2025spbra"):
|
|
81
|
+
print(team.team_number, team.nickname)
|
|
82
|
+
|
|
83
|
+
# live rankings
|
|
84
|
+
ranking = c.event_rankings("2025spbra")
|
|
85
|
+
if ranking:
|
|
86
|
+
for entry in ranking.rankings[:5]:
|
|
87
|
+
print(entry.rank, entry.team_key, entry.record)
|
|
88
|
+
|
|
89
|
+
# full event bundle in one call
|
|
90
|
+
bundle = c.event_bundle("2025spbra")
|
|
91
|
+
print(bundle.event.name)
|
|
92
|
+
print(f"{len(bundle.teams)} teams, {len(bundle.matches)} matches")
|
|
93
|
+
|
|
94
|
+
# 2025 Reefscape score breakdown already parsed
|
|
95
|
+
for match, bd in c.event_matches_2025("2025spbra"):
|
|
96
|
+
if bd:
|
|
97
|
+
coral = bd.red.autoCoralCount + bd.red.teleopCoralCount
|
|
98
|
+
print(match.key, "red coral:", coral, "endgame:", bd.red.endGameRobot1)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Three layers
|
|
102
|
+
|
|
103
|
+
| Layer | Import | What it does |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `TBAClient` | `from bluealliance import TBAClient` | Raw HTTP — returns `dict`/`list`. One method per TBA endpoint (84 total). |
|
|
106
|
+
| `TBACollector` | `from bluealliance import TBACollector` | Typed — wraps every client method to return Pydantic models instead of dicts. Handles pagination automatically. |
|
|
107
|
+
| Schemas | `from bluealliance import Team, Match, Event` | Pydantic v2 models. Use `Model.model_validate(raw)` if you already have a dict. |
|
|
108
|
+
|
|
109
|
+
You can mix layers freely — `TBACollector` for most work, `TBAClient` when you need the raw payload for something not covered by the schemas.
|
|
110
|
+
|
|
111
|
+
## Low-level client
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from bluealliance import TBAClient
|
|
115
|
+
|
|
116
|
+
client = TBAClient("YOUR_TBA_KEY")
|
|
117
|
+
|
|
118
|
+
# returns raw dict/list -- no Pydantic parsing
|
|
119
|
+
raw = client.get_event_matches("2025spbra")
|
|
120
|
+
raw_team = client.get_team("frc7563")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Pydantic models directly
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from bluealliance.schemas import Team, Match, ScoreBreakdown2025, parse_score_breakdown_2025
|
|
127
|
+
|
|
128
|
+
team = Team.model_validate(raw_dict)
|
|
129
|
+
|
|
130
|
+
match = Match.model_validate(raw_match_dict)
|
|
131
|
+
bd = parse_score_breakdown_2025(match.score_breakdown)
|
|
132
|
+
if bd:
|
|
133
|
+
print(bd.red.totalPoints, bd.blue.endGameBargePoints)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Available collector methods
|
|
137
|
+
|
|
138
|
+
### Status
|
|
139
|
+
- `c.status()` → `APIStatus`
|
|
140
|
+
|
|
141
|
+
### Teams
|
|
142
|
+
- `c.team(key)` → `Team`
|
|
143
|
+
- `c.team_simple(key)` → `TeamSimple`
|
|
144
|
+
- `c.team_history(key)` → `TeamHistory`
|
|
145
|
+
- `c.team_robots(key)` → `list[TeamRobot]`
|
|
146
|
+
- `c.team_awards(key, year?)` → `list[Award]`
|
|
147
|
+
- `c.team_media(key, year)` → `list[MediaBase]`
|
|
148
|
+
- `c.team_events(key, year?)` → `list[Event]`
|
|
149
|
+
- `c.team_matches(key, year)` → `list[Match]`
|
|
150
|
+
- `c.team_event_matches(key, event_key)` → `list[Match]`
|
|
151
|
+
- `c.team_event_status(key, event_key)` → `TeamEventStatus | None`
|
|
152
|
+
- `c.team_season_summary(key, year)` → `TeamSeasonSummary`
|
|
153
|
+
- `c.all_teams_by_year(year)` → `list[Team]` *(auto-paginates)*
|
|
154
|
+
|
|
155
|
+
### Events
|
|
156
|
+
- `c.events(year)` → `list[Event]`
|
|
157
|
+
- `c.event(key)` → `Event`
|
|
158
|
+
- `c.event_teams(key)` → `list[Team]`
|
|
159
|
+
- `c.event_matches(key)` → `list[Match]`
|
|
160
|
+
- `c.event_matches_2025(key)` → `list[tuple[Match, ScoreBreakdown2025 | None]]`
|
|
161
|
+
- `c.event_rankings(key)` → `EventRanking | None`
|
|
162
|
+
- `c.event_oprs(key)` → `EventOPRs | None`
|
|
163
|
+
- `c.event_alliances(key)` → `list[EliminationAlliance] | None`
|
|
164
|
+
- `c.event_awards(key)` → `list[Award]`
|
|
165
|
+
- `c.event_teams_statuses(key)` → `dict[str, TeamEventStatus | None]`
|
|
166
|
+
- `c.event_bundle(key)` → `EventBundle`
|
|
167
|
+
|
|
168
|
+
### Matches
|
|
169
|
+
- `c.match(key)` → `Match`
|
|
170
|
+
- `c.match_2025(key)` → `tuple[Match, ScoreBreakdown2025 | None]`
|
|
171
|
+
- `c.match_zebra(key)` → `Zebra`
|
|
172
|
+
|
|
173
|
+
### Districts
|
|
174
|
+
- `c.districts(year)` → `list[District]`
|
|
175
|
+
- `c.district_rankings(key)` → `list[DistrictRanking] | None`
|
|
176
|
+
- `c.district_advancement(key)` → `dict[str, DistrictAdvancement] | None`
|
|
177
|
+
|
|
178
|
+
### Regional (2025+)
|
|
179
|
+
- `c.regional_advancement(year)` → `dict[str, RegionalAdvancement] | None`
|
|
180
|
+
- `c.regional_rankings(year)` → `list[RegionalRanking] | None`
|
|
181
|
+
|
|
182
|
+
### Insights
|
|
183
|
+
- `c.leaderboards(year)` → `list[LeaderboardInsight]`
|
|
184
|
+
- `c.insights_v2(year, category?)` → `list[InsightV2...]`
|
|
185
|
+
|
|
186
|
+
## Requirements
|
|
187
|
+
|
|
188
|
+
- Python 3.11+
|
|
189
|
+
- `requests >= 2.32`
|
|
190
|
+
- `pydantic >= 2.7`
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# BlueAlliancePy
|
|
2
|
+
|
|
3
|
+
Python client for [The Blue Alliance](https://www.thebluealliance.com) API v3.
|
|
4
|
+
Typed, schema-validated, zero boilerplate.
|
|
5
|
+
|
|
6
|
+
Built for FRC Team 7563 (Megazord) scouting infrastructure.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install bluealliance
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or directly from the repository:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install git+https://github.com/Kaique-Sique/BlueAlliancePy.git
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
Get your API key at https://www.thebluealliance.com/account.
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from bluealliance import TBACollector
|
|
26
|
+
|
|
27
|
+
c = TBACollector("YOUR_TBA_KEY")
|
|
28
|
+
|
|
29
|
+
# team profile
|
|
30
|
+
team = c.team("frc7563")
|
|
31
|
+
print(team.nickname, team.city) # Megazord, Jundiaí
|
|
32
|
+
|
|
33
|
+
# all teams at an event (typed, not raw dicts)
|
|
34
|
+
for team in c.event_teams("2025spbra"):
|
|
35
|
+
print(team.team_number, team.nickname)
|
|
36
|
+
|
|
37
|
+
# live rankings
|
|
38
|
+
ranking = c.event_rankings("2025spbra")
|
|
39
|
+
if ranking:
|
|
40
|
+
for entry in ranking.rankings[:5]:
|
|
41
|
+
print(entry.rank, entry.team_key, entry.record)
|
|
42
|
+
|
|
43
|
+
# full event bundle in one call
|
|
44
|
+
bundle = c.event_bundle("2025spbra")
|
|
45
|
+
print(bundle.event.name)
|
|
46
|
+
print(f"{len(bundle.teams)} teams, {len(bundle.matches)} matches")
|
|
47
|
+
|
|
48
|
+
# 2025 Reefscape score breakdown already parsed
|
|
49
|
+
for match, bd in c.event_matches_2025("2025spbra"):
|
|
50
|
+
if bd:
|
|
51
|
+
coral = bd.red.autoCoralCount + bd.red.teleopCoralCount
|
|
52
|
+
print(match.key, "red coral:", coral, "endgame:", bd.red.endGameRobot1)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Three layers
|
|
56
|
+
|
|
57
|
+
| Layer | Import | What it does |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `TBAClient` | `from bluealliance import TBAClient` | Raw HTTP — returns `dict`/`list`. One method per TBA endpoint (84 total). |
|
|
60
|
+
| `TBACollector` | `from bluealliance import TBACollector` | Typed — wraps every client method to return Pydantic models instead of dicts. Handles pagination automatically. |
|
|
61
|
+
| Schemas | `from bluealliance import Team, Match, Event` | Pydantic v2 models. Use `Model.model_validate(raw)` if you already have a dict. |
|
|
62
|
+
|
|
63
|
+
You can mix layers freely — `TBACollector` for most work, `TBAClient` when you need the raw payload for something not covered by the schemas.
|
|
64
|
+
|
|
65
|
+
## Low-level client
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from bluealliance import TBAClient
|
|
69
|
+
|
|
70
|
+
client = TBAClient("YOUR_TBA_KEY")
|
|
71
|
+
|
|
72
|
+
# returns raw dict/list -- no Pydantic parsing
|
|
73
|
+
raw = client.get_event_matches("2025spbra")
|
|
74
|
+
raw_team = client.get_team("frc7563")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Pydantic models directly
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from bluealliance.schemas import Team, Match, ScoreBreakdown2025, parse_score_breakdown_2025
|
|
81
|
+
|
|
82
|
+
team = Team.model_validate(raw_dict)
|
|
83
|
+
|
|
84
|
+
match = Match.model_validate(raw_match_dict)
|
|
85
|
+
bd = parse_score_breakdown_2025(match.score_breakdown)
|
|
86
|
+
if bd:
|
|
87
|
+
print(bd.red.totalPoints, bd.blue.endGameBargePoints)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Available collector methods
|
|
91
|
+
|
|
92
|
+
### Status
|
|
93
|
+
- `c.status()` → `APIStatus`
|
|
94
|
+
|
|
95
|
+
### Teams
|
|
96
|
+
- `c.team(key)` → `Team`
|
|
97
|
+
- `c.team_simple(key)` → `TeamSimple`
|
|
98
|
+
- `c.team_history(key)` → `TeamHistory`
|
|
99
|
+
- `c.team_robots(key)` → `list[TeamRobot]`
|
|
100
|
+
- `c.team_awards(key, year?)` → `list[Award]`
|
|
101
|
+
- `c.team_media(key, year)` → `list[MediaBase]`
|
|
102
|
+
- `c.team_events(key, year?)` → `list[Event]`
|
|
103
|
+
- `c.team_matches(key, year)` → `list[Match]`
|
|
104
|
+
- `c.team_event_matches(key, event_key)` → `list[Match]`
|
|
105
|
+
- `c.team_event_status(key, event_key)` → `TeamEventStatus | None`
|
|
106
|
+
- `c.team_season_summary(key, year)` → `TeamSeasonSummary`
|
|
107
|
+
- `c.all_teams_by_year(year)` → `list[Team]` *(auto-paginates)*
|
|
108
|
+
|
|
109
|
+
### Events
|
|
110
|
+
- `c.events(year)` → `list[Event]`
|
|
111
|
+
- `c.event(key)` → `Event`
|
|
112
|
+
- `c.event_teams(key)` → `list[Team]`
|
|
113
|
+
- `c.event_matches(key)` → `list[Match]`
|
|
114
|
+
- `c.event_matches_2025(key)` → `list[tuple[Match, ScoreBreakdown2025 | None]]`
|
|
115
|
+
- `c.event_rankings(key)` → `EventRanking | None`
|
|
116
|
+
- `c.event_oprs(key)` → `EventOPRs | None`
|
|
117
|
+
- `c.event_alliances(key)` → `list[EliminationAlliance] | None`
|
|
118
|
+
- `c.event_awards(key)` → `list[Award]`
|
|
119
|
+
- `c.event_teams_statuses(key)` → `dict[str, TeamEventStatus | None]`
|
|
120
|
+
- `c.event_bundle(key)` → `EventBundle`
|
|
121
|
+
|
|
122
|
+
### Matches
|
|
123
|
+
- `c.match(key)` → `Match`
|
|
124
|
+
- `c.match_2025(key)` → `tuple[Match, ScoreBreakdown2025 | None]`
|
|
125
|
+
- `c.match_zebra(key)` → `Zebra`
|
|
126
|
+
|
|
127
|
+
### Districts
|
|
128
|
+
- `c.districts(year)` → `list[District]`
|
|
129
|
+
- `c.district_rankings(key)` → `list[DistrictRanking] | None`
|
|
130
|
+
- `c.district_advancement(key)` → `dict[str, DistrictAdvancement] | None`
|
|
131
|
+
|
|
132
|
+
### Regional (2025+)
|
|
133
|
+
- `c.regional_advancement(year)` → `dict[str, RegionalAdvancement] | None`
|
|
134
|
+
- `c.regional_rankings(year)` → `list[RegionalRanking] | None`
|
|
135
|
+
|
|
136
|
+
### Insights
|
|
137
|
+
- `c.leaderboards(year)` → `list[LeaderboardInsight]`
|
|
138
|
+
- `c.insights_v2(year, category?)` → `list[InsightV2...]`
|
|
139
|
+
|
|
140
|
+
## Requirements
|
|
141
|
+
|
|
142
|
+
- Python 3.11+
|
|
143
|
+
- `requests >= 2.32`
|
|
144
|
+
- `pydantic >= 2.7`
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "bluealliance"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python client for The Blue Alliance API v3 — typed, schema-validated, zero boilerplate."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
keywords = ["frc", "first-robotics", "the-blue-alliance", "tba", "api-client"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"requests>=2.32",
|
|
25
|
+
"pydantic>=2.7",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
dev = [
|
|
30
|
+
"pytest>=8.0",
|
|
31
|
+
"pytest-cov",
|
|
32
|
+
"ruff",
|
|
33
|
+
"mypy",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Repository = "https://github.com/Kaique-Sique/BlueAlliancePy"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.wheel]
|
|
40
|
+
packages = ["src/bluealliance"]
|
|
41
|
+
artifacts = ["src/bluealliance/py.typed"]
|
|
42
|
+
|
|
43
|
+
[tool.ruff]
|
|
44
|
+
line-length = 100
|
|
45
|
+
target-version = "py311"
|
|
46
|
+
|
|
47
|
+
[tool.mypy]
|
|
48
|
+
python_version = "3.11"
|
|
49
|
+
strict = true
|