Module: MLBStatsAPI::Games

Included in:
Client
Defined in:
lib/mlb_stats_api/games.rb

Instance Method Summary collapse

Instance Method Details

#boxscore(game_id) ⇒ Object


5
6
7
# File 'lib/mlb_stats_api/games.rb', line 5

def boxscore(game_id)
  get "/game/#{game_id}/boxscore"
end

#color_feed(game_id, timecode: nil) ⇒ Object


44
45
46
47
48
49
50
# File 'lib/mlb_stats_api/games.rb', line 44

def color_feed(game_id, timecode: nil)
  MLBStatsAPI::ColorFeed.new(
    self,
    game_id,
    get("/game/#{game_id}/feed/color", timecode: timecode)
  )
end

#content(game_id, limit: nil) ⇒ Object


9
10
11
# File 'lib/mlb_stats_api/games.rb', line 9

def content(game_id, limit: nil)
  get "/game/#{game_id}/content", highlightLimit: limit
end

#context_metrics(game_id, timecode: nil) ⇒ Object


13
14
15
# File 'lib/mlb_stats_api/games.rb', line 13

def context_metrics(game_id, timecode: nil)
  get "/game/#{game_id}/contextMetrics", timecode: timecode
end

#linescore(game_id) ⇒ Object

def color_feed_timestamps(game_id)

get "/game/#{game_id}/feed/color/timestamps"

end


70
71
72
# File 'lib/mlb_stats_api/games.rb', line 70

def linescore(game_id)
  get "/game/#{game_id}/linescore"
end

#live_feed(game_id, timecode: nil) ⇒ Object

This endpoint can return very large payloads. It is STRONGLY recommended that clients ask for diffs and use “Accept-Encoding: gzip” header.


19
20
21
22
23
24
# File 'lib/mlb_stats_api/games.rb', line 19

def live_feed(game_id, timecode: nil)
  MLBStatsAPI::LiveFeed.new(
    self,
    get("/game/#{game_id}/feed/live", version: '1.1', timecode: timecode)
  )
end

#live_feed_diff(game_id, timecode: nil, snapshot_at: nil) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mlb_stats_api/games.rb', line 26

def live_feed_diff(game_id, timecode: nil, snapshot_at: nil)
  query = { version: '1.1' }

  if timecode
    query[:startTimecode] = timecode
  elsif snapshot_at
    query[:endTimecode] = snapshot_at
  else
    raise ArgumentError, 'Please pass either a timecode or a snapshot.'
  end

  get "/game/#{game_id}/feed/live/diffPatch", query
end

#live_feed_timestamps(game_id) ⇒ Object


40
41
42
# File 'lib/mlb_stats_api/games.rb', line 40

def live_feed_timestamps(game_id)
  get "/game/#{game_id}/feed/live/timestamps", version: '1.1'
end

#play_by_play(game_id, timecode: nil) ⇒ Object


74
75
76
# File 'lib/mlb_stats_api/games.rb', line 74

def play_by_play(game_id, timecode: nil)
  get "/game/#{game_id}/playByPlay", timecode: timecode
end

#win_probability(game_id, timecode: nil) ⇒ Object


78
79
80
# File 'lib/mlb_stats_api/games.rb', line 78

def win_probability(game_id, timecode: nil)
  get "/game/#{game_id}/winProbability", timecode: timecode
end