node-thebluealliance is a node.js wrapper library for The Blue Alliance v2 API. See the v2 API page for more information on what data can be returned.
This app uses The Blue Alliance's post-2013 event codes.
First install node. Then:
$ npm install thebluealliance
This will download node-thebluealliance to the local node_modules
folder, from which it can be imported with require
.
-
Arguments
frc_id
refers to the number assigned to each team by FIRST (i.e. 1540, 254, etc.)event_id
refers to The Blue Alliance's post-2013 event codes
-
CONSISTENT ACROSS EVERY FUNCTION: In node's style, all callbacks will receive an
error
object as the first argument. A nullerror
object indicates a successful request. The second argument in the callback will contain unchanged queried data from The Blue Alliance. The Blue Alliance data models are available under the Models sections of the API webpage.
type: null
or Error Object
Queried data returned by The Blue Alliance
- CONSISTENT ACROSS EVERY FUNCTION: The year argument is always optional and will always default to the current year. For example, calling
tba.getTeamsAtEvent('arc', callback);
is the same as calling
tba.getTeamsAtEvent('arc', (new Date()).getFullYear(), callback);
type: number
default: current year
The year for which data will be returned.
- Suggestions for improvement are always welcome at hmzh.khn@gmail.com
- initTBA
- tba
- getListOfTeams / getTeamList
- getTeamById / getTeam
- getEventsForTeam / getTeamEvent
- getAwardsForTeamAtEvent / getTeamEventAwards
- getMatchesForTeamsAtEvent / getTeamEventMatches
- getYearsParticipatedByTeam / getTeamYearsParticipated
- getMediaForTeam / getTeamMedia
- getListOfEvents / getEventList
- getEventById / getEvent
- getTeamsAtEvent / getEventTeams
- getMatchesAtEvent / getEventMatches
- getStatsAtEvent / getEventStats
- getRankingsAtEvent / getEventRankings
- getAwardsAtEvent / getEventAwards
- getEventHistoryForTeam / getTeamEventHistory
- getAwardHistoryForTeam / getTeamAwardHistory
- getRobotHistoryForTeam / getTeamRobotHistory
- getDistrictHistoryForTeam / getTeamDistrictHistory
- getSingleMatchFromKey / getSingleMatch
var initTBA = require('thebluealliance');
var tba = initTBA('node-thebluealliance','Node.js wrapper library for the TBA v2 API','1.1.1');
// or as a shortcut
var tba = require('thebluealliance')('node-thebluealliance','Node.js wrapper library for the TBA v2 API','1.1.1');
The Blue Alliance v2 API requires a custom X-TBA-App-Id
header in order to accept requests. Calling initTBA allows node-thebluealliance to retain this header for the duration of the library's use. Calling initTBA
returns the tba
object, which contains all of the methods required to retrieve data from The Blue Alliance.
Type: String
Name or organization of the user.
Type: String
Description of the application requesting data from The Blue Alliance.
Type: String
or Number
Version number of the application requesting data from The Blue Alliance.
Team List Request
on TBA API docs
Gets all the teams on one page of the team list at TBA
data_type: Array
of Teams
Team Request
on TBA API docs
Gets one team`s background info by its team id
Team Events Request
on TBA API docs
Gets all the team`s events from a single year
Team Event Awards Request
on TBA API docs
Gets all the teams awards for a single year at a single event
Team Event Matches Request
on TBA API docs
Gets all the team`s matches at a single event in a single year
Team Years Participated Request
on TBA API docs
returns array of years that the team has been participated in FIRST
Team Media Request
on TBA API docs
Gets all the teams media for a single year, as collected on TBA
'Team History Events Request' on TBA API docs Gets all historical events for a given team
'Team History Awards Request' on TBA API docs Gets all historical awards for a given team
'Team History Robots Request' on TBA API docs Gets all historical robots for a given team
'Team History Districts Request' on TBA API docs Gets all historical districts for a given team
Team List Request
on TBA API docs
Gets all the events in FIRST in a single year
Event Request
on TBA API docs
Gets event info for a single year
Event Teams Request
on TBA API docs
get all of the teams at an event
Event Matches Request
on TBA API docs
get all of the matches at an event
Event Stats Request
on TBA API docs
Gets the stats for a single event
Event Rankings Request
on TBA API docs
Gets the rankings for a single event
Event Awards Request
on TBA API docs
Gets awards at an event in a single year
Single Match Request
on TBA API docs
Gets information from 1 match at an event using a match key (see Match Model - key on TBA API docs)
tba.getTeamsAtEvent('casb', function(err, teamsInfo) {
// teamsInfo is a list of teams at the Inland Empire Regional for the current year
//...
});
- more clarity in documentation
- add better example code
- tests w/ Mocha
- ability to pass in more variants of ids/years (i.e.
'2014orore'
instead ofgetEvent('orore',2014)
)
- methods that allow analysis of certain data subsets (maybe a separate library for this)
- data caching for things that are unlikely to change
- for this one, limitations due to TBA API (can't get data subsets easily)
Copyright © 2014 Hamzah Khan <hmzh.khn@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.