-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsection1.html
182 lines (174 loc) · 8.07 KB
/
section1.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<!--
Micheal Willard
CS 290-400
Winter 2015
-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>MLBAM API How-To</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/blog.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="blog-masthead">
<div class="container">
<nav class="blog-nav">
<a class="blog-nav-item active" href="index.html">Home</a>
</nav>
</div>
</div>
<div class="container">
<div class="blog-header">
<!-- <h1 class="blog-title">Introduction to Accessing the MLBAM API</h1>
<p class="lead blog-description">by Micheal Willard</p> -->
</div>
<div class="row">
<div class="col-sm-8 blog-main">
<div class="blog-post">
<h2 class="blog-post-title">Section 1: The API Structure</h2>
<hr>
<p>As discussed in the Introduction, the base URL is:</p>
<pre><code>http://gd2.mlb.com/components/game/mlb/</code></pre>
<p>
The basic structure begins with the base URL and then trees down first by year, then month then date. The format is similar to the following:
</p>
<p>
<li><code>year_YYYY/</code></li>
<ul>
<li><code>month_MM/</code></li>
<ul>
<li><code>day_DD/</code></li>
</ul>
</ul>
</p>
<p>Building the URL out from that would take us to the Date Level Folder, as mentioned in the Introduction.
</p>
<pre><code> http://gd2.mlb.com/components/game/mlb/year_YYYY/month_MM/day_DD/</code></pre>
<p>
At the year level folder you can continue on to folders for each month. But this also contains <code>batters/</code> and <code>pitchers/</code> folders. Within those folders are <b>.xml</b> files for each batter and pitcher that played that year. These files can only be accessed if you have the batter's or pitcher's ID number. That ID number is assigned by MLB.
</p>
<p>
Accessing these files would require a .csv (for example) file that can tie batters to their ID numbers. There are a number of developers on Github whcih have compiled such lists, but I'm opting to not 'borrow' that data. So this How-To will not spend a lot of time on those files. I wanted to point them out as they are accessible and would contain relevant data depending on what you would like to do.
</p>
<h3>Structure</h3>
<h4>(Abbreviated)</h4>
http://gd2.mlb.com/components/game/mlb/
<ul>
<li>year_YYYY/</li>
<ul>
<li>batters/</li>
<li>media/</li>
<li>mobile/</li>
<li>pitchers/</li>
<li>month_MM/</li>
<ul><li>day_DD/</li>
<ul><li>miniscoreboard.json</li>
<li>master_scoreboard.json</li>
<li>batters/</li>
<li>pitchers/</li>
<li>etc,numerous other files</li>
<li>gid_YYYY_MM_DD_XXXmlb_YYYmlb_1/</li>
<ul>
<li>atv_feed_selection.xml</li>
<li>atv_game_events.xml</li>
<li>atv_preview.xml</li>
<li>atv_preview_noscores.xml</li>
<li>atv_runScoringPlays.xml</li>
<li>batters/</li>
<li>bench.xml</li>
<li>benchO.xml</li>
<li>bis_boxscore.xml</li>
<li>boxscore.json</li>
<li>boxscore.xml</li>
<li>emailSource.xml</li>
<li>eventLog.xml</li>
<li>feed_selection.plist</li>
<li>game.xml</li>
<li>game_events.json</li>
<li>game_events.plist</li>
<li>game_events.xml</li>
<li>gamecenter.xml</li>
<li>gameday_Syn.xml</li>
<li>inning/</li>
<li>linescore.json</li>
<li>linescore.xml</li>
<li>media/</li>
<li>miniscoreboard.xml</li>
<li>notifications/</li>
<li>onbase/</li>
<li>pitchers/</li>
<li>players.xml</li>
<li>plays.json</li>
<li>plays.xml</li>
<li>pregumbo.json</li>
<li>premium/</li>
<li>preview.plist</li>
<li>rawboxscore.xml</li>
<li>runScoringPlays.plist</li>
</ul>
</ul>
</ul>
</ul>
</ul>
<!-- <blockquote>
<p>Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong> ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</blockquote> -->
</div><!-- /.blog-post -->
<nav>
<ul class="pager">
<li><a href="index.html">Previous</a></li>
<li><a href="section2.html">Next</a></li>
</ul>
</nav>
</div><!-- /.blog-main -->
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
<div class="sidebar-module sidebar-module-inset">
<h4>About</h4>
<p>This site offers a How-To on accessing the MLB Advanced Media Api. The code is all done in Javascript, but PHP has similar methods which can be applied to attain the same effect if server side scripting is desired.</p>
</div>
<div class="sidebar-module">
<h4>Sections</h4>
<ol class="list-unstyled">
<li><a href="index.html">Home: About the API</a></li>
<li><a href="section2.html">Section 2: The Date Level Folder</a></li>
<li><a href="section3.html">Section 3: The Scoreboard JSONs</a></li>
<li><a href="section4.html">Section 4: Accessing the Scoreboard Data Using Javascript</a></li>
<li><a href="example.html">Section 5: A Scoreboard Example Using Javascript</a></li>
</ol>
</div>
<div class="sidebar-module">
<h4>Elsewhere</h4>
<ol class="list-unstyled">
<li><a href="https://github.com/michealwillard">GitHub</a></li>
</ol>
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
</div>
<footer class="blog-footer">
<p>Blog template built for <a href="http://getbootstrap.com">Bootstrap</a> by <a href="https://twitter.com/mdo">@mdo</a>.</p>
<p>
<a href="#">Back to top</a>
</p>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>