Project

jtv

0.01
No commit activity in last 3 years
No release in over 3 years
Ruby wrapper for the Justin.tv and Twitch.tv API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

Jtv Code Climate Build Status

This library provides a complete wrapper for the Justin.TV and Twitch.TV APIs.

Installation

Add this line to your application's Gemfile:

gem 'jtv'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jtv

Justin.TV API Keys

If you want access to higher rate limits for your application, then you need to sign up for a Justin.TV developer account.

Once you have your API Keys, you can set them up using the configuration guide below.

Configuration

  Jtv.configure do |config|
    config.consumer_key = YOUR_CONSUMER_KEY
    config.consumer_secret = YOUR_CONSUMER_SECRET
  end

If you want to make requests on behalf of a specific user, then you need to instantiate a client.

  @client = Jtv::Client.new oauth_token: 'users_token',
    oauth_secret: 'users_secret'

Usage

The Jtv gem offers various methods depending on the type of information you're looking for.

It's recommended to cache your requests, and to always keep your account's rate limit in mind.

Check out the RDOC.

Stream

Summary

Returns aggregate stream information for all live channels (possibly scoped by category).

  Jtv.summary
  # {"average_bitrate"=>0, "streams_count"=>4346, "viewers_count"=>"142733"}

  Jtv.summary channel: 'mockra'
  # {"average_bitrate"=>0, "streams_count"=>0, "viewers_count"=>0}

You can include a channel, language, or category in your search params.

Featured

Returns stream information for all live channels. The results are sorted by the current number of viewers, with the most popular channels first.

  Jtv.featured
  # [{'name' => 'live_user_wingsofdeath'...}]

Search

Returns stream information for the live channels that match a search query. The results are sorted by the current number of viewers, with the most popular channels first.

  Jtv.search 'gaming', limit: 1
  # [{'name' => 'live_user_steven_bonnell_ii'...}]

The first argument is your search query, and you can also pass limit and offset as params.

User

Show

Returns extended information for a user, specified by user id or login.

  Jtv.user_show 'mockra'
  # {"id"=>22056792...}

Pass in a user's login.

Channel

Show

Returns extended information for a channel, specified by channel id or login. Requires OAuth authentication for private channels.

  Jtv.channel_show 'apidemo'
  # {'login'=>'apidemo'...}

Pass in a login or id for the channel.

Fans

Get users who are fans of a channel. Requires OAuth authentication for private channels.

  Jtv.fans id: 'officecam'
  # [{'id'=>23}]

Login must be included for the channel. Optional limit and offset params (defaults are 20 for limit and 0 for offset). Results returned are limited to 100. Results are returned in create date order.

Archives

Get archives from a given channel. Requires OAuth authentication for private channels.

  Jtv.archives id: 'dotahut', limit: 2
  # [{'video_codec' => 'AVC'}, {}]

channel id or login must be included as a param. Optional limit and offset params (defaults are 20 for limit and 0 for offset). Results returned are limited to 100. Results are returned in create date order

Contributing

Contributions and feedback are more than welcome and highly encouraged.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contact

david@mockra.com

@Mockra_

mockra.com