I’m relatively new to the javascript side of websites and The Blue Alliance API has gotten very confusing for me. I am attempting to display my team’s match results at different events on a page of our websites, but I cannot find much on how to do this. I contacted TBA but I figured I might be able to reach out to a wider community this way and see if anyone could help me out.
The Blue Alliance API is publically documented, at the following URL:
You need to get a myTBA key for your TBA account, and then you’ll be able to access the data.
The easiest way to get the data from TBA into the web-browser via JS is a Jquery AJAX request, setting the headers to include the proper TBA authentication.
EG:
$.ajax({
url: 'https://www.thebluealliance.com/api/v3/event/2017nytr/matches',
headers: {
'X-TBA-Auth-Key':'TBA KEY'
},
method: 'GET',
dataType: 'json',
success: function(data){
console.log(data);
}
});
The documentation that Tim pointed you to is the best place to start.
However, for displaying on your website, you might not want to go through the API. Each page has a match feed in the format thebluealliance.com/event/<<EVENT CODE>>/feed. Depending on your website/how you want to parse the data, you may be able to manipulate it to show only your team’s matches.
Going through the API would be much more straightforward than using the feed since you have direct access to a team’s matches. Plus, it’s in a nicer format (JSON) and provides more match details.
Thank you everyone for your help and suggestions. I was following the api documentation but not knowing much about how it works, none of it made much sense. I’ll try a few of the things you guys suggested.
Don’t know if it will help your situation but I have just release our app that uses API v3 to pull data off the website. You can take a look to see how that works.
https://github.com/trc492/TBAShell