A Node.js wrapper for the new MLB API.
It looks like MLB has taken down the endpoints this repo hit to gather information. I'll be looking into other means, but for now this repo is useless. 🙃
Install via npm
npm install node-mlb-api --save
Use in your Node.js application
const MLBApi = require("node-mlb-api");
const games = MLBApi.getGames();
All functions return a promise containing the JSON response.
Get a list of games. Accepts an optional date argument as a string (MM/DD/YYYY) to get particular date. If no argument is passed it will get the current day.
MLBApi.getGames("03/03/2018");
Accepts optional argument for singleTeamId to only return information from one team. Otherwise it will return all 32 teams.
MLBApi.getTeams(133); // returns Oakland Athletics - see the MLB Stats documentation for IDs
Gets a single game's live feed. Accepts a required argument of the gamePk
id.
MLBApi.getGameFeed(533786); // Tigers vs. Yankees 02/23/2018
Gets a single game's linescore. Accepts a required argument of the gamePk
id.
MLBApi.getLinescore(533786); // Tigers vs. Yankees 02/23/2018
Gets a single game's boxscore. Accepts a required argument of the gamePk
id.
MLBApi.getBoxscore(533786); // Tigers vs. Yankees 02/23/2018
Gets a single game's color feed. Accepts a required argument of the gamePk
id.
Beware, the payload for this can get very large - see the disclaiming on the MLB Stats API
to learn more and how to manage the data responsibly.
MLBApi.getBoxscore(533786); // Tigers vs. Yankees 02/23/2018
Gets regular season standings by League. Accepts a required string argument of league
('AL'
/ 'NL'
) and an optional year argument (YYYY
). The response from the API
is broken up by division.
MLBApi.getStandings("NL", 2017); // 2017 NL Standings
The MLB Stats API documentation can be found here
NOTICE: This is NOT an official MLB product or affiliated with MLB in anyway.