Package: falcon-alliance
FalconAllianceA Pythonic wrapper around TBA and other FRC data sources at your convenience. You can find the documentationhere.InstallationTo installfalcon-alliance, run the following in your console:(.venv)$pipinstallfalcon-allianceIf the following doesn't work, and you get an error regarding pip not being a command, try one of the following below:(.venv)$python-mpipinstallfalcon-alliance(.venv)$python3-mpipinstallfalcon-alliance(.venv)$python3.<your_version>-mpipinstallfalcon-allianceSetupOnce you havefalcon-allianceinstalled, a basic skeleton of FalconAlliance code isimportfalcon_alliancewithfalcon_alliance.ApiClient(api_key=YOUR_API_KEY)asapi_client:# Code using the API client hereFor more information about the building block of FalconAlliance code, check outthis sectionof our documentation.Do note that passing in the API key is not required if the API key is already stored in your.envfile under the nameTBA_API_KEYorAPI_KEY.As for the code within the context manager (the with statement), below is an example of retrieving a list of all the teams that played in 2022 via FalconAlliance:importfalcon_alliancewithfalcon_alliance.ApiClient(api_key=YOUR_API_KEY)asapi_client:all_teams=api_client.teams(year=2022)For more examples with the building block, check out theCommon Taskssection and theExamplessection.StructureThe structure of FalconAlliance code follows a hierarchy, withApiClientbeing at the top, containing agnostic methods like getting a list of all teams from a certain year, a list of all events from a certain year, etc.In the middle of the hierarchy are schemas with methods in them, containing endpoints depending on a certain team/event/district.Team,Event, andDistrict, which wrap around endpoints that depend on a certain key (team key/event key/district key). An example of a method for each of the following classes are:Team.events, which wraps around the/team/{team_key}/eventsendpoint.Event.teams, which wraps around the/event/{event_key}/teamsendpoint.District.rankings, which wraps around the/district/{district_key}/rankingsendpoint.At the bottom of the hierarchy are schemas which primarily act as data-classes, and are there as a means of communicating data in a readable format rather than having functionality. The classes at the bottom of the hierarchy are:Award,EventTeamStatus,Match,Media, andRobot.PlottingFalconAlliance has a plotting feature that makes on-the-fly visualizations for you based on your data.You can learn more about the plotting featurehere.ExamplesCreating a Dictionary Containing how many Teams each State hasimportfalcon_alliancestates_to_teams={}withfalcon_alliance.ApiClient(api_key=YOUR_API_KEY)asapi_client:all_teams=api_client.teams(year=2022)forteaminall_teams:states_to_teams[team.state_prov]=states_to_teams.get(team.state_prov,0)+1Getting the Average Rookie Year of Teams in a Districtimportfalcon_alliancewithfalcon_alliance.ApiClient(api_key=YOUR_API_KEY)asapi_client:team4099=falcon_alliance.Team(4099)# Suggested waymatch_with_max_score=team4099.max(2022,metric=falcon_alliance.Metrics.MATCH_SCORE)maximum_score=match_with_max_score.alliance_of(team4099).score# Alternative waymatch_scores=[]formatchinteam4099.matches(year=2022):match_scores.append(match.alliance_of(team4099).score)maximum_match_score=max(match_scores)Finding the Maximum Score from all the Matches a Team Played During a Yearimportfalcon_alliancewithfalcon_alliance.ApiClient(api_key=YOUR_API_KEY)asapi_client:team4099=falcon_alliance.Team(4099)# Suggested waymatch_with_max_score=team4099.max(2022,metric=falcon_alliance.Metrics.MATCH_SCORE)maximum_score=match_with_max_score.alliance_of(team4099).score# Alternative waymatch_scores=[]formatchinteam4099.matches(year=2022):match_scores.append(match.alliance_of(team4099).score)maximum_match_score=max(match_scores)More examples are listed on the documentationhere.