mlb-game-day
A JavaScript wrapper around the MLB Game Day API that can be used on the server or browser.
Install
$ npm install mlb-game-day -S
Use with TypeScript
You can use this library with TypeScript. To do this, you'll also need to grab a couple external type definition dependencies (axios and es6-promise).
I use typings to handle TypeScript type definition dependencies.
$ npm install typings -g
then from the directory of your application
$ typings install axios es6-promise --ambient
typings will install the type definitions to a typings
folder which contains a
main.d.ts
file which can referenced from your project's typescript config.
API
Methods
Methods
gameIds(date)
Retrieves a list of game id's for a given date. If no date is provided, the current date is used.
Arguments
date
(Date): A date for which game id's will be retrieved.
Returns
(Axios.IPromise<string[]>): A list of string id's.
Example
; ; gameIdsdate.thenconsole.log; // ['2016_04_08_nyamlb_detmlb_1', ... ]
getGameBoxScoreById(id)
Retrieves the box score for the given game id.
Arguments
id
(String): The game id
Returns
(Promise): The box score for the given id.
Example
; ; gameIdsdate.then; // { home_sname: 'San Francisco', ... }
getGameEventsById(id)
Retrieves the game events for the given game id.
Arguments
id
(String): The game id
Returns
(Promise): The events for the given id.
Example
; ; gameIdsdate.then; // { inning: [ { num: 1, ... }, ... ], ... }
Use Locally
$ npm install && npm run typings
LICENSE
MIT