Class: XTwitterScraper::Resources::X::Tweets

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/x/tweets.rb,
lib/x_twitter_scraper/resources/x/tweets/like.rb,
lib/x_twitter_scraper/resources/x/tweets/retweet.rb,
sig/x_twitter_scraper/resources/x/tweets.rbs,
sig/x_twitter_scraper/resources/x/tweets/like.rbs,
sig/x_twitter_scraper/resources/x/tweets/retweet.rbs

Defined Under Namespace

Classes: Like, Retweet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tweets

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tweets.

Parameters:



921
922
923
924
925
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 921

def initialize(client:)
  @client = client
  @like = XTwitterScraper::Resources::X::Tweets::Like.new(client: client)
  @retweet = XTwitterScraper::Resources::X::Tweets::Retweet.new(client: client)
end

Instance Attribute Details

#likeXTwitterScraper::Resources::X::Tweets::Like (readonly)

X write actions (tweets, likes, follows, DMs)



13
14
15
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 13

def like
  @like
end

#retweetXTwitterScraper::Resources::X::Tweets::Retweet (readonly)

X write actions (tweets, likes, follows, DMs)



17
18
19
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 17

def retweet
  @retweet
end

Instance Method Details

#create(account:, idempotency_key:, community_id: nil, is_note_tweet: nil, media: nil, reply_to_tweet_id: nil, text: nil, request_options: {}) ⇒ XTwitterScraper::Models::X::TweetCreateResponse

Some parameter documentations has been truncated, see Models::X::TweetCreateParams for more details.

Create tweet

Parameters:

  • account (String)

    Body param: X account (@username or account ID)

  • idempotency_key (String)

    Header param: Generate one unique value for each intended write. Reuse it only w

  • community_id (String)

    Body param

  • is_note_tweet (Boolean)

    Body param

  • media (Array<String>)

    Body param: Array of public media URLs to attach. Supports up to 4 images or exa

  • reply_to_tweet_id (String)

    Body param

  • text (String)

    Body param: Tweet text (optional when media is provided)

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 45

def create(params)
  parsed, options = XTwitterScraper::X::TweetCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "x/tweets",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::X::TweetCreateResponse,
    options: options
  )
end

#delete(id, account:, idempotency_key:, request_options: {}) ⇒ XTwitterScraper::Models::X::TweetDeleteResponse

Some parameter documentations has been truncated, see Models::X::TweetDeleteParams for more details.

Delete tweet

Parameters:

  • id (String)

    Path param: Tweet ID to delete

  • account (String)

    Body param: X account identifier (@username or account ID)

  • idempotency_key (String)

    Header param: Generate one unique value for each intended write. Reuse it only w

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 119

def delete(id, params)
  parsed, options = XTwitterScraper::X::TweetDeleteParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :delete,
    path: ["x/tweets/%1$s", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::X::TweetDeleteResponse,
    options: options
  )
end

#get_favoriters(id, bio_contains: nil, cursor: nil, has_location: nil, has_website: nil, location_contains: nil, max_followers: nil, max_following: nil, max_statuses: nil, min_account_age_days: nil, min_followers: nil, min_following: nil, min_statuses: nil, page_size: nil, username_contains: nil, verified_only: nil, verified_type: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

Some parameter documentations has been truncated, see Models::X::TweetGetFavoritersParams for more details.

Returns liker profiles that X makes visible for the post. X can withhold liker identities even when the post reports likes. In that case this endpoint returns 424 favoriters_unavailable instead of a misleading empty success.

Parameters:

  • id (String)

    Tweet ID to get favoriters

  • bio_contains (String)

    Match any comma-separated or line-separated bio term, ignoring case.

  • cursor (String)

    Pagination cursor for favoriters

  • has_location (Boolean)

    Only return profiles with a location.

  • has_website (Boolean)

    Only return profiles with a website.

  • location_contains (String)

    Match a location substring, ignoring case.

  • max_followers (Integer)

    Maximum follower count. Missing counts pass this maximum.

  • max_following (Integer)

    Maximum following count.

  • max_statuses (Integer)

    Maximum post count. maxPosts is also accepted.

  • min_account_age_days (Integer)

    Minimum account age in whole days.

  • min_followers (Integer)

    Minimum follower count. Filtering happens before billing.

  • min_following (Integer)

    Minimum following count.

  • min_statuses (Integer)

    Minimum post count. minPosts is also accepted.

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). Source, fi

  • username_contains (String)

    Match a username substring, ignoring case.

  • verified_only (Boolean)

    Only return verified profiles.

  • verified_type (String)

    Match the verification type exactly, ignoring case.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 180

