Skip to content

luk-/mlb.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notice:

It looks like since baseball is over, the XML data this relies on was removed from the web so this will no longer function. Once they put up their new back end for next year's season, I'll see if I can do this again (and better).

#mlb.js

##major league blernsball!

Build Status

Find all your favorite blernsball sportsball scores and events and games and schedule!

Installation

npm install mlb

Then in your code:

var mlb = require('mlb')

Mlb.js has many features useful for finding out sportsball fun facts, such as:

Schedules!

You can get some sweet SPORTS object of current games using mlb.games.get

Ex:

mlb.games.get(function(err, res) {
  console.log(res)
})

Or give it a date:

mlb.games.get(function (err, res) {
  console.log(res)
}, '2012, 05, 14')

Output (truncated):

{ '2012/05/15/houmlb-phimlb-1': 
   { home: 'Phillies',
     away: 'Astros',
     field: 'Citizens Bank Park',
     time: '1:05 PM',
     status: 'Final' },
  '2012/05/15/sdnmlb-wasmlb-1': 
   { home: 'Nationals',
     away: 'Padres',
     field: 'Nationals Park',
     time: '1:05 PM',
     status: 'Final' },
  '2012/05/15/clemlb-minmlb-1': 
   { home: 'Twins',
     away: 'Indians',
     field: 'Target Field',
     time: '1:10 PM',
     status: 'Final' } }

Neat!

Want some other blernsball sportsball details? OK!

Gonna need to parse that game ID first:

var game = mlb.games.url('2012/05/15/kcamlb-texmlb-1')

OK we're ready for some more SPOOOORTS!

mlb.events(game, function (err, res, body) {
  res.forEach(function (val) {
    console.log('Event: ' + val['@'].event)
    console.log('Description: ' + val['@'].des)
    console.log('Time: ' + val['@'].start_tfs_zulu + '\n')
  })
}, {limit: 2})

Output:

Event: Groundout
Description: Elvis Andrus grounds out, shortstop Alcides Escobar to first baseman Eric Hosmer.  
Time: 2012-05-16T02:46:42Z

Event: Home Run
Description: Brandon Snyder homers (3) on a fly ball to left field.  
Time: 2012-05-16T02:41:43Z

But I need the sports score so I can find out who won the game and support my TEEEEAM!

mlb.score(game, function (err, res) {
  console.log(res)
})

Output:

{ Rangers: '4', Royals: '7' }

Tests:

npm test

SPORTS ARE FINALLY FUN

###license: MIT

About

major league SPORTSBALL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages