I’d recommend looking at the Blue Alliance API. That’ll help you get past some of the information overload, as you’re already familiar with everything that’s being accessed. You can focus in on some specific piece of data and ignore everything else.
Overview:
Details:
Conceptually, it’s pretty easy - you call a URL (There are a LOT of possible URL’s in the TBA API - they all start with https://www.thebluealliance.com/api/v3/, and have some variables to plug in, indicated by curly brackets), and it returns some information. In reality, it can be a little more difficult :). The following is the basics of doing it in Java.
This function would be used to get information from an appropriate URL (for example, to get the basic team info for my team from TBA, it would be https://www.thebluealliance.com/api/v3/team/frc2177/simple). All you need to run it is the URL and your x-auth key from your TBA accounts page.
public InputStream getjSON(String path)
{
System.out.println("Fetching from URL: " + path);
InputStream stream = null;
try
{
URL url = new URL(path);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("User-Agent", "TBA-API");
connection.setRequestProperty("X-TBA-Auth-Key", auth); //x-auth key from TBA accounts page
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setUseCaches(false);
stream = (InputStream)connection.getInputStream();
}
catch (Exception e)
{
e.printStackTrace();
}
return stream;
}
It uses all native Java stuff, and returns an InputStream that you can iterate through to read the results. That’s basically it - with that simple function, we can access the API using the appropriate URL and get back any information we want. Calling that for https://www.thebluealliance.com/api/v3/team/frc2177/simple returns the following:
{
"city": "Mendota Heights",
"country": "USA",
"key": "frc2177",
"name": "Boston Scientific/PTC/Palmer Family&Visitation School",
"nickname": "The Robettes",
"state_prov": "Minnesota",
"team_number": 2177
}
Parsing through that can be a pain. I prefer to use a package called Jackson to help with the parsing. It lets me create a simple POJO for the information:
public class TeamSimple
{
public String key;
public int team_number;
public String nickname;
public String name;
public String city;
public String state_prov;
public String country;
}
Then It’s a simple call using the Jackson class com.fasterxml.jackson.databind.ObjectMapper class to parse the InputStream into the POJO:
TeamSimple result = mapper.readValue(getjSON("https://www.thebluealliance.com/api/v3/team/frc2177/simple"), TeamSimple.class);
After that, you can do whatever you want, because you now have the data in an easy to access java object!