Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Commit 449ad7a

Browse files
committed
2 parents 1b380e9 + 8a5b54e commit 449ad7a

291 files changed

Lines changed: 59052 additions & 1329 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
before_script:
2-
- chmod +x gradlew
31
language: java
42
jdk:
53
- oraclejdk8
4+
- openjdk8
5+
6+
before_install:
7+
- chmod +x gradlew
8+
9+
env:
10+
global:
11+
- JAVA_HOME=/usr/lib/jvm/java-8-oracle

README.md

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# The Blue Alliance API Java Library [![Build Status](https://travis-ci.org/spencerng/TBA-API-Java-Library.svg?branch=master)](https://travis-ci.org/spencerng/TBA-API-Java-Library)
1+
# The Blue Alliance API Java Library [![Build Status](https://travis-ci.org/spencerng/blue-alliance-api-java-library.svg?branch=master)](https://travis-ci.org/spencerng/blue-alliance-api-java-library)
22

33
Java client library to retrieve data from The Blue Alliance using TBA API v3
44

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/)
66

77
## Usage
88

@@ -13,60 +13,54 @@ Begin by creating a TBA object with your Read TBA API Key. This can be found or
1313

1414
### Regular Usage
1515

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).
1717

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).
1919

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:
2521

26-
**`tba.eventRequest`**
22+
Team[] midAtlanticTeams = tba.districtRequest.getTeams("2017mar");
2723

28-
* to be continued
24+
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).
2925

30-
**`tba.districtRequest`**
31-
32-
* to be continued
26+
### Advanced Usage
3327

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.
3529

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.
3731

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.
3933

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.
34+
APIResponse resp = tba.dataRequest.getDataTBA("/event/2017njfla/matches");
35+
String lastModified = resp.getLastModified();
36+
Match[] matchList = Deserializer.toMatchArray(resp.getJson());
4337