def get_favoriters(id, params = {})
  parsed, options = XTwitterScraper::X::TweetGetFavoritersParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s/favoriters", id],
    query: query.transform_keys(
      bio_contains: "bioContains",
      has_location: "hasLocation",
      has_website: "hasWebsite",
      location_contains: "locationContains",
      max_followers: "maxFollowers",
      max_following: "maxFollowing",
      max_statuses: "maxStatuses",
      min_account_age_days: "minAccountAgeDays",
      min_followers: "minFollowers",
      min_following: "minFollowing",
      min_statuses: "minStatuses",
      page_size: "pageSize",
      username_contains: "usernameContains",
      verified_only: "verifiedOnly",
      verified_type: "verifiedType"
    ),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#get_quotes(id, any_words: nil, blue_verified_only: nil, card_name: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_source: nil, exclude_words: nil, from_user: nil, geocode: nil, hashtags: nil, include_replies: nil, in_reply_to_tweet_id: nil, language: nil, max_faves: nil, max_id: nil, max_quotes: nil, max_replies: nil, max_retweets: nil, media_type: nil, mentioning: nil, min_bookmarks: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: nil, min_views: nil, native_retweets: nil, near: nil, news: nil, page_size: nil, quotes: nil, quotes_of_tweet_id: nil, replies: nil, retweets: nil, retweets_of_tweet_id: nil, safe: nil, since_date: nil, since_id: nil, since_time: nil, source: nil, to_user: nil, until_date: nil, until_time: nil, url: nil, verified_only: nil, within: nil, within_time: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

Some parameter documentations has been truncated, see Models::X::TweetGetQuotesParams for more details.

List quote tweets of a tweet

Parameters:

  • id (String)

    Numeric tweet ID to get quotes, 15-20 digits

  • any_words (String)

    Words or quoted phrases where any one can match. Separate with spaces, commas, o

  • blue_verified_only (Boolean)

    Only return tweets from Blue-verified authors.

  • card_name (String)

    Match the Tweet card name.

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for quote tweets

  • exact_phrase (String)

    Exact phrase to match.

  • exclude_source (String)

    Exclude a source application.

  • exclude_words (String)

    Words or quoted phrases to exclude. Separate with spaces, commas, or lines.

  • from_user (String)

    Filter by author username.

  • geocode (String)

    Match latitude, longitude, and radius.

  • hashtags (String)

    Hashtags separated by spaces, commas, or lines.

  • include_replies (Boolean)

    Include reply quotes (default false)

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

    Language code filter, e.g. en or tr.

  • max_faves (Integer)

    Maximum likes threshold. maxLikes is also accepted.

  • max_id (String)

    Return Tweets older than this Tweet ID.

  • max_quotes (Integer)

    Maximum quotes threshold.

  • max_replies (Integer)

    Maximum replies threshold.

  • max_retweets (Integer)

    Maximum retweets threshold.

  • media_type (Symbol, XTwitterScraper::Models::X::TweetGetQuotesParams::MediaType)

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_bookmarks (Integer)

    Minimum bookmark count threshold.

  • min_faves (Integer)

    Minimum likes threshold. minLikes is also accepted.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • min_views (Integer)

    Minimum view count threshold.

  • native_retweets (Boolean)

    Only return native reposts.

  • near (String)

    Match a place name.

  • news (Boolean)

    Only return news results.

  • page_size (Integer)

    Maximum page items (1-100, default 20). Source, filters, or credits can reduce r

  • quotes (Symbol, XTwitterScraper::Models::X::TweetGetQuotesParams::Quotes)

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

  • replies (Symbol, XTwitterScraper::Models::X::TweetGetQuotesParams::Replies)

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::TweetGetQuotesParams::Retweets)

    Retweet mode.

  • retweets_of_tweet_id (String)

    Only retweets of this tweet ID.

  • safe (Boolean)

    Enable the safe-search filter.

  • since_date (Date)

    Start date in YYYY-MM-DD format.

  • since_id (String)

    Return Tweets newer than this Tweet ID.

  • since_time (String)

    Unix timestamp - return quotes posted after this time

  • source (String)

    Match the source application.

  • to_user (String)

    Filter replies sent to a username.

  • until_date (Date)

    End date in YYYY-MM-DD format.

  • until_time (String)

    Unix timestamp - return quotes posted before this time

  • url (String)

    URL substring or domain filter.

  • verified_only (Boolean)

    Only return tweets from verified authors.

  • within (String)

    Set the radius for the near filter.

  • within_time (String)

    Match Tweets inside a recent time window.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 320

