Gameday API

The Gameday API allows you to fetch live statistical data from servers. This is the same data that is used by the Gameday application available on Another project on GitHub uses the Gameday API to create an application that allows users to view linescore, boxscore, and play-by-play data for any selected game. That project is called Baseball Tracker.


  • hpricot


Dumping an HTML Boxscore for a Specified Game: The code below will create a 'boxscore.html' file containing the boxscore for the Detroit Tigers game played on 9/15/2009.

$: << File.expand_path(File.dirname(__FILE__) + "/../lib")

require 'team' team ='det') games = team.games_for_date('2009', '09', '15') games.get_boxscore.dump_to_file

Print Linescores for the Specified Day The code below will output linescores for all games played on the date 9/15/2009.

$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
require 'game'
games = Game.find_by_date('2009','09','15')
games.each do |game| 
  puts game.print_linescore

Print all starting pitchers used by Detroit in 2009 The code below will output the name of the starting pitcher for all of Detroit's games from 2009. $: << File.expand_path(File.dirname(__FILE__) + “/../lib”) require 'team' team ='det') games = team.all_games('2009') games.each do |game|

 		starters = game.get_starting_pitchers
		if game.home_team_abbrev == 'det'
  		puts 'Home: ' + starters[1]['name']
  		puts 'Visitors: ' + starters[0]['name']


Usage Restriction

All documents fetched by this API clearly state:

Copyright 2009 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here

Which furthermore states:

The accounts, descriptions, data and presentation in the referring page (the “Materials”) are proprietary content of MLB Advanced Media, L.P (“MLBAM”).<br />Only individual, non-commercial, non-bulk use of the Materials is permitted and any other use of the Materials is prohibited without prior written authorization from MLBAM.<br />Authorized users of the Materials are prohibited from using the Materials in any commercial manner other than as expressly authorized by MLBAM.

Naturally, these terms are passed on to any who use this API. It is your responsibility to abide by them.