-
Notifications
You must be signed in to change notification settings - Fork 0
Pulling data
All the data is really easy to pull. Let's say you want to pull an Event model from the Blue Alliance.
The pull methods in the TBA class are named the same as they are on the https://www.thebluealliance.com/apidocs page. Every method is documented and will show the required parameters (and example parameters) as well as what the method returns. You can also find this information on TBA API page. Here are some examples of pulling data:
Event e = tba.getEvent("casd", 2016);
Team t = tba.getTeam(4859);
Team[] teams = tba.getTeams("casd", 2016);
Match m = tba.getMatch(2016, "casd", "f1m1");
DistrictRanking[] rankings = tba.getDistrictRankings("ne", 2016);
Some methods return a single model, some return an array, some return arrays of strings. All the methods are clearly documented. The general format is: pull the data you want, see what model it returns, look at that model's class, and see what data you have to work with.
On a sidenote, if you ever need to print out a model to the console, check out the Test class. It will give you a start on all the system.outs.
When pulling an Event model, you have some more customization options. Events contain a lot of stuff: teams, matches, alliances, stuff like that. By default, the TBA server doesn't deliver these to you when you pull an event, which might be kind of inconvenient for you. So, I've added a way to configure what data is added to the Event model when it is pulled. Take a look at the settings class (https://github.com/techguy9984/TBA-API/blob/master/TBA-API/src/com/cpjd/main/Settings.java). Here are the different options you have to configure:
GET_EVENT_AWARDS If true, all the awards won within the event will be added to the Event's Award[] array when the event is pulled.
GET_EVENT_TEAMS If true, all the teams within this event will be added to the Event's Team[] array when the event is pulled.
GET_EVENT_MATCHES If true, all the matches within this event will be added to the Event's Match[] array when the event is pulled.
GET_EVENT_ALLIANCES If true, all the alliances (picks & declines) will be added to the Event's Alliance[] array when the event is pulled.
GET_EVENT_WEBCASTS If true, all the webcasts will be added to the Event's Webcast[] array when the event is pulled.
FIND_TEAM_RANKINGS If the GET_EVENT_TEAMS boolean is also true, then the Team[] array will be sorted by the team's ranking, with index 0 being the team in first place.
If any of these settings are false, their respective array will remain null when the event is pulled.
Set any of these settings with the general format:
Settings.option = true; or Settings.option = false;
For example: Settings.GET_EVENT_TEAMS = true;
When V3 support is officially added, use Settings.useAPIV3(true)