def get_quotes(id, params = {})
  parsed, options = XTwitterScraper::X::TweetGetQuotesParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s/quotes", id],
    query: query.transform_keys(
      any_words: "anyWords",
      blue_verified_only: "blueVerifiedOnly",
      card_name: "cardName",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_source: "excludeSource",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      include_replies: "includeReplies",
      in_reply_to_tweet_id: "inReplyToTweetId",
      max_faves: "maxFaves",
      max_id: "maxId",
      max_quotes: "maxQuotes",
      max_replies: "maxReplies",
      max_retweets: "maxRetweets",
      media_type: "mediaType",
      min_bookmarks: "minBookmarks",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      min_views: "minViews",
      native_retweets: "nativeRetweets",
      page_size: "pageSize",
      quotes_of_tweet_id: "quotesOfTweetId",
      retweets_of_tweet_id: "retweetsOfTweetId",
      since_date: "sinceDate",
      since_id: "sinceId",
      since_time: "sinceTime",
      to_user: "toUser",
      until_date: "untilDate",
      until_time: "untilTime",
      verified_only: "verifiedOnly",
      within_time: "withinTime"
    ),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

#get_replies(id, any_words: nil, blue_verified_only: nil, card_name: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_original_author: nil, exclude_source: nil, exclude_words: nil, from_user: nil, geocode: nil, hashtags: nil, has_media_only: nil, include_original_post: nil, in_reply_to_tweet_id: nil, language: nil, limit: nil, max_depth: nil, max_faves: nil, max_id: nil, max_quotes: nil, max_replies: nil, max_retweets: nil, media_type: nil, mentioning: nil, min_bookmarks: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: nil, min_views: nil, mode: nil, native_retweets: nil, near: nil, news: nil, page_size: nil, quotes: nil, quotes_of_tweet_id: nil, replies: nil, retweets: nil, retweets_of_tweet_id: nil, safe: nil, scope: nil, since_date: nil, since_id: nil, since_time: nil, sort: nil, source: nil, to_user: nil, until_date: nil, until_time: nil, url: nil, verified_only: nil, within: nil, within_time: nil, request_options: {}) ⇒ XTwitterScraper::Models::X::TweetGetRepliesResponse

Some parameter documentations has been truncated, see Models::X::TweetGetRepliesParams for more details.

Returns direct replies. Omit mode for automatic maximum coverage with resumable pagination. Complete mode returns nested replies, diagnostics, and 424 when direct coverage stays below 80%.

