{"id":15562200,"url":"https://github.com/deanpcmad/twitchrb","last_synced_at":"2025-08-09T20:17:12.603Z","repository":{"id":46295474,"uuid":"321502769","full_name":"deanpcmad/twitchrb","owner":"deanpcmad","description":"Ruby library for the Twitch API","archived":false,"fork":false,"pushed_at":"2024-11-20T13:38:04.000Z","size":159,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-10T20:08:00.273Z","etag":null,"topics":["ruby","rubygem","twitch","twitch-api"],"latest_commit_sha":null,"homepage":"","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/deanpcmad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"deanpcmad","buy_me_a_coffee":"deanpcmad","ko_fi":"deanpcmad"}},"created_at":"2020-12-14T23:50:42.000Z","updated_at":"2024-11-20T13:38:08.000Z","dependencies_parsed_at":"2024-05-27T20:12:58.558Z","dependency_job_id":"1349326f-221d-4500-92a8-21f0efee18d9","html_url":"https://github.com/deanpcmad/twitchrb","commit_stats":{"total_commits":110,"total_committers":2,"mean_commits":55.0,"dds":0.3727272727272727,"last_synced_commit":"cadbbe3e0b721aee91843f09fd02930cd7b26146"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/deanpcmad/twitchrb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deanpcmad%2Ftwitchrb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deanpcmad%2Ftwitchrb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deanpcmad%2Ftwitchrb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deanpcmad%2Ftwitchrb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deanpcmad","download_url":"https://codeload.github.com/deanpcmad/twitchrb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deanpcmad%2Ftwitchrb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268214714,"owners_count":24214354,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ruby","rubygem","twitch","twitch-api"],"created_at":"2024-10-02T16:12:18.107Z","updated_at":"2025-08-09T20:17:12.542Z","avatar_url":"https://github.com/deanpcmad.png","language":"Ruby","funding_links":["https://github.com/sponsors/deanpcmad","https://buymeacoffee.com/deanpcmad","https://ko-fi.com/deanpcmad"],"categories":[],"sub_categories":[],"readme":"# TwitchRB\n\nTwitchRB is the easiest and most complete Ruby library for the [Twitch Helix API](https://dev.twitch.tv/docs/api).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"twitchrb\"\n```\n\n## Usage\n\n### Set Client Details\n\nFirstly you'll need to set a Client ID and an Access Token.\n\nAn access token is required because the Helix API requires authentication.\n\n```ruby\n@client = Twitch::Client.new(client_id: \"abc123\", access_token: \"xyz123\")\n```\n\n### Resources\n\nThe gem maps as closely as we can to the Twitch API so you can easily convert API examples to gem code.\n\nResponses are created as objects like `Twitch::Channel`. Having types like `Twitch::User` is handy for understanding what\ntype of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way.\n\n### Pagination\n\nSome of the endpoints return pages of results. The result object will have a `data` key to access the results, as well as metadata like `cursor`\nfor retrieving the next and previous pages. This can be used by using `before` and `after` parameters, on API endpoints that support it.\n\nAn example of using collections, including pagination:\n\n```ruby\nresults = @client.clips.list(broadcaster_id: 123)\n#=\u003e Twitch::Collection\n\nresults.total\n#=\u003e 30\n\nresults.data\n#=\u003e [#\u003cTwitch::Clip\u003e, #\u003cTwitch::Clip\u003e]\n\nresults.each do |result|\n  puts result.id\nend\n\nresults.first\n#=\u003e #\u003cTwitch::Clip\u003e\n\nresults.last\n#=\u003e #\u003cTwitch::Clip\u003e\n\nresults.cursor\n#=\u003e \"abc123\"\n\n# Retrieve the next page\n@client.clips.list(broadcaster_id: 123, after: results.cursor)\n#=\u003e Twitch::Collection\n```\n\n### OAuth\n\nThis library includes the ability to create, refresh and revoke OAuth tokens.\n\n```ruby\n# Firstly, set the client details\n@oauth = Twitch::OAuth.new(client_id: \"\", client_secret: \"\")\n\n# Create a Token\n# grant_type can be either \"authorization_code\" or \"client_credentials\"\n# scope is a space-delimited list of scopes. This is optional depending on the grant_type\n@oauth.create(grant_type: \"\", scope: \"\")\n\n# Refresh a Token\n@oauth.refresh(refresh_token: \"\")\n\n# Device Code Grant Flow\n# scopes is required and is a space-delimited list of scopes\n# https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow\n@oauth.device(scopes: \"bits:read channel:read:subscriptions\")\n\n# Validate an Access Token\n# Returns false if the token is invalid\n@oauth.validate(token: \"\")\n\n# Revoke a Token\n@oauth.revoke(token: \"\")\n```\n\n### Users\n\n```ruby\n# Retrieves a user by their ID\n@client.users.retrieve(id: 141981764)\n\n# Retrieves multiple users by their IDs\n# Requires an array of IDs\n@client.users.retrieve(ids: [141981764, 72938118])\n\n# Retrieves a user by their username\n@client.users.retrieve(username: \"twitchdev\")\n\n# Retrieves multiple users by their usernames\n# Requires an array of IDs\n@client.users.retrieve(usernames: [\"twitchdev\", \"deanpcmad\"])\n\n# Update the currently authenticated user's description\n# Required scope: user:edit\n@client.users.update(description: \"New Description\")\n\n# Returns Blocked users for a broadcaster\n# Required scope: user:read:blocked_users\n@client.users.blocks(broadcaster_id: 141981764)\n\n# Blocks a user\n# Required scope: user:manage:blocked_users\n@client.users.block_user(target_user_id: 141981764)\n\n# Unblocks a user\n# Required scope: user:manage:blocked_users\n@client.users.unblock_user(target_user_id: 141981764)\n\n# Get a User's Chat Color\n@client.users.get_color(user_id: 123)\n\n# Or get multiple users' chat colors\n# Returns a collection\n@client.users.get_color(user_ids: \"123,321\")\n\n# Update a User's Chat Color\n# Requires user:manage:chat_color\n# user_id must be the currently authenticated user\n# Current allowed colours: blue, blue_violet, cadet_blue, chocolate, coral, dodger_blue, firebrick, golden_rod, green, hot_pink, orange_red, red, sea_green, spring_green, yellow_green\n# For Turbo and Prime users, a hex colour code is allowed.\n@client.users.update_color(user_id: 123, color: \"blue\")\n\n# Get Emotes a User has\n# Required scope: user:read:emotes\n@client.users.emotes(user_id: 123)\n@client.users.emotes(user_id: 123, broadcaster_id: 321)\n@client.users.emotes(user_id: 123, after: \"abc123\")\n```\n\n### Channels\n\n```ruby\n# Retrieve a channel by their ID\n@client.channels.retrieve(id: 141981764)\n\n# Retrieve a list of broadcasters a specified user follows\n# user_id must match the currently authenticated user\n# Required scope: user:read:follows\n@client.channels.followed user_id: 123123\n\n# Retrieve a list of users that follow a specified broadcaster\n# broadcaster_id must match the currently authenticated user or\n# a moderator of the specified broadcaster\n# Required scope: moderator:read:followers\n@client.channels.followers broadcaster_id: 123123\n\n# Retrieve the number of Followers a broadcaster has\n@client.channels.follows_count(broadcaster_id: 141981764)\n\n# Retrieve the number of Subscribers and Subscriber Points a broadcaster has\n# Required scope: channel:read:subscriptions\n@client.channels.subscribers_count(broadcaster_id: 141981764)\n\n# Update the currently authenticated channel details\n# Required scope: channel:manage:broadcast\n# Parameters which are allowed: game_id, title, broadcaster_language, delay\nattributes = {title: \"My new title\"}\n@client.channels.update(broadcaster_id: 141981764, attributes)\n\n# Retrieves editors for a channel\n@client.channels.editors(broadcaster_id: 141981764)\n```\n\n### Videos\n\n```ruby\n# Retrieves a list of videos\n# Available parameters: user_id or game_id\n@client.videos.list(user_id: 12345)\n@client.videos.list(game_id: 12345)\n\n# Retrieves a video by its ID\n@client.videos.retrieve(id: 12345)\n```\n\n### Clips\n\n```ruby\n# Retrieves a list of clips\n# Available parameters: broadcaster_id or game_id\n@client.clips.list(user_id: 12345)\n@client.clips.list(game_id: 12345)\n\n# Retrieves a clip by its ID.\n# Clip IDs are alphanumeric. e.g. AwkwardHelplessSalamanderSwiftRage\n@client.clips.retrieve(id: \"AwkwardHelplessSalamanderSwiftRage\")\n\n# Create a clip of a given Channel\n# Required scope: clips:edit\n@client.clips.create(broadcaster_id: 1234)\n```\n\n### Emotes\n\n```ruby\n# Retrieve all global emotes\n@client.emotes.global\n\n# Retrieve emotes for a channel\n@client.emotes.channel(broadcaster_id: 141981764)\n\n# Retrieve emotes for an emote set\n@client.emotes.sets(emote_set_id: 301590448)\n```\n\n### Badges\n\n```ruby\n# Retrieve all global badges\n@client.badges.global\n\n# Retrieve badges for a channel\n@client.badges.channel(broadcaster_id: 141981764)\n```\n\n### Games\n\n```ruby\n# Retrieves a game by ID\n@client.games.retrieve(id: 514974)\n\n# Retrieves multiple games by IDs\n# Requires an array of IDs\n@client.games.retrieve(ids: [66402, 514974])\n\n# Retrieves a game by name\n@client.games.retrieve(name: \"Battlefield 4\")\n\n# Retrieves multiple games by names\n# Requires an array of IDs\n@client.games.retrieve(names: [\"Battlefield 4\", \"Battlefield 2042\"])\n```\n\n### EventSub Subscriptions\n\nThese require an application OAuth access token.\n\n```ruby\n# Retrieves a list of EventSub Subscriptions\n# Available parameters: status, type, after\n@client.eventsub_subscriptions.list\n@client.eventsub_subscriptions.list(status: \"enabled\")\n@client.eventsub_subscriptions.list(type: \"channel.follow\")\n\n# Create an EventSub Subscription\n@client.eventsub_subscriptions.create(\n  type: \"channel.follow\",\n  version: 1,\n  condition: {broadcaster_user_id: 123},\n  transport: {method: \"webhook\", callback: \"webhook_url\", secret: \"secret\"}\n)\n\n# Delete an EventSub Subscription\n# IDs are UUIDs\n@client.eventsub_subscriptions.delete(id: \"abc12-abc12-abc12\")\n```\n\n### Banned Events\n\n```ruby\n# Retrieves all ban and un-ban events for a channel\n# Available parameters: user_id\n@client.banned_events.list(broadcaster_id: 123)\n```\n\n### Banned Users\n\n```ruby\n# Retrieves all banned and timed-out users for a channel\n# Available parameters: user_id\n@client.banned_users.list(broadcaster_id: 123)\n```\n\n```ruby\n# Ban/Timeout a user from a broadcaster's channel\n# Required scope: moderator:manage:banned_users\n# A reason is required\n# To time a user out, a duration is required. If no duration is set, the user will be banned.\n@client.banned_users.create broadcaster_id: 123, moderator_id: 321, user_id: 112233, reason: \"testing\", duration: 60\n```\n\n```ruby\n# Unban/untimeout a user from a broadcaster's channel\n# Required scope: moderator:manage:banned_users\n@client.banned_users.delete broadcaster_id: 123, moderator_id: 321, user_id: 112233\n```\n\n### Send Chat Announcement\n\n```ruby\n# Sends an announcement to the broadcaster's chat room\n# Requires moderator:manage:announcements\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n# color can be either blue, green, orange, purple, primary. If left blank, primary is default\n@client.announcements.create broadcaster_id: 123, moderator_id: 123, message: \"test message\", color: \"purple\"\n```\n\n### Create a Shoutout\n\n```ruby\n# Creates a Shoutout for a broadcaster\n# Requires moderator:manage:shoutouts\n# From: the ID of the Broadcaster creating the Shoutout\n# To: the ID of the Broadcaster the Shoutout will be for\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.shoutouts.create from: 123, to: 321, moderator_id: 123\n```\n\n### Moderators\n\n```ruby\n# List all channels a user has moderator privileges on\n# Required scope: user:read:moderated_channels\n# user_id must be the currently authenticated user\n@client.moderators.channels user_id: 123\n```\n\n```ruby\n# List all moderators for a broadcaster\n# Required scope: moderation:read\n# broadcaster_id must be the currently authenticated user\n@client.moderators.list broadcaster_id: 123\n```\n\n```ruby\n# Add a Moderator\n# Required scope: channel:manage:moderators\n# broadcaster_id must be the currently authenticated user\n@client.moderators.create broadcaster_id: 123, user_id: 321\n```\n\n```ruby\n# Remove a Moderator\n# Required scope: channel:manage:moderators\n# broadcaster_id must be the currently authenticated user\n@client.moderators.delete broadcaster_id: 123, user_id: 321\n```\n\n### VIPs\n\n```ruby\n# List all VIPs for a broadcaster\n# Required scope: channel:read:vips or channel:manage:vips\n# broadcaster_id must be the currently authenticated user\n@client.vips.list broadcaster_id: 123\n```\n\n```ruby\n# Add a VIP\n# Required scope: channel:manage:vips\n# broadcaster_id must be the currently authenticated user\n@client.vips.create broadcaster_id: 123, user_id: 321\n```\n\n```ruby\n# Remove a VIP\n# Required scope: channel:manage:vips\n# broadcaster_id must be the currently authenticated user\n@client.vips.delete broadcaster_id: 123, user_id: 321\n```\n\n### Raids\n\n```ruby\n# Starts a raid\n# Requires channel:manage:raids\n# from_broadcaster_id must be the authenticated user\n@client.raids.create from_broadcaster_id: 123, to_broadcaster_id: 321\n```\n\n```ruby\n# Requires channel:manage:raids\n# broadcaster_id must be the authenticated user\n@client.raids.delete broadcaster_id: 123\n```\n\n### Chat Messages\n\n```ruby\n# Send a chat message to a broadcaster's chat room\n# Requires an app or user access token that includes user:write:chat then either user:bot or channel:bot\n# sender_id must be the currently authenticated user\n# reply_to is optional and is the UUID of the message to reply to\n@client.chat_messages.create broadcaster_id: 123, sender_id: 321, message: \"A test message\", reply_to: \"aabbcc\"\n\n# Removes a single chat message from the broadcaster's chat room\n# Requires moderator:manage:chat_messages\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.chat_messages.delete broadcaster_id: 123, moderator_id: 123, message_id: \"abc123-abc123\"\n```\n\n### Whispers\n\n```ruby\n# Send a Whisper\n# Required scope: user:manage:whispers\n# from_user_id must be the currently authenticated user's ID and have a verified phone number\n@client.whispers.create from_user_id: 123, to_user_id: 321, message: \"this is a test\"\n```\n\n### AutoMod\n\n```ruby\n# Check if a message meets the channel's AutoMod requirements\n# Required scope: moderation:read\n# id is a developer-generated identifier for mapping messages to results.\n@client.automod.check_status_multiple broadcaster_id: 123, id: \"abc123\", text: \"Is this message allowed?\"\n\n#\u003e #\u003cTwitch::AutomodStatus msg_id=\"abc123\", is_permitted=true\u003e\n```\n\n```ruby\n# Check if multiple messages meet the channel's AutoMod requirements\n# messages must be an array of hashes and must include msg_id and msg_text\n# Returns a collection\nmessages = [{msg_id: \"abc1\", msg_text: \"is this allowed?\"}, {msg_id: \"abc2\", msg_text: \"What about this?\"}]\n@client.automod.check_status_multiple broadcaster_id: 123, messages: messages\n```\n\n```ruby\n# Get AutoMod settings\n# Required scope: moderator:read:automod_settings\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.automod.settings broadcaster_id: 123, moderator_id: 321\n```\n\n```ruby\n# Update AutoMod settings\n# Required scope: moderator:manage:automod_settings\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n# As this is a PUT method, it overwrites all options so all fields you want set should be supplied\n@client.automod.update_settings broadcaster_id: 123, moderator_id: 321, swearing: 1\n```\n\n### Creator Goals\n\n```ruby\n# List all active creator goals\n# Required scope: channel:read:goals\n# broadcaster_id must match the currently authenticated user\n@client.goals.list broadcaster_id: 123\n```\n\n### Blocked Terms\n\n```ruby\n# List all blocked terms\n# Required scope: moderator:read:blocked_terms\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.blocked_terms.list broadcaster_id: 123, moderator_id: 321\n```\n\n```ruby\n# Create a blocked term\n# Required scope: moderator:manage:blocked_terms\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.blocked_terms.create broadcaster_id: 123, moderator_id: 321, text: \"term to block\"\n```\n\n```ruby\n# Delete a blocked term\n# Required scope: moderator:manage:blocked_terms\n# moderator_id can be either the currently authenticated moderator or the broadcaster\n@client.blocked_terms.delete broadcaster_id: 123, moderator_id: 321, id: \"abc12-12abc\"\n```\n\n### Charity Campaigns\n\n```ruby\n# Gets information about the charity campaign that a broadcaster is running\n# Required scope: channel:read:charity\n# broadcaster_id must match the currently authenticated user\n@client.charity_campaigns.list broadcaster_id: 123\n```\n\n### Chatters\n\n```ruby\n# Gets the list of users that are connected to the specified broadcaster’s chat session\n# Required scope: moderator:read:chatters\n# broadcaster_id must match the currently authenticated user\n@client.chatters.list broadcaster_id: 123, moderator_id: 123\n```\n\n### Channel Points Custom Rewards\n\n```ruby\n# Gets a list of custom rewards for a specific channel\n# Required scope: channel:read:redemptions\n# broadcaster_id must match the currently authenticated user\n@client.custom_rewards.list broadcaster_id: 123\n\n# Create a custom reward\n# Required scope: channel:manage:redemptions\n# broadcaster_id must match the currently authenticated user\n@client.custom_rewards.create broadcaster_id: 123, title: \"New Reward\", cost: 1000\n\n# Update a custom reward\n# Required scope: channel:manage:redemptions\n# broadcaster_id must match the currently authenticated user\n@client.custom_rewards.update broadcaster_id: 123, reward_id: 321, title: \"Updated Reward\"\n\n# Delete a custom reward\n# Required scope: channel:manage:redemptions\n# broadcaster_id must match the currently authenticated user\n@client.custom_rewards.delete broadcaster_id: 123, reward_id: 321\n```\n\n### Channel Points Custom Reward Redemptions\n\n```ruby\n# Gets a list of custom reward redemptions for a specific channel\n# Required scope: channel:read:redemptions\n# broadcaster_id must match the currently authenticated user\n@client.custom_reward_redemptions.list broadcaster_id: 123, reward_id: 321, status: \"UNFULFILLED\"\n\n# Update a custom reward redemption status\n# Required scope: channel:manage:redemptions\n# broadcaster_id must match the currently authenticated user\n# Status can be FULFILLED or CANCELED\n@client.custom_reward_redemptions.update broadcaster_id: 123, reward_id: 321, redemption_id: 123, status: \"FULFILLED\"\n```\n\n### Unban Requests\n\n```ruby\n# Retrieves a list of Unban Requests for a broadcaster\n# Required scope: moderator:read:unban_requests or moderator:manage:unban_requests\n# moderator_id must match the currently authenticated user\n@client.unban_requests.list broadcaster_id: 123, moderator_id: 123, status: \"pending\"\n\n# Resolve an Unban Request\n# Required scope: moderator:manage:unban_requests\n# moderator_id must match the currently authenticated user\n@client.unban_requests.resolve broadcaster_id: 123, moderator_id: 123, id: \"abc123\", status: \"approved\"\n```\n\n### Warnings\n\n```ruby\n# Sends a warning to a user\n# Required scope: moderator:manage:warnings\n# moderator_id must match the currently authenticated user\n@client.warnings.create broadcaster_id: 123, moderator_id: 123, user_id: 321, reason: \"dont do that\"\n```\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/twitchrb.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeanpcmad%2Ftwitchrb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeanpcmad%2Ftwitchrb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeanpcmad%2Ftwitchrb/lists"}