You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
# The Blue Alliance API Java Library [](https://travis-ci.org/spencerng/TBA-API-Java-Library)
1
+
# The Blue Alliance API Java Library [](https://travis-ci.org/spencerng/blue-alliance-api-java-library)
2
2
3
3
Java client library to retrieve data from The Blue Alliance using TBA API v3
4
4
5
-
The library is essentially complete, but documentation is in progress.
5
+
Full Javadoc documentation can be found [here](http://spencerng.github.io/blue-alliance-api-java-library/)
6
6
7
7
## Usage
8
8
@@ -13,60 +13,54 @@ Begin by creating a TBA object with your Read TBA API Key. This can be found or
13
13
14
14
### Regular Usage
15
15
16
-
The library allows access to almost all of the calls in [The Blue Alliance API v3 documentation](https://www.thebluealliance.com/apidocs/v3). They are grouped into requests with team, event, district, or match parameters:
16
+
The library allows access to almost all of the calls in [The Blue Alliance API v3 documentation](https://www.thebluealliance.com/apidocs/v3).
17
17
18
-
**`tba.teamRequest`**
18
+
They are grouped into requests with team, event, district, or match parameters, and you will need to use the `teamRequest`, `eventRequest`, or `matchRequest` instance variables found in the [`TBA` class](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/TBA.html).
19
19
20
-
*`getTeam(teamNumber)`: Gets a `Team` object for the team referenced by the given number (an `int`).
21
-
*`getSimpleTeam(teamNumber): Gets a `SimpleTeam` object for the team referenced by the given number.
22
-
* `getYearsParticipated(teamNumber): Gets a list of years in which the team participated in at least one competition.
23
-
* getDistricts(teamNumber): Gets a list of `District` objects for each year the team was in a district. Will return `null` if the team was never in a district.
24
-
* to be continued
20
+
Here is an example of retrieving an array of teams in the FIRST Mid-Atlantic district in 2017:
A list of request methods for each request object can be found [here](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/requests/package-summary.html).
29
25
30
-
**`tba.districtRequest`**
31
-
32
-
* to be continued
26
+
### Advanced Usage
33
27
34
-
**`tba.matchRequest`**
28
+
If you want to utilize the `If-Modified-Since` and `Last-Modified` headers, you will need to make a direct URL request with the [`getDataTBA(String urlDirectory, String ifModifiedSince)` method](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/requests/DataRequest.html#getDataTBA-java.lang.String-java.lang.String-) in the [`DataRequest` class](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/requests/DataRequest.html). This will return an [`APIResponse`](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/requests/APIResponse.html) object with JSON data, the HTTP response code, and the `Last-Modified` header.
35
29
36
-
*to be continued
30
+
The JSON data will need to be deserialized into an object model with a method in the [`Deserializer` class](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/Deserializer.html) before being used.
37
31
38
-
### Advance Usage
32
+
Here is an example of continuously fetching the `Match` objects for the 2017 Mount Olive District Event, if they have been updated. Note that this is very inefficient.
39
33
40
-
If you want to utilize the `If-Modified-Since` and `Last-Modified` headers, you will need to make a direct URL request (following the documentation). This will return an `APIResponse` object with JSON data, the HTTP response code, and the `Last-Modified` header.
41
-
42
-
The JSON data will need to be deserialized into an object model with a method in the `Deserializer` class before being used.
Most of the object models follow those on The Blue Alliance API documentation, with appropriately named getter methods:
49
+
A list of object model classes and their getter methods for instance variables can be found [here](http://spencerng.github.io/blue-alliance-api-java-library/com/thebluealliance/api/v3/models/package-summary.html)
50
+
51
+
## Dependencies
52
+
53
+
You will need [Gson](https://github.com/google/gson) to use the released compiled TBA API JAR file in your project. Gson can be installed with [Maven](https://maven-badges.herokuapp.com/maven-central/com.google.code.gson/gson), via a [JAR file](http://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.1/), or with Gradle if you include the following in your `build.gradle`
54
+
55
+
dependencies {
56
+
compile 'com.google.code.gson:gson:2.2.4'
57
+
}
58
+
59
+
Note that you will need Gradle to compile this repository's source code if you do not get Gson.
61
60
62
-
**Award**
61
+
## Examples
63
62
64
-
*`String getName()`: The name of the award as provided by FIRST. May vary for the same award type.
65
-
*`int getAwardType()`: Type of award given. See [here](https://github.com/the-blue-alliance/the-blue-alliance/blob/master/consts/award_type.py#L6) for details.
66
-
*`String getEventKey()`: The `event_key` of the event the award was won at.
67
-
*`AwardRecipient[] getRecipientList()`: A list of recipients of the award at the event. Either team_key and/or awardee for individual awards.
68
-
*`int getYear()`: The year this award was won.
69
63
70
64
## Contact
71
65
72
-
Feel free to contact me at sng1488@gmail.com or create a pull request if you have any questions, fixes, or suggestions. This library is (currently) unaffiliated with [FRC Team 25](http://raiderrobotix.org).
66
+
Feel free to contact me at sng1488@gmail.com or create a pull request if you have any questions, fixes, or suggestions.
<li><ahref="com/thebluealliance/api/v3/requests/APIResponse.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">APIResponse</a></li>
16
+
<li><ahref="com/thebluealliance/api/v3/models/Award.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Award</a></li>
17
+
<li><ahref="com/thebluealliance/api/v3/Constants.html" title="class in com.thebluealliance.api.v3" target="classFrame">Constants</a></li>
18
+
<li><ahref="com/thebluealliance/api/v3/requests/DataRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">DataRequest</a></li>
19
+
<li><ahref="com/thebluealliance/api/v3/Deserializer.html" title="class in com.thebluealliance.api.v3" target="classFrame">Deserializer</a></li>
20
+
<li><ahref="com/thebluealliance/api/v3/models/District.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">District</a></li>
21
+
<li><ahref="com/thebluealliance/api/v3/models/DistrictRanking.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">DistrictRanking</a></li>
22
+
<li><ahref="com/thebluealliance/api/v3/requests/DistrictRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">DistrictRequest</a></li>
23
+
<li><ahref="com/thebluealliance/api/v3/models/EliminationAlliance.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EliminationAlliance</a></li>
24
+
<li><ahref="com/thebluealliance/api/v3/models/Event.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Event</a></li>
25
+
<li><ahref="com/thebluealliance/api/v3/models/EventDistrictPoints.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventDistrictPoints</a></li>
26
+
<li><ahref="com/thebluealliance/api/v3/models/EventPoints.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventPoints</a></li>
27
+
<li><ahref="com/thebluealliance/api/v3/models/EventRankings.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventRankings</a></li>
28
+
<li><ahref="com/thebluealliance/api/v3/requests/EventRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">EventRequest</a></li>
29
+
<li><ahref="com/thebluealliance/api/v3/models/Match.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Match</a></li>
30
+
<li><ahref="com/thebluealliance/api/v3/requests/MatchRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">MatchRequest</a></li>
31
+
<li><ahref="com/thebluealliance/api/v3/models/Media.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Media</a></li>
32
+
<li><ahref="com/thebluealliance/api/v3/models/OPRs.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">OPRs</a></li>
33
+
<li><ahref="com/thebluealliance/api/v3/models/Ranking.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Ranking</a></li>
34
+
<li><ahref="com/thebluealliance/api/v3/models/Robot.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Robot</a></li>
35
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleEvent.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleEvent</a></li>
36
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleMatch.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleMatch</a></li>
37
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleTeam.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleTeam</a></li>
38
+
<li><ahref="com/thebluealliance/api/v3/TBA.html" title="class in com.thebluealliance.api.v3" target="classFrame">TBA</a></li>
39
+
<li><ahref="com/thebluealliance/api/v3/models/Team.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Team</a></li>
40
+
<li><ahref="com/thebluealliance/api/v3/models/TeamEventStatus.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">TeamEventStatus</a></li>
41
+
<li><ahref="com/thebluealliance/api/v3/requests/TeamRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">TeamRequest</a></li>
42
+
<li><ahref="com/thebluealliance/api/v3/models/WLTRecord.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">WLTRecord</a></li>
<li><ahref="com/thebluealliance/api/v3/requests/APIResponse.html" title="class in com.thebluealliance.api.v3.requests">APIResponse</a></li>
16
+
<li><ahref="com/thebluealliance/api/v3/models/Award.html" title="class in com.thebluealliance.api.v3.models">Award</a></li>
17
+
<li><ahref="com/thebluealliance/api/v3/Constants.html" title="class in com.thebluealliance.api.v3">Constants</a></li>
18
+
<li><ahref="com/thebluealliance/api/v3/requests/DataRequest.html" title="class in com.thebluealliance.api.v3.requests">DataRequest</a></li>
19
+
<li><ahref="com/thebluealliance/api/v3/Deserializer.html" title="class in com.thebluealliance.api.v3">Deserializer</a></li>
20
+
<li><ahref="com/thebluealliance/api/v3/models/District.html" title="class in com.thebluealliance.api.v3.models">District</a></li>
21
+
<li><ahref="com/thebluealliance/api/v3/models/DistrictRanking.html" title="class in com.thebluealliance.api.v3.models">DistrictRanking</a></li>
22
+
<li><ahref="com/thebluealliance/api/v3/requests/DistrictRequest.html" title="class in com.thebluealliance.api.v3.requests">DistrictRequest</a></li>
23
+
<li><ahref="com/thebluealliance/api/v3/models/EliminationAlliance.html" title="class in com.thebluealliance.api.v3.models">EliminationAlliance</a></li>
24
+
<li><ahref="com/thebluealliance/api/v3/models/Event.html" title="class in com.thebluealliance.api.v3.models">Event</a></li>
25
+
<li><ahref="com/thebluealliance/api/v3/models/EventDistrictPoints.html" title="class in com.thebluealliance.api.v3.models">EventDistrictPoints</a></li>
26
+
<li><ahref="com/thebluealliance/api/v3/models/EventPoints.html" title="class in com.thebluealliance.api.v3.models">EventPoints</a></li>
27
+
<li><ahref="com/thebluealliance/api/v3/models/EventRankings.html" title="class in com.thebluealliance.api.v3.models">EventRankings</a></li>
28
+
<li><ahref="com/thebluealliance/api/v3/requests/EventRequest.html" title="class in com.thebluealliance.api.v3.requests">EventRequest</a></li>
29
+
<li><ahref="com/thebluealliance/api/v3/models/Match.html" title="class in com.thebluealliance.api.v3.models">Match</a></li>
30
+
<li><ahref="com/thebluealliance/api/v3/requests/MatchRequest.html" title="class in com.thebluealliance.api.v3.requests">MatchRequest</a></li>
31
+
<li><ahref="com/thebluealliance/api/v3/models/Media.html" title="class in com.thebluealliance.api.v3.models">Media</a></li>
32
+
<li><ahref="com/thebluealliance/api/v3/models/OPRs.html" title="class in com.thebluealliance.api.v3.models">OPRs</a></li>
33
+
<li><ahref="com/thebluealliance/api/v3/models/Ranking.html" title="class in com.thebluealliance.api.v3.models">Ranking</a></li>
34
+
<li><ahref="com/thebluealliance/api/v3/models/Robot.html" title="class in com.thebluealliance.api.v3.models">Robot</a></li>
35
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleEvent.html" title="class in com.thebluealliance.api.v3.models">SimpleEvent</a></li>
36
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleMatch.html" title="class in com.thebluealliance.api.v3.models">SimpleMatch</a></li>
37
+
<li><ahref="com/thebluealliance/api/v3/models/SimpleTeam.html" title="class in com.thebluealliance.api.v3.models">SimpleTeam</a></li>
38
+
<li><ahref="com/thebluealliance/api/v3/TBA.html" title="class in com.thebluealliance.api.v3">TBA</a></li>
39
+
<li><ahref="com/thebluealliance/api/v3/models/Team.html" title="class in com.thebluealliance.api.v3.models">Team</a></li>
40
+
<li><ahref="com/thebluealliance/api/v3/models/TeamEventStatus.html" title="class in com.thebluealliance.api.v3.models">TeamEventStatus</a></li>
41
+
<li><ahref="com/thebluealliance/api/v3/requests/TeamRequest.html" title="class in com.thebluealliance.api.v3.requests">TeamRequest</a></li>
42
+
<li><ahref="com/thebluealliance/api/v3/models/WLTRecord.html" title="class in com.thebluealliance.api.v3.models">WLTRecord</a></li>
0 commit comments