Parameters:

  • id (String)

    Tweet ID to get replies

  • any_words (String)

    Words or quoted phrases where any one can match. Separate with spaces, commas, o

  • blue_verified_only (Boolean)

    Only return tweets from Blue-verified authors.

  • card_name (String)

    Match the Tweet card name.

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Cursor from the previous response. Xquik cursors resume automatic coverage. Exis

  • exact_phrase (String)

    Exact phrase to match.

  • exclude_original_author (Boolean)

    Exclude replies written by the source-post author.

  • exclude_source (String)

    Exclude a source application.

  • exclude_words (String)

    Words or quoted phrases to exclude. Separate with spaces, commas, or lines.

  • from_user (String)

    Filter by author username.

  • geocode (String)

    Match latitude, longitude, and radius.

  • hashtags (String)

    Hashtags separated by spaces, commas, or lines.

  • has_media_only (Boolean)

    Only return replies containing media.

  • include_original_post (Boolean)

    Include the source post and count it toward limit.

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

    Language code filter, e.g. en or tr.

  • limit (Integer)

    With mode=complete, maximum combined direct and nested reply rows (1-25000, defa

  • max_depth (Integer)

    Maximum reply depth from the source post.

  • max_faves (Integer)

    Maximum likes threshold. maxLikes is also accepted.

  • max_id (String)

    Return Tweets older than this Tweet ID.

  • max_quotes (Integer)

    Maximum quotes threshold.

  • max_replies (Integer)

    Maximum replies threshold.

  • max_retweets (Integer)

    Maximum retweets threshold.

  • media_type (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::MediaType)

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_bookmarks (Integer)

    Minimum bookmark count threshold.

  • min_faves (Integer)

    Minimum likes threshold. minLikes is also accepted.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • min_views (Integer)

    Minimum view count threshold.

  • mode (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Mode)

    Optional advanced override. Omit mode for automatic maximum direct reply coverag

  • native_retweets (Boolean)

    Only return native reposts.

  • near (String)

    Match a place name.

  • news (Boolean)

    Only return news results.

  • page_size (Integer)

    Automatic pages accept 1-300 Tweets. Standard pages keep 1-100. Default 20. Cont

  • quotes (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Quotes)

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

  • replies (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Replies)

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Retweets)

    Retweet mode.

  • retweets_of_tweet_id (String)

    Only retweets of this tweet ID.

  • safe (Boolean)

    Enable the safe-search filter.

  • scope (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Scope)

    Select all replies, direct replies, or nested replies.

  • since_date (Date)

    Start date in YYYY-MM-DD format.

  • since_id (String)

    Return Tweets newer than this Tweet ID.

  • since_time (String)

    Unix timestamp - return replies posted after this time

  • sort (Symbol, XTwitterScraper::Models::X::TweetGetRepliesParams::Sort)

    Sort the selected replies before applying limit.

  • source (String)

    Match the source application.

  • to_user (String)

    Filter replies sent to a username.

  • until_date (Date)

    End date in YYYY-MM-DD format.

  • until_time (String)

    Unix timestamp - return replies posted before this time

  • url (String)

    URL substring or domain filter.

  • verified_only (Boolean)

    Only return tweets from verified authors.

  • within (String)

    Set the radius for the near filter.

  • within_time (String)

    Match Tweets inside a recent time window.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 495

def get_replies(id, params = {})
  parsed, options = XTwitterScraper::X::TweetGetRepliesParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s/replies", id],
    query: query.transform_keys(
      any_words: "anyWords",
      blue_verified_only: "blueVerifiedOnly",
      card_name: "cardName",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_original_author: "excludeOriginalAuthor",
      exclude_source: "excludeSource",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      has_media_only: "hasMediaOnly",
      include_original_post: "includeOriginalPost",
      in_reply_to_tweet_id: "inReplyToTweetId",
      max_depth: "maxDepth",
      max_faves: "maxFaves",
      max_id: "maxId",
      max_quotes: "maxQuotes",
      max_replies: "maxReplies",
      max_retweets: "maxRetweets",
      media_type: "mediaType",
      min_bookmarks: "minBookmarks",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      min_views: "minViews",
      native_retweets: "nativeRetweets",
      page_size: "pageSize",
      quotes_of_tweet_id: "quotesOfTweetId",
      retweets_of_tweet_id: "retweetsOfTweetId",
      since_date: "sinceDate",
      since_id: "sinceId",
      since_time: "sinceTime",
      to_user: "toUser",
      until_date: "untilDate",
      until_time: "untilTime",
      verified_only: "verifiedOnly",
      within_time: "withinTime"
    ),
    model: XTwitterScraper::Models::X::TweetGetRepliesResponse,
    options: options
  )
end

#get_retweeters(id, bio_contains: nil, cursor: nil, has_location: nil, has_website: nil, location_contains: nil, max_followers: nil, max_following: nil, max_statuses: nil, min_account_age_days: nil, min_followers: nil, min_following: nil, min_statuses: nil, page_size: nil, username_contains: nil, verified_only: nil, verified_type: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