44-
Here is an (extremely inefficient) example of continuously fetching the `Team` objects for an event (`2017njfla`), if they have been updated.
38+
while(true){
39+
resp = tba.dataRequest.getDataTBA("/event/2017njfla/matches", lastModified);
4540

46-
TBA tba = new TBA(authKey);
47-
APIResponse resp = tba.dataRequest.getDataTBA("/event/2017njfla/teams");
48-
String lastModified = resp.getLastModified();
49-
Team[] teamList = Deserializer.toTeamArray(resp.getJson());
50-
while(true){
51-
resp = tba.dataRequest.getDataTBA("/event/2017njfla/teams", lastModified);
52-
if(resp.getResponseCode()!=304){
53-
teamList = Deserializer.jsonToTeamArray(resp.getJson());
54-
lastModified = resp.getLastModified();
55-
}
41+
if(resp.getResponseCode()!=304){ // HTTP code 304 indicates no change
42+
teamList = Deserializer.jsonToTeamArray(resp.getJson());
43+
lastModified = resp.getLastModified();
5644
}
45+
}
5746

5847
## Models
5948

60-
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.
6160

62-
**Award**
61+
## Examples
6362

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.
6963

7064
## Contact
7165

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.

doc/allclasses-frame.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<!-- NewPage -->
3+
<html lang="en">
4+
<head>
5+
<!-- Generated by javadoc (1.8.0_121) on Sat Jul 08 00:08:59 EDT 2017 -->
6+
<title>All Classes</title>
7+
<meta name="date" content="2017-07-08">
8+
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
9+
<script type="text/javascript" src="script.js"></script>
10+
</head>
11+
<body>
12+
<h1 class="bar">All&nbsp;Classes</h1>
13+
<div class="indexContainer">
14+
<ul>
15+
<li><a href="com/thebluealliance/api/v3/requests/APIResponse.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">APIResponse</a></li>
16+
<li><a href="com/thebluealliance/api/v3/models/Award.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Award</a></li>
17+
<li><a href="com/thebluealliance/api/v3/Constants.html" title="class in com.thebluealliance.api.v3" target="classFrame">Constants</a></li>
18+
<li><a href="com/thebluealliance/api/v3/requests/DataRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">DataRequest</a></li>
19+
<li><a href="com/thebluealliance/api/v3/Deserializer.html" title="class in com.thebluealliance.api.v3" target="classFrame">Deserializer</a></li>
20+
<li><a href="com/thebluealliance/api/v3/models/District.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">District</a></li>
21+
<li><a href="com/thebluealliance/api/v3/models/DistrictRanking.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">DistrictRanking</a></li>
22+
<li><a href="com/thebluealliance/api/v3/requests/DistrictRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">DistrictRequest</a></li>
23+
<li><a href="com/thebluealliance/api/v3/models/EliminationAlliance.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EliminationAlliance</a></li>
24+
<li><a href="com/thebluealliance/api/v3/models/Event.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Event</a></li>
25+
<li><a href="com/thebluealliance/api/v3/models/EventDistrictPoints.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventDistrictPoints</a></li>
26+
<li><a href="com/thebluealliance/api/v3/models/EventPoints.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventPoints</a></li>
27+
<li><a href="com/thebluealliance/api/v3/models/EventRankings.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">EventRankings</a></li>
28+
<li><a href="com/thebluealliance/api/v3/requests/EventRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">EventRequest</a></li>
29+
<li><a href="com/thebluealliance/api/v3/models/Match.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Match</a></li>
30+
<li><a href="com/thebluealliance/api/v3/requests/MatchRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">MatchRequest</a></li>
31+
<li><a href="com/thebluealliance/api/v3/models/Media.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Media</a></li>
32+
<li><a href="com/thebluealliance/api/v3/models/OPRs.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">OPRs</a></li>
33+
<li><a href="com/thebluealliance/api/v3/models/Ranking.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Ranking</a></li>
34+
<li><a href="com/thebluealliance/api/v3/models/Robot.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Robot</a></li>
35+
<li><a href="com/thebluealliance/api/v3/models/SimpleEvent.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleEvent</a></li>
36+
<li><a href="com/thebluealliance/api/v3/models/SimpleMatch.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleMatch</a></li>
37+
<li><a href="com/thebluealliance/api/v3/models/SimpleTeam.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">SimpleTeam</a></li>
38+
<li><a href="com/thebluealliance/api/v3/TBA.html" title="class in com.thebluealliance.api.v3" target="classFrame">TBA</a></li>
39+
<li><a href="com/thebluealliance/api/v3/models/Team.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">Team</a></li>
40+
<li><a href="com/thebluealliance/api/v3/models/TeamEventStatus.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">TeamEventStatus</a></li>
41+
<li><a href="com/thebluealliance/api/v3/requests/TeamRequest.html" title="class in com.thebluealliance.api.v3.requests" target="classFrame">TeamRequest</a></li>
42+
<li><a href="com/thebluealliance/api/v3/models/WLTRecord.html" title="class in com.thebluealliance.api.v3.models" target="classFrame">WLTRecord</a></li>
43+
</ul>
44+
</div>
45+
</body>
46+
</html>

doc/allclasses-noframe.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<!-- NewPage -->
3+
<html lang="en">
4+
<head>
5+
<!-- Generated by javadoc (1.8.0_121) on Sat Jul 08 00:08:59 EDT 2017 -->
6+
<title>All Classes</title>
7+
<meta name="date" content="2017-07-08">
8+
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
9+
<script type="text/javascript" src="script.js"></script>
10+
</head>
11+
<body>
12+
<h1 class="bar">All&nbsp;Classes</h1>
13+
<div class="indexContainer">
14+
<ul>
15+
<li><a href="com/thebluealliance/api/v3/requests/APIResponse.html" title="class in com.thebluealliance.api.v3.requests">APIResponse</a></li>
16+
<li><a href="com/thebluealliance/api/v3/models/Award.html" title="class in com.thebluealliance.api.v3.models">Award</a></li>
17+
<li><a href="com/thebluealliance/api/v3/Constants.html" title="class in com.thebluealliance.api.v3">Constants</a></li>
18+
<li><a href="com/thebluealliance/api/v3/requests/DataRequest.html" title="class in com.thebluealliance.api.v3.requests">DataRequest</a></li>
19+
<li><a href="com/thebluealliance/api/v3/Deserializer.html" title="class in com.thebluealliance.api.v3">Deserializer</a></li>
20+
<li><a href="com/thebluealliance/api/v3/models/District.html" title="class in com.thebluealliance.api.v3.models">District</a></li>
21+
<li><a href="com/thebluealliance/api/v3/models/DistrictRanking.html" title="class in com.thebluealliance.api.v3.models">DistrictRanking</a></li>
22+
<li><a href="com/thebluealliance/api/v3/requests/DistrictRequest.html" title="class in com.thebluealliance.api.v3.requests">DistrictRequest</a></li>
23+
<li><a href="com/thebluealliance/api/v3/models/EliminationAlliance.html" title="class in com.thebluealliance.api.v3.models">EliminationAlliance</a></li>
24+
<li><a href="com/thebluealliance/api/v3/models/Event.html" title="class in com.thebluealliance.api.v3.models">Event</a></li>
25+
<li><a href="com/thebluealliance/api/v3/models/EventDistrictPoints.html" title="class in com.thebluealliance.api.v3.models">EventDistrictPoints</a></li>
26+
<li><a href="com/thebluealliance/api/v3/models/EventPoints.html" title="class in com.thebluealliance.api.v3.models">EventPoints</a></li>
27+
<li><a href="com/thebluealliance/api/v3/models/EventRankings.html" title="class in com.thebluealliance.api.v3.models">EventRankings</a></li>
28+
<li><a href="com/thebluealliance/api/v3/requests/EventRequest.html" title="class in com.thebluealliance.api.v3.requests">EventRequest</a></li>
29+
<li><a href="com/thebluealliance/api/v3/models/Match.html" title="class in com.thebluealliance.api.v3.models">Match</a></li>
30+
<li><a href="com/thebluealliance/api/v3/requests/MatchRequest.html" title="class in com.thebluealliance.api.v3.requests">MatchRequest</a></li>
31+
<li><a href="com/thebluealliance/api/v3/models/Media.html" title="class in com.thebluealliance.api.v3.models">Media</a></li>
32+
<li><a href="com/thebluealliance/api/v3/models/OPRs.html" title="class in com.thebluealliance.api.v3.models">OPRs</a></li>
33+
<li><a href="com/thebluealliance/api/v3/models/Ranking.html" title="class in com.thebluealliance.api.v3.models">Ranking</a></li>
34+
<li><a href="com/thebluealliance/api/v3/models/Robot.html" title="class in com.thebluealliance.api.v3.models">Robot</a></li>
35+
<li><a href="com/thebluealliance/api/v3/models/SimpleEvent.html" title="class in com.thebluealliance.api.v3.models">SimpleEvent</a></li>
36+
<li><a href="com/thebluealliance/api/v3/models/SimpleMatch.html" title="class in com.thebluealliance.api.v3.models">SimpleMatch</a></li>
37+
<li><a href="com/thebluealliance/api/v3/models/SimpleTeam.html" title="class in com.thebluealliance.api.v3.models">SimpleTeam</a></li>
38+
<li><a href="com/thebluealliance/api/v3/TBA.html" title="class in com.thebluealliance.api.v3">TBA</a></li>
39+
<li><a href="com/thebluealliance/api/v3/models/Team.html" title="class in com.thebluealliance.api.v3.models">Team</a></li>
40+
<li><a href="com/thebluealliance/api/v3/models/TeamEventStatus.html" title="class in com.thebluealliance.api.v3.models">TeamEventStatus</a></li>
41+
<li><a href="com/thebluealliance/api/v3/requests/TeamRequest.html" title="class in com.thebluealliance.api.v3.requests">TeamRequest</a></li>
42+
<li><a href="com/thebluealliance/api/v3/models/WLTRecord.html" title="class in com.thebluealliance.api.v3.models">WLTRecord</a></li>
43+
</ul>
44+
</div>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)