Git Product home page Git Product logo

pudney / gameday_api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timothyf/gameday_api

1.0 2.0 1.0 4.39 MB

A Ruby API for using the Major League Baseball Gameday statistics data. MLB provides very deep statistics for all major league baseball games through Gameday. Statistics include not only the typical boxscore stats, but also down to the physics of every single pitch thrown in the game. You can find the speed, movement, and position of every pitch thrown. The Gameday API makes it easy for Ruby developers to work with all this statistical information. The test directory included with the source code contains many examples of how the API can be used. If you prefer to use SVN, the gameday_api is also available via an SVN repository at: http://code.google.com/p/gamedayapi/ If you like this project, be sure to also check out the Baseball-Tracker project also hosted on GitHub. Baseball-Tracker is a web application that uses the gameday_api. You can find a hosted version of Baseball Tracker at http://baseballstatz.heroku.com

Home Page: http://gameday.timothyfisher.com/

License: MIT License

gameday_api's Introduction

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. There is a hosted version of Baseball Tracker available at baseballstatz.heroku.com

Requirements

Usage

You can verify that you have a working version of Gameday API with proper Internet connectivity by running the included unit tests. After downloading Gameday API, navigate to the test/unit_tests directory and open a command shell there. Run all of the tests by running the all_tests.rb suite:

ruby all_tests.rb

This should run the unit tests and report 0 failures and 0 errors.

Below are some examples of how you might use Gameday API. However this shows only a very small percentage of the API’s functionality. You can access a very deep set of live statistics through Gameday API. There are additional examples of its usage available in the test directory of Gameday API.

For each of these examples you should be in an IRB session opened in the lib directory of Gameday API.

Create a ‘boxscore.html’ file containing the boxscore for the Detroit Tigers game played on 9/15/2009.

require 'team'
team = Team.new('det')
games = team.games_for_date('2009', '09', '15')
games[0].get_boxscore.dump_to_file

Print linescores for all games played on 9/15/2009

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

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

Print the names of all hitters that Detroit used in the leadoff spot during 2009.

require 'team'
team = Team.new('det')
hitters = team.get_leadoff_hitters_by_year('2009')
hitters.each do |hitter|
   puts hitter.batter_name
end

Download all Gameday files for a specified year and month

require 'data_downloader'
downloader = DataDownloader.new
downloader.download_all_for_month(2009,5)

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 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.

gameday_api's People

Contributors

timothyf avatar

Stargazers

Sean Pudney avatar

Watchers

Sean Pudney avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.