Some parameter documentations has been truncated, see Models::X::TweetGetRetweetersParams for more details.

List users who retweeted a tweet

Parameters:

  • id (String)

    Tweet ID to get retweeters

  • bio_contains (String)

    Match any comma-separated or line-separated bio term, ignoring case.

  • cursor (String)

    Pagination cursor for retweeters

  • has_location (Boolean)

    Only return profiles with a location.

  • has_website (Boolean)

    Only return profiles with a website.

  • location_contains (String)

    Match a location substring, ignoring case.

  • max_followers (Integer)

    Maximum follower count. Missing counts pass this maximum.

  • max_following (Integer)

    Maximum following count.

  • max_statuses (Integer)

    Maximum post count. maxPosts is also accepted.

  • min_account_age_days (Integer)

    Minimum account age in whole days.

  • min_followers (Integer)

    Minimum follower count. Filtering happens before billing.

  • min_following (Integer)

    Minimum following count.

  • min_statuses (Integer)

    Minimum post count. minPosts is also accepted.

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). Source, fi

  • username_contains (String)

    Match a username substring, ignoring case.

  • verified_only (Boolean)

    Only return verified profiles.

  • verified_type (String)

    Match the verification type exactly, ignoring case.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 591

def get_retweeters(id, params = {})
  parsed, options = XTwitterScraper::X::TweetGetRetweetersParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s/retweeters", id],
    query: query.transform_keys(
      bio_contains: "bioContains",
      has_location: "hasLocation",
      has_website: "hasWebsite",
      location_contains: "locationContains",
      max_followers: "maxFollowers",
      max_following: "maxFollowing",
      max_statuses: "maxStatuses",
      min_account_age_days: "minAccountAgeDays",
      min_followers: "minFollowers",
      min_following: "minFollowing",
      min_statuses: "minStatuses",
      page_size: "pageSize",
      username_contains: "usernameContains",
      verified_only: "verifiedOnly",
      verified_type: "verifiedType"
    ),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#get_thread(id, any_words: nil, blue_verified_only: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_words: nil, from_user: nil, hashtags: nil, in_reply_to_tweet_id: nil, language: nil, max_faves: nil, max_quotes: nil, max_replies: nil, max_retweets: nil, media_type: nil, mentioning: nil, min_bookmarks: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: nil, min_views: nil, page_size: nil, quotes: nil, quotes_of_tweet_id: nil, replies: nil, retweets: nil, retweets_of_tweet_id: nil, since_date: nil, to_user: nil, until_date: nil, url: nil, verified_only: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

Some parameter documentations has been truncated, see Models::X::TweetGetThreadParams for more details.

Get full conversation thread for a tweet

Parameters:

  • id (String)

    Tweet ID to get thread context

  • any_words (String)

    Words or quoted phrases where any one can match. Separate with spaces, commas, o

  • blue_verified_only (Boolean)

    Only return tweets from Blue-verified authors.

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for thread tweets

  • exact_phrase (String)

    Exact phrase to match.

  • exclude_words (String)

    Words or quoted phrases to exclude. Separate with spaces, commas, or lines.

  • from_user (String)

    Filter by author username.

  • hashtags (String)

    Hashtags separated by spaces, commas, or lines.

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

    Language code filter, e.g. en or tr.

  • max_faves (Integer)

    Maximum likes threshold. maxLikes is also accepted.

  • max_quotes (Integer)

    Maximum quotes threshold.

  • max_replies (Integer)

    Maximum replies threshold.

  • max_retweets (Integer)

    Maximum retweets threshold.

  • media_type (Symbol, XTwitterScraper::Models::X::TweetGetThreadParams::MediaType)

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_bookmarks (Integer)

    Minimum bookmark count threshold.

  • min_faves (Integer)

    Minimum likes threshold. minLikes is also accepted.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • min_views (Integer)

    Minimum view count threshold.

  • page_size (Integer)

    Maximum page items (1-100, default 20). Source, filters, or credits can reduce r

  • quotes (Symbol, XTwitterScraper::Models::X::TweetGetThreadParams::Quotes)

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

  • replies (Symbol, XTwitterScraper::Models::X::TweetGetThreadParams::Replies)

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::TweetGetThreadParams::Retweets)

    Retweet mode.

  • retweets_of_tweet_id (String)

    Only retweets of this tweet ID.

  • since_date (Date)

    Start date in YYYY-MM-DD format.

  • to_user (String)

    Filter replies sent to a username.

  • until_date (Date)

    End date in YYYY-MM-DD format.

  • url (String)

    URL substring or domain filter.

  • verified_only (Boolean)

    Only return tweets from verified authors.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 701

