Table of Contents
Cornelius
Cornelius let's you grab MLB data via MLBAM's public lookup routes. All of the data Cornelius returns is property of MLB Advanced Media, and subject to their usage terms.
Getting Started
yarn add cornelius
const cornelius = ;
Usage
cornelius.playerSearch
Search for players by name.
options
should be an object.
If you provide no search query, playerSearch
will return an empty array.
Parameters
options
Object Options object.
Examples
Active player search
cornelius ;
Historic player search
cornelius ;
Returns (Array | Object) Array of pruned search results or MLB search_player_all
JSON data.
cornelius.getPlayer
Takes a player's ID and returns their information.
options
should be an object.
If you provide no player ID, or an incorrect one, getPlayer
will return
an empty object.
Parameters
options
Object Options object.
Examples
Get a player by ID
cornelius ;
Returns Object Pruned player object or MLB player_info
JSON data.
cornelius.getStats
Takes a player's ID and returns their stats.
options
should be an object.
If you provide no player ID, or an incorrect one, getStats
returns an empty array.
If no year is provided, getStats
returns all available stats for the given player.
Parameters
options
Object Options object.
Examples
Get a player's hitting stats
cornelius ;
Get a player's pitching stats for the 2017 season
cornelius ;
Returns (Array | Object) Array of pruned stats or MLB sport_[statType]_tm
JSON data.
cornelius.getRoster
Takes a team's ID and returns their 40 man, or all time roster.
The season
property is a string of two years which mark the start and end seasons of the
all time rosters you're requesting. Providing a single year will return only that years roster.
Omitting the season
property will return a team's current 40 man roster.
options
should be an object.
If you provide no team ID, or an incorrect one, getRoster
returns an empty array.
Parameters
options
Object Options object.
Examples
Get a team's roster by ID
cornelius // New York Mets ;
Get a team's cumulative roster for the seasons beginning 2016 and ending 2017
cornelius ;
Returns (Array | Object) Pruned roster or MLB roster_40
| roster_team_alltime
JSON data.
License
MIT