Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xquik.com/llms.txt

Use this file to discover all available pages before exploring further.

Use the Ruby SDK for Ruby 3.2+ applications that need typed REST access, retries, Yard docs, RBS, RBI, and connection pooling.

Install

gem install x-twitter-scraper
Or add it to your Gemfile:
gem "x-twitter-scraper", "~> 0.4.0"

Authenticate

export X_TWITTER_SCRAPER_API_KEY="xq_YOUR_KEY_HERE"

Basic Example

require "x_twitter_scraper"

client = XTwitterScraper::Client.new(
  api_key: ENV["X_TWITTER_SCRAPER_API_KEY"]
)

tweets = client.x.tweets.search(q: "from:elonmusk", limit: 10)
puts(tweets.has_next_page)

Error Handling

All SDK errors inherit from XTwitterScraper::Errors::APIError.
StatusError class
400BadRequestError
401AuthenticationError
403PermissionDeniedError
404NotFoundError
422UnprocessableEntityError
429RateLimitError
5xxInternalServerError
begin
  account = client.account.retrieve
rescue XTwitterScraper::Errors::APIConnectionError => e
  warn("Connection failed: #{e.cause}")
rescue XTwitterScraper::Errors::APIStatusError => e
  warn("HTTP #{e.status}")
end

Pagination

Paginated responses expose fields such as has_next_page. Pass the endpoint’s cursor fields when requesting more pages.
page = client.x.tweets.search(q: "xquik", limit: 20)
puts("More results are available") if page.has_next_page

Webhooks & References