def get_thread(id, params = {})
  parsed, options = XTwitterScraper::X::TweetGetThreadParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s/thread", id],
    query: query.transform_keys(
      any_words: "anyWords",
      blue_verified_only: "blueVerifiedOnly",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      in_reply_to_tweet_id: "inReplyToTweetId",
      max_faves: "maxFaves",
      max_quotes: "maxQuotes",
      max_replies: "maxReplies",
      max_retweets: "maxRetweets",
      media_type: "mediaType",
      min_bookmarks: "minBookmarks",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      min_views: "minViews",
      page_size: "pageSize",
      quotes_of_tweet_id: "quotesOfTweetId",
      retweets_of_tweet_id: "retweetsOfTweetId",
      since_date: "sinceDate",
      to_user: "toUser",
      until_date: "untilDate",
      verified_only: "verifiedOnly"
    ),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

#list(ids:, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

Get multiple tweets by IDs

Parameters:

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 89

def list(params)
  parsed, options = XTwitterScraper::X::TweetListParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "x/tweets",
    query: query,
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::X::TweetRetrieveResponse

Get tweet with full text, author, metrics & media

Parameters:

Returns:

See Also:



69
70
71
72
73
74
75
76
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 69

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["x/tweets/%1$s", id],
    model: XTwitterScraper::Models::X::TweetRetrieveResponse,
    options: params[:request_options]
  )
end

#search(q:, advanced_query: nil, any_words: nil, blue_verified_only: nil, bounding_box: nil, card_name: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_source: nil, exclude_words: nil, from_user: nil, geocode: nil, hashtags: nil, in_reply_to_tweet_id: nil, language: nil, limit: nil, list_id: nil, max_faves: nil, max_id: nil, max_quotes: nil, max_replies: nil, max_retweets: nil, media_type: nil, mentioning: nil, min_bookmarks: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: nil, min_views: nil, mode: nil, native_retweets: nil, near: nil, news: nil, place: nil, place_country: nil, point_radius: nil, query_type: nil, quotes: nil, quotes_of_tweet_id: nil, replies: nil, retweets: nil, retweets_of_tweet_id: nil, safe: nil, since_date: nil, since_id: nil, since_time: nil, source: nil, to_user: nil, until_date: nil, until_time: nil, url: nil, verified_only: nil, within: nil, within_time: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets, XTwitterScraper::Models::X::TweetSearchResponse::TweetSearchCoverageResponse

Some parameter documentations has been truncated, see Models::X::TweetSearchParams for more details.

No-mode search maximizes coverage. New cursorless Latest sessions return rows newest-first across cursor pages. Existing cursors preserve their established ordering.

