Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Implementing TBA Api in Java (http://www.chiefdelphi.com/forums/showthread.php?t=135760)

ceb515 14-03-2015 14:12

Implementing TBA Api in Java
 
Okay guys I need some help:confused: ,
I'm creating a Java Program and I want it to be able to access match data from TBA and store it somewhere.

I have absolutely NO idea how to access the data from the API or how to store or display (JFrame) the data.

Any help or suggestions?

Jon Stratis 14-03-2015 14:32

Re: Implementing TBA Api in Java
 
Why use the Blue Alliance API and not the official FIRST API that the Blue Alliance most likely uses to populate their own data? You can find out more about the FIRST Event API on their TeamForge page: https://usfirst.collab.net/sf/projec...ty_developers/

If you decide to go that route, get signed up and I can share some of the work I've done with you... It's all in Java, designed to pull all of the data needed to calculate rankings for the MN State Championship invites - basically, a slightly modified version of the District ranking formula. It would at least give you a framework for making requests and parsing the results.

Past that, you'll have to decide what your requirements are for storing and displaying data. On the complex side of things, you could read all of the data into a database, and run a local webhost to put it in a browser, or a local app customized to display and navigate the data. On the easy side, you could spit it out into a CSV file and open it in Excel to play around with. In the middle, you can actually write the data directly to a nicely formatted, multi-tab spreadsheet (there's an apache library that makes this relatively easy to do, once you get it figured out). This is one of the things I love most about programming... there are a hundred ways to do what you want, you just have to decide which way to use!

ceb515 14-03-2015 14:40

Re: Implementing TBA Api in Java
 
Okay so I created an account on TeamForge, how would you like to share the code that you currently have?

-Charlie

Ether 14-03-2015 16:29

Re: Implementing TBA Api in Java
 
Quote:

Originally Posted by Jon Stratis (Post 1457515)
Why use the Blue Alliance API and not the official FIRST API that the Blue Alliance most likely uses to populate their own data?

If your goal is to a) write an app that uses FRC's API and b) share that app widely... you may want to get FIRST's approval before you do so.



ceb515 14-03-2015 16:30

Re: Implementing TBA Api in Java
 
Quote:

Originally Posted by Ether (Post 1457539)
If your goal it to a) write an app that uses FRC's API and b) share that app widely... you may want to get FIRST's approval before you do so.



My purpose is to make an app to use for myself and for my team, I would go to first before I go widespread

Ether 14-03-2015 16:33

Re: Implementing TBA Api in Java
 
Quote:

Originally Posted by ceb515 (Post 1457540)
...and for my team

Quote:

This token is meant for personal development, if you intend to use it for any significant volume, you must inform us and associated an organization and contact information or the token will be disabled.
.
.
.

Jon Stratis 14-03-2015 17:28

Re: Implementing TBA Api in Java
 
Each registered user/team gets a unique token that's used on every request - in other words, if you spam the server a ridiculous amount (for example, sticking it in an app like FRC Spyder and having every client hit the FRC servers) then FIRST can identify the offending developer and work with them to reduce the impact on the FRC servers (for example, by periodic polling of the servers and storage of results on a 3rd party server for further distribution from there).

Once FIRST accepts you in the group and issues you a token, message me on TeamForge and I'll send you some stuff to get you started there.

plnyyanks 14-03-2015 18:11

Re: Implementing TBA Api in Java
 
Quote:

Originally Posted by ceb515 (Post 1457512)
Okay guys I need some help:confused: ,
I'm creating a Java Program and I want it to be able to access match data from TBA and store it somewhere.

I have absolutely NO idea how to access the data from the API or how to store or display (JFrame) the data.

Any help or suggestions?


If you still want to see a Java implementation of the TBA API, the Android app implements all the endpoints. You can check out the code here https://github.com/the-blue-alliance...liance-android

plnyyanks 14-03-2015 21:36

Re: Implementing TBA Api in Java
 
Here's a little more detailed info about the TBA API, now that I'm no longer trying to keep a regional on schedule...

The TBA API is pretty fully featured - it's got a lot of data you can pull in multiple ways. The simplest is the main API (documentation is here). You hit a url for the data you want, and get a response back. This is what the TBA Android app implements for its data source. Here are some links to getting started:
- Where API urls are built
- Where the HTTP Request is built
- All the model deserializers (to bring the json response into Java objects). I've been meaning to rip this out and make it into a library we can publish on maven central for other people to use, but that'll happen when I get the time...

TBA can also push live updates to a server of your choosing (documentation is here). This is how the Android app handles its push notifications. You subscribe your account to whatever you want (teams, events, everything, etc) and pick the notification types you would like to receive updates for, and TBA will push a POST request to a server you've registered every time something updates.

Here is an example project that implements a webhook receiver, and here specifically is where webhooks come in


All times are GMT -5. The time now is 10:27.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi