Created
November 6, 2016 19:14
-
-
Save ssplatt/39329c6855d7d3376e7ba8098ecc60f0 to your computer and use it in GitHub Desktop.
NFL API wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NFLApi | |
include HTTParty | |
#wrapper for nfl.com player stats | |
base_uri 'http://api.fantasy.nfl.com/v1' | |
def initialize() | |
end | |
def get_players_stats(options={}) | |
#player stats | |
#http://api.fantasy.nfl.com/v1/docs/service?serviceName=playersStats | |
#stattype, season, week, position | |
Rails.cache.fetch(["/players/stats", { query: options }], :expires => 1.hour) do | |
self.class.get("/players/stats", { query: options }) | |
end | |
end | |
def get_players_details(options={}) | |
#player details | |
#http://api.fantasy.nfl.com/v1/docs/service?serviceName=playersDetails | |
Rails.cache.fetch(["/players/details", { query: options }], :expires => 1.hour) do | |
self.class.get("/players/details", { query: options }) | |
end | |
end | |
def get_players_weekstats(options={}) | |
#live stats | |
#http://api.fantasy.nfl.com/v1/docs/service?serviceName=playersWeekStats | |
#season, week, position | |
Rails.cache.fetch(["/players/weekstats", { query: options }], :expires => 1.hour) do | |
self.class.get("/players/weekstats", { query: options }) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment