|
| 1 | +import os |
| 2 | +import pickle |
| 3 | + |
| 4 | +import tbaapiv3client |
| 5 | +from tbaapiv3client.rest import ApiException |
| 6 | + |
| 7 | +TBA_READ_KEY = os.environ["TBA_READ_KEY"] |
| 8 | +TEAM_KEY = "frc2767" |
| 9 | + |
| 10 | +configuration = tbaapiv3client.Configuration( |
| 11 | + host="https://www.thebluealliance.com/api/v3", |
| 12 | + api_key={"X-TBA-Auth-Key": TBA_READ_KEY}, |
| 13 | +) |
| 14 | + |
| 15 | +year = 2024 |
| 16 | + |
| 17 | +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed |
| 18 | +# configuration.api_key_prefix['X-TBA-Auth-Key'] = 'Bearer' |
| 19 | + |
| 20 | +# Enter a context with an instance of the API client |
| 21 | +with tbaapiv3client.ApiClient(configuration) as api_client: |
| 22 | + # Create an instance of the API class |
| 23 | + event_api = tbaapiv3client.EventApi(api_client) |
| 24 | + team_api = tbaapiv3client.TeamApi(api_client) |
| 25 | + |
| 26 | + try: |
| 27 | + # api_response = api_instance.get_team_event_status(team_key, event_key) |
| 28 | + events = event_api.get_team_events_by_year(TEAM_KEY, year) |
| 29 | + awards = team_api.get_team_awards_by_year(TEAM_KEY, year) |
| 30 | + results = team_api.get_team_events_statuses_by_year(TEAM_KEY, year) |
| 31 | + except ApiException as e: |
| 32 | + print("Exception when calling TeamApi->get_team_event_status: %s\n" % e) |
| 33 | + |
| 34 | +data = dict(awards=awards, events=events, results=results) |
| 35 | + |
| 36 | +with open(f"{year}_data.pickle", "wb") as f: |
| 37 | + pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL) |
0 commit comments