explaingit

sferik/twitter-ruby

4,576RubyAudience · developerComplexity · 2/5Setup · moderate

TLDR

A Ruby library for controlling a Twitter/X account from code, post tweets, read timelines, search posts, and receive live tweet streams, without writing raw HTTP requests.

Mindmap

mindmap
  root((twitter-ruby))
    What it does
      Post and read tweets
      Follow users
      Live tweet streaming
    Auth
      OAuth credentials
      X developer portal
    Features
      REST API calls
      Streaming clients
      Search and filters
    Notes
      Targets API v1.1
      Legacy projects
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automate posting tweets or following users from a Ruby script.

USE CASE 2

Build a bot that monitors Twitter for keywords and responds automatically.

USE CASE 3

Stream live tweets matching a topic in real time into your application.

Tech stack

Ruby

Getting it running

Difficulty · moderate Time to first run · 30min

Requires registering an app on the X developer portal to get OAuth credentials before making any API calls.

License details not mentioned in the explanation.

In plain English

The Twitter Ruby Gem is a library that lets Ruby programs talk to the Twitter (now X) API. Instead of writing raw HTTP requests, developers call simple methods like client.update, client.follow, or client.search, and the gem handles the communication with Twitter's servers in the background. The result is that actions you would normally do in a browser, like posting a tweet, following a user, or reading a timeline, can be automated from a Ruby program. Using the library requires OAuth credentials, which you get by registering an application in the X developer portal. Once you have a consumer key, consumer secret, access token, and access token secret, you pass them to the client when setting it up. Every request you make after that is authenticated automatically. The gem covers the standard REST actions: posting tweets, fetching a user's profile or follower list, reading home and mentions timelines, looking up individual tweets by ID, and searching recent posts with filters like language or keyword exclusions. It also includes streaming clients that can receive a live feed of tweets matching certain topics, or all activity from the authenticated user's account, as it happens. The README notes that this gem targets the older API v1.1. For new projects that need the newer API v2 features, the author suggests using a separate gem called X instead. The Twitter Ruby Gem is still maintained for projects already using the v1.1 interface.

Copy-paste prompts

Prompt 1
Using the twitter Ruby gem, write a script that posts a tweet with today's date and the text 'Good morning!' using my OAuth credentials.
Prompt 2
Show me how to set up the twitter Ruby gem client with my consumer key and access token, then fetch my home timeline and print each tweet's text.
Prompt 3
Write a Ruby script using the twitter gem's streaming client to print every tweet that mentions a specific keyword as it happens.
Prompt 4
How do I search for recent tweets in a specific language using the twitter Ruby gem and filter out retweets?
Open on GitHub → Explain another repo

← sferik on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.