Parameters:

  • q (String)

    Query, Tweet ID, or status URL. Valid inline bounds apply per page.

  • advanced_query (String)

    Raw advanced search query appended as-is.

  • any_words (String)

    Words or quoted phrases where any one can match. Separate with spaces, commas, o

  • blue_verified_only (Boolean)

    Only return tweets from Blue-verified authors.

  • bounding_box (String)

    Geo bounding box, e.g. -74.1 40.6 -73.9 40.8.

  • card_name (String)

    Match the Tweet card name.

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Cursor from the previous response. Xquik cursors resume automatic coverage. Exis

  • exact_phrase (String)

    Exact phrase to match.

  • exclude_source (String)

    Exclude a source application.

  • exclude_words (String)

    Words or quoted phrases to exclude. Separate with spaces, commas, or lines.

  • from_user (String)

    Filter by author username.

  • geocode (String)

    Match latitude, longitude, and radius.

  • hashtags (String)

    Hashtags separated by spaces, commas, or lines.

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

    Language code filter, e.g. en or tr.

  • limit (Integer)

    Result upper bound. Omit it for the existing 20-row page size. Explicit coverage

  • list_id (String)

    Search within a list ID.

  • max_faves (Integer)

    Maximum likes threshold. maxLikes is also accepted.

  • max_id (String)

    Return Tweets older than this Tweet ID.

  • max_quotes (Integer)

    Maximum quotes threshold.

  • max_replies (Integer)

    Maximum replies threshold.

  • max_retweets (Integer)

    Maximum retweets threshold.

  • media_type (Symbol, XTwitterScraper::Models::X::TweetSearchParams::MediaType)

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_bookmarks (Integer)

    Minimum bookmark count threshold.

  • min_faves (Integer)

    Minimum likes threshold. minLikes is also accepted.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • min_views (Integer)

    Minimum view count threshold.

  • mode (Symbol, XTwitterScraper::Models::X::TweetSearchParams::Mode)

    Omit mode for resumable maximum coverage. Standard keeps legacy pagination. Cove

  • native_retweets (Boolean)

    Only return native reposts.

  • near (String)

    Match a place name.

  • news (Boolean)

    Only return news results.

  • place (String)

    Search within a place ID.

  • place_country (String)

    Search within a country code.

  • point_radius (String)

    Geo point radius, e.g. -73.99 40.73 25mi.

  • query_type (Symbol, XTwitterScraper::Models::X::TweetSearchParams::QueryType)

    Sort order - Latest (chronological) or Top (engagement-ranked)

  • quotes (Symbol, XTwitterScraper::Models::X::TweetSearchParams::Quotes)

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

  • replies (Symbol, XTwitterScraper::Models::X::TweetSearchParams::Replies)

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::TweetSearchParams::Retweets)

    Retweet mode.

  • retweets_of_tweet_id (String)

    Only retweets of this tweet ID.

  • safe (Boolean)

    Enable the safe-search filter.

  • since_date (Date)

    Start date in YYYY-MM-DD format.

  • since_id (String)

    Return Tweets newer than this Tweet ID.

  • since_time (String)

    Inclusive ISO bound.

  • source (String)

    Match the source application.

  • to_user (String)

    Filter replies sent to a username.

  • until_date (Date)

    End date in YYYY-MM-DD format.

  • until_time (String)

    Exclusive ISO bound.

  • url (String)

    URL substring or domain filter.

  • verified_only (Boolean)

    Only return tweets from verified authors.

  • within (String)

    Set the radius for the near filter.

  • within_time (String)

    Match Tweets inside a recent time window.

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'lib/x_twitter_scraper/resources/x/tweets.rb', line 867

def search(params)
  parsed, options = XTwitterScraper::X::TweetSearchParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "x/tweets/search",
    query: query.transform_keys(
      advanced_query: "advancedQuery",
      any_words: "anyWords",
      blue_verified_only: "blueVerifiedOnly",
      bounding_box: "boundingBox",
      card_name: "cardName",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_source: "excludeSource",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      in_reply_to_tweet_id: "inReplyToTweetId",
      list_id: "listId",
      max_faves: "maxFaves",
      max_id: "maxId",
      max_quotes: "maxQuotes",
      max_replies: "maxReplies",
      max_retweets: "maxRetweets",
      media_type: "mediaType",
      min_bookmarks: "minBookmarks",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      min_views: "minViews",
      native_retweets: "nativeRetweets",
      place_country: "placeCountry",
      point_radius: "pointRadius",
      query_type: "queryType",
      quotes_of_tweet_id: "quotesOfTweetId",
      retweets_of_tweet_id: "retweetsOfTweetId",
      since_date: "sinceDate",
      since_id: "sinceId",
      since_time: "sinceTime",
      to_user: "toUser",
      until_date: "untilDate",
      until_time: "untilTime",
      verified_only: "verifiedOnly",
      within_time: "withinTime"
    ),
    model: XTwitterScraper::Models::X::TweetSearchResponse,
    options: options
  )
end