{"id":13758534,"url":"https://github.com/schmich/kappa","last_synced_at":"2025-05-10T08:30:32.481Z","repository":{"id":56879889,"uuid":"9741468","full_name":"schmich/kappa","owner":"schmich","description":"The Twitch Ruby API","archived":true,"fork":false,"pushed_at":"2017-06-24T20:43:07.000Z","size":872,"stargazers_count":33,"open_issues_count":13,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T02:14:55.308Z","etag":null,"topics":["api","kappa","kraken","rest","ruby","twitch","twitch-tv"],"latest_commit_sha":null,"homepage":"http://rdoc.info/gems/kappa/frames","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schmich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-29T05:10:42.000Z","updated_at":"2024-01-28T21:33:29.000Z","dependencies_parsed_at":"2022-08-20T23:40:18.736Z","dependency_job_id":null,"html_url":"https://github.com/schmich/kappa","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmich%2Fkappa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmich%2Fkappa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmich%2Fkappa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmich%2Fkappa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schmich","download_url":"https://codeload.github.com/schmich/kappa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253389431,"owners_count":21900760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","kappa","kraken","rest","ruby","twitch","twitch-tv"],"created_at":"2024-08-03T13:00:31.900Z","updated_at":"2025-05-10T08:30:31.595Z","avatar_url":"https://github.com/schmich.png","language":"Ruby","readme":"# ![Kappa](https://raw.github.com/schmich/kappa/master/assets/kappa.png) Kappa\n\nKappa is the Ruby library for interfacing with the [Twitch.tv API](https://github.com/justintv/Twitch-API).\n\n[![Gem Version](https://badge.fury.io/rb/kappa.svg)](http://rubygems.org/gems/kappa)\n[![Build Status](https://secure.travis-ci.org/schmich/kappa.svg)](http://travis-ci.org/schmich/kappa)\n[![Dependency Status](https://gemnasium.com/schmich/kappa.svg)](https://gemnasium.com/schmich/kappa)\n[![Coverage Status](http://img.shields.io/coveralls/schmich/kappa.svg)](https://coveralls.io/r/schmich/kappa?branch=master)\n[![Code Climate](http://img.shields.io/codeclimate/github/schmich/kappa.svg)](https://codeclimate.com/github/schmich/kappa)\n\n## Getting Started\n\n```bash\ngem install kappa\n```\n\n```ruby\nrequire 'kappa'\n\nfrag = Twitch.channels.get('lethalfrag')\nputs frag.streaming?\n```\n\n```ruby\ngem 'kappa', '~\u003e 1.0'\n```\n\n## Configuration\n\nWhen making requests to Twitch, you must specify a client ID for your application.\nIf you do not specify a client ID, Twitch reserves the right to rate-limit your application\nwithout warning.\n\nYour client ID can be specified through configuration, for example:\n\n```ruby\nTwitch.configure do |config|\n  config.client_id = 'sc2daily-v1.0.0'\nend\n```\n\nSee the [`Twitch.configure`](http://rdoc.info/gems/kappa/Twitch#configure-class_method) documentation.\n\n## Examples\n\nGet the featured streams on the Twitch.tv homepage:\n\n```ruby\nTwitch.streams.featured do |stream|\n  channel = stream.channel\n  puts \"#{channel.display_name}: #{stream.viewer_count} viewers\"\n  puts \"#{channel.status}\"\n  puts '-' * 80\nend\n```\n\nSee if certain users are streaming:\n\n```ruby\nusers = ['destiny', 'followgrubby', 'incontroltv']\nTwitch.streams.find(:channel =\u003e users) do |stream|\n  puts \"#{stream.channel.name} is streaming #{stream.game_name}.\"\nend\n```\n\nGet the most popular games being streamed:\n\n```ruby\nTwitch.games.top(:limit =\u003e 3) do |game|\n  print \"#{game.name}: \"\n  print \"#{game.viewer_count} viewers in \"\n  puts  \"#{game.channel_count} channels\"\nend\n```\n\nGet streams for a particular game:\n\n```ruby\nTwitch.streams.find(:game =\u003e 'League of Legends') do |stream|\n  next if stream.viewer_count \u003c 1000\n  puts \"#{stream.channel.display_name}: #{stream.viewer_count}\"\nend\n```\n\nGet info for a single user:\n\n```ruby\nuser = Twitch.users.get('lethalfrag')\nstream = user.stream\n\nputs user.display_name\nif stream\n  puts \"Streaming #{stream.game_name} at #{stream.url}\"\nelse\n  puts 'Not streaming.'\nend\n```\n\nGet the followers of a channel:\n\n```ruby\nchannel = Twitch.channels.get('day9tv')\nchannel.followers do |user|\n  puts user.display_name\nend\n```\n\n## Resources\n\n### \u003ca id=\"channels\"\u003e\u003c/a\u003eChannels\n\nChannels serve as the home location for a [user's](#users) content. Channels have a [stream](#streams),\ncan run commercials, store [videos](#videos), display information and status, and have a customized page\nincluding banners and backgrounds. See the [`Channel`](http://rdoc.info/gems/kappa/Twitch/V2/Channel) documentation.\n\n```ruby\nc = Twitch.channels.get('destiny')\nc.nil?        # =\u003e false (channel exists)\nc.stream      # =\u003e #\u003cKappa::V2::Stream\u003e (current live stream)\nc.url         # =\u003e \"http://www.twitch.tv/destiny\"\nc.status      # =\u003e \"Destiny - Diamond I ADC  - Number 1 Draven player...\"\nc.teams       # =\u003e [#\u003cKappa::V2::Team\u003e]      \nc.videos      # =\u003e [#\u003cKappa::V2::Video\u003e, ...]\nc.followers   # =\u003e [#\u003cKappa::V2::User\u003e, ...]\n```\n\n### \u003ca id=\"streams\"\u003e\u003c/a\u003eStreams\n\nStreams are video broadcasts that are currently live. They belong to a [user](#users) and are part of a\n[channel](#channels). See the [`Stream`](http://rdoc.info/gems/kappa/Twitch/V2/Stream) and\n[`Streams`](http://rdoc.info/gems/kappa/Twitch/V2/Streams) documentation.\n\n```ruby\ns = Twitch.streams.get('idrajit')\ns.nil?          # =\u003e false (currently live)\ns.game_name     # =\u003e \"StarCraft II: Heart of the Swarm\"\ns.viewer_count  # =\u003e 7267\ns.channel.url   # =\u003e \"http://www.twitch.tv/idrajit\"\n```\n\n### \u003ca id=\"users\"\u003e\u003c/a\u003eUsers\n\nThese are members of the Twitch community who have a Twitch account. If broadcasting, they can own a\n[stream](#streams) that they can broadcast on their [channel](#channels). If mainly viewing, they might\nfollow or subscribe to channels. See the [`User`](http://rdoc.info/gems/kappa/Twitch/V2/User) documentation.\n\n```ruby\nu = Twitch.users.get('snoopeh')\nu.nil?                    # =\u003e false (user exists)\nu.channel                 # =\u003e #\u003cKappa::V2::Channel\u003e\nu.following.map(\u0026:name)   # =\u003e [\"national_esl1\", \"dreamhacklol\", \"riotgames\"]\n```\n\n### \u003ca id=\"videos\"\u003e\u003c/a\u003eVideos\n\nVideos are broadcasts or highlights owned by a [channel](#channels). Broadcasts are unedited videos that are saved\nafter a streaming session. Highlights are videos edited from broadcasts by the channel's owner. See the\n[`Video`](http://rdoc.info/gems/kappa/Twitch/V2/Video) and [`Videos`](http://rdoc.info/gems/kappa/Twitch/V2/Videos)\ndocumentation.\n\n```ruby\nv = Twitch.videos.get('a395995729')\nv.nil?          # =\u003e false (video exists)\nv.title         # =\u003e \"DreamHack Open Stockholm 26-27 April\"\nv.game_name     # =\u003e \"StarCraft II: Heart of the Swarm\"\nv.recorded_at   # =\u003e 2013-04-26 18:33:48 UTC\nv.view_count    # =\u003e 12506\n```\n\n### \u003ca id=\"teams\"\u003e\u003c/a\u003eTeams\n\nTeams are an organization of [channels](#channels). See the [`Team`](http://rdoc.info/gems/kappa/Twitch/V2/Team)\ndocumentation.\n\n```ruby\nt = Twitch.teams.get('teamliquid')\nt.nil?          # =\u003e false (team exists)\nt.display_name  # =\u003e \"TeamLiquid\"\nt.info          # =\u003e \"TeamLiquid is awesome. and esports. video games. \\n\\n\"\nt.updated_at    # =\u003e 2013-05-24 00:17:10 UTC\n```\n\n### \u003ca id=\"games\"\u003e\u003c/a\u003eGames\n\nGames are categories (e.g. League of Legends, Diablo 3) used by [streams](#streams) and [channels](#channels).\nGames can be searched for by query. See the [`Game`](http://rdoc.info/gems/kappa/Twitch/V2/Game),\n[`Games`](http://rdoc.info/gems/kappa/Twitch/V2/Games), and\n[`GameSuggestion`](http://rdoc.info/gems/kappa/Twitch/V2/GameSuggestion) documentation.\n\n```ruby\ntop = Twitch.games.top(:limit =\u003e 2)\ntop.map(\u0026:name)  # =\u003e [\"League of Legends\", \"StarCraft II: Heart of the Swarm\"]\n```\n\n```ruby\ng = Twitch.games.top(:limit =\u003e 1).first\ng.name                   # =\u003e \"League of Legends\"\ng.channel_count          # =\u003e 906\ng.viewer_count           # =\u003e 79223\ng.box_images.medium_url  # =\u003e\"http://static-cdn.jtvnw.net/ttv-boxart/31412.jpg\"\n```\n\n```ruby\ns = Twitch.games.find(:name =\u003e 'diablo', :live =\u003e true)\ns.map(\u0026:name)        # =\u003e [\"Diablo III\", \"Diablo II\", \"Diablo\"]\ns.map(\u0026:popularity)  # =\u003e [120, 4, 1]\n```\n\n## Errors\n\nAll errors derive from `Twitch::Error`.\n\n- `Twitch:Error` - Base class for all errors.\n- `Twitch::Error::ResponseError` - Base class for all Twitch.tv API response errors.\n- `Twitch::Error::FormatError` - The returned data was incorrectly formatted (e.g. invalid JSON).\n- `Twitch::Error::ClientError` - The server returned a 4xx status code.\n- `Twitch::Error::ServerError` - The server returned a 5xx status code.\n\nAll `ResponseError` errors have additional diagnostic information:\n\n```ruby\ne.status # =\u003e 422\ne.body   # =\u003e '{\"status\":422,\"message\":\"...\",\"error\":\"...\"}'\ne.url    # =\u003e \"https://api.twitch.tv/streams/desrow\"\n```\n\nSee the [`ResponseError`](http://rdoc.info/gems/kappa/Twitch/Error/ResponseError) documentation.\n\n## Documentation\n\n- Current release: [http://rdoc.info/gems/kappa/frames](http://rdoc.info/gems/kappa/frames)\n- Latest master: [http://rdoc.info/github/schmich/kappa/frames](http://rdoc.info/github/schmich/kappa/frames)\n- Twitch REST API: [https://github.com/justintv/Twitch-API](https://github.com/justintv/Twitch-API)\n\n## Versioning\n\n### Library version\n\nKappa adheres to the [Semantic Versioning 2.0.0](http://semver.org/) specification. Most importantly, any\ncompatibility- or API-breaking changes will result in a new major version (e.g. `1.x.x` to `2.x.x`). Because\nof this, you should use a [pessimistic version constraint](http://docs.rubygems.org/read/chapter/16#page74) when\ntaking a dependency on this library. For example:\n\n```ruby\ngem 'kappa', '~\u003e 1.0'\n```\n\nAny new backwards-compatible features will result in a new minor version (e.g. `x.1.x` to `x.2.x`) while any\nbackwards-compatible bugfixes will result in a new patch version (e.g. `x.x.1` to `x.x.2`).\n\n### Twitch API versions\n\nTwitch supports multiple versions of their API simultaneously, with each version potentially providing different data\nand behaving differently. Because of this, you can specify which version of the Twitch API you wish to use.\nThis is done through Kappa configuration.\n\nFor example, if you want to use the V2 Twitch API:\n\n```ruby\nTwitch.configure do |config|\n  config.client_id = 'sc2daily-v1.0.0'\n  config.api = Twitch::V2\nend\n```\n\n`Twitch::V2` is the default and is currently the only supported API version.\n\n## Contributing\n\n- [Fork and clone the repo.](http://help.github.com/fork-a-repo/)\n- [Create a branch for your changes.](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging)\n- Run `bundle install` to install development requirements.\n- Implement your feature or bug fix.\n- Add specs under the `spec` folder to prevent regressions or to test new code.\n- Add [YARD](http://rubydoc.info/docs/yard/file/docs/GettingStarted.md) documentation for new features. Run `rake yard` to view documentation.\n- Run `rake coverage` to run specs with code coverage. All specs must pass; coverage must remain at 100%. Run `rake coverage:view` to see a detailed report.\n- Commit and push your changes.\n- [Submit a pull request.](http://help.github.com/send-pull-requests/)\n\n## License\n\nCopyright \u0026copy; 2013 Chris Schmich  \nMIT License. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschmich%2Fkappa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschmich%2Fkappa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschmich%2Fkappa/lists"}