forked from timothyf/gameday_api
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
65 lines (44 loc) · 2.47 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Gameday API
The Gameday API allows you to fetch live statistical data from MLB.com servers. This is the same data that is used by the
Gameday application available on MLB.com. 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.
Requirements
* hpricot
Usage
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 = Team.new('det')
games = team.games_for_date('2009', '09', '15')
games[0].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
puts
end
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 = Team.new('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']
else
puts 'Visitors: ' + starters[0]['name']
end
end
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 http://gdx.mlb.com/components/copyright.txt
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.