Module: Seize::Twitch

Defined in:
lib/seize/twitch.rb

Constant Summary collapse

BASE_URL =
'https://api.twitch.tv/kraken'
HEADERS =
{:accept => 'application/vnd.twitchtv.v3+json',
:'client-id' => '2n7irufqjtyyayigyc4ubzq174axeex'}

Class Method Summary collapse

Class Method Details

.get_channel(channel_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/seize/twitch.rb', line 17

def self.get_channel(channel_name)
  begin
    channel_response = RestClient.get(
      "#{BASE_URL}/streams/#{channel_name}",
      { headers: HEADERS })
    JSON.parse(channel_response)
  rescue RestClient::NotFound
    nil
  end
end

.get_streams(limit: nil) ⇒ Object

TODO support games paramater



10
11
12
13
14
15
# File 'lib/seize/twitch.rb', line 10

def self.get_streams(limit: nil)
  streams_response = RestClient.get("#{BASE_URL}/streams", {
    params: { limit: limit }, headers: HEADERS,
  })
  JSON.parse(streams_response)
end