Class: XTwitterScraper::Resources::X::Users

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/x/users.rb,
lib/x_twitter_scraper/resources/x/users/follow.rb,
sig/x_twitter_scraper/resources/x/users.rbs,
sig/x_twitter_scraper/resources/x/users/follow.rbs

Defined Under Namespace

Classes: Follow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

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 Users.

Parameters:



749
750
751
752
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 749

def initialize(client:)
  @client = client
  @follow = XTwitterScraper::Resources::X::Users::Follow.new(client: client)
end

Instance Attribute Details

#followXTwitterScraper::Resources::X::Users::Follow (readonly)

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



9
10
11
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 9

def follow
  @follow
end

Instance Method Details

#remove_follower(id, account:, request_options: {}) ⇒ XTwitterScraper::Models::X::UserRemoveFollowerResponse

Remove follower

Parameters:

  • id (String)

    User ID to remove from your followers

  • account (String)

    X account identifier (@username or account ID)

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

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 44

def remove_follower(id, params)
  parsed, options = XTwitterScraper::X::UserRemoveFollowerParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["x/users/%1$s/remove-follower", id],
    body: parsed,
    model: XTwitterScraper::Models::X::UserRemoveFollowerResponse,
    options: options
  )
end

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

Get user profile with follower counts and verification

Parameters:

Returns:

See Also:



22
23
24
25
26
27
28
29
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 22

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

#retrieve_batch(ids:, request_options: {}) ⇒ XTwitterScraper::Models::X::UserRetrieveBatchResponse

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

Look up multiple users by IDs in one call

Parameters:

  • ids (String)

    Comma-separated numeric user IDs (1-100 values). Duplicate IDs are ignored while

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

Returns:

See Also:



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

def retrieve_batch(params)
  parsed, options = XTwitterScraper::X::UserRetrieveBatchParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "x/users/batch",
    query: query,
    model: XTwitterScraper::Models::X::UserRetrieveBatchResponse,
    options: options
  )
end

#retrieve_followers(id, after: nil, cursor: nil, limit: nil, page_size: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

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

List followers of a user

Parameters:

  • id (String)

    User ID or username

  • after (String)

    Legacy cursor alias. Prefer cursor.

  • cursor (String)

    Pagination cursor for followers list

  • limit (Integer)

    Legacy integer page size alias for following lists. Prefer pageSize.

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). The respon

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

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 103

def retrieve_followers(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveFollowersParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/followers", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#retrieve_followers_you_know(id, cursor: nil, page_size: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

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

List mutual followers between you and a user

Parameters:

  • id (String)

    User ID for followers-you-know lookup

  • cursor (String)

    Pagination cursor for followers-you-know

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). The respon

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

Returns:

See Also:



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 134

def retrieve_followers_you_know(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveFollowersYouKnowParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/followers-you-know", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#retrieve_following(id, after: nil, cursor: nil, limit: nil, page_size: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

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

List accounts a user follows

Parameters:

  • id (String)

    User ID or username for following lookup

  • after (String)

    Legacy cursor alias. Prefer cursor.

  • cursor (String)

    Pagination cursor for following list

  • limit (Integer)

    Legacy page size alias. Prefer pageSize.

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). The respon

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

Returns:

See Also:



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 168

def retrieve_following(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveFollowingParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/following", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#retrieve_likes(id, any_words: 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, media_type: nil, mentioning: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: 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::UserRetrieveLikesParams for more details.

List tweets liked by a user

Parameters:

  • id (String)

    User ID or username

  • any_words (String)

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

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for liked 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.

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

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_faves (Integer)

    Minimum likes threshold.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • page_size (Integer)

    Maximum items requested from this page (1-100, default 20). The response can con

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

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

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

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::UserRetrieveLikesParams::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:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 248

def retrieve_likes(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveLikesParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/likes", id],
    query: query.transform_keys(
      any_words: "anyWords",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      in_reply_to_tweet_id: "inReplyToTweetId",
      media_type: "mediaType",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      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

#retrieve_media(id, any_words: 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, media_type: nil, mentioning: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: 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::UserRetrieveMediaParams for more details.

List media tweets posted by a user

Parameters:

  • id (String)

    User ID or username for media lookup

  • any_words (String)

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

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for media 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.

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

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_faves (Integer)

    Minimum likes threshold.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • page_size (Integer)

    Maximum items requested from this page (1-100, default 20). The response can con

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

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

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

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::UserRetrieveMediaParams::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:



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 347

def retrieve_media(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveMediaParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/media", id],
    query: query.transform_keys(
      any_words: "anyWords",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      in_reply_to_tweet_id: "inReplyToTweetId",
      media_type: "mediaType",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      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

#retrieve_mentions(id, any_words: 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, media_type: nil, mentioning: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: nil, page_size: nil, quotes: nil, quotes_of_tweet_id: nil, replies: nil, retweets: nil, retweets_of_tweet_id: nil, since_date: nil, since_time: nil, to_user: nil, until_date: nil, until_time: nil, url: nil, verified_only: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

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

List tweets mentioning a user

Parameters:

  • id (String)

    User ID or username for mentions lookup

  • any_words (String)

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

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for mentions

  • 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.

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

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_faves (Integer)

    Minimum likes threshold.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • page_size (Integer)

    Maximum items requested from this page (1-100, default 20). The response can con

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

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

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

    Reply mode.

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

    Retweet mode.

  • retweets_of_tweet_id (String)

    Only retweets of this tweet ID.

  • since_date (Date)

    Start date in YYYY-MM-DD format.

  • since_time (String)

    Unix timestamp - return mentions after this time

  • 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 mentions before this time

  • 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:



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 450

def retrieve_mentions(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveMentionsParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/mentions", id],
    query: query.transform_keys(
      any_words: "anyWords",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      in_reply_to_tweet_id: "inReplyToTweetId",
      media_type: "mediaType",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      page_size: "pageSize",
      quotes_of_tweet_id: "quotesOfTweetId",
      retweets_of_tweet_id: "retweetsOfTweetId",
      since_date: "sinceDate",
      since_time: "sinceTime",
      to_user: "toUser",
      until_date: "untilDate",
      until_time: "untilTime",
      verified_only: "verifiedOnly"
    ),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

#retrieve_replies(id, any_words: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_words: nil, from_user: nil, hashtags: nil, include_parent_tweet: nil, in_reply_to_tweet_id: nil, language: nil, media_type: nil, mentioning: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: 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::UserRetrieveRepliesParams for more details.

Returns the user's timeline with replies included by default.

Parameters:

  • id (String)

    X user ID or username

  • any_words (String)

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

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for user replies

  • 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.

  • include_parent_tweet (Boolean)

    Include parent tweet for replies

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

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

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

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_faves (Integer)

    Minimum likes threshold.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • page_size (Integer)

    Maximum items requested from this page (1-100, default 20). The response can con

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

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

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

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::UserRetrieveRepliesParams::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:



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 553

def retrieve_replies(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveRepliesParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/replies", id],
    query: query.transform_keys(
      any_words: "anyWords",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      include_parent_tweet: "includeParentTweet",
      in_reply_to_tweet_id: "inReplyToTweetId",
      media_type: "mediaType",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      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

#retrieve_search(q:, cursor: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

Search users by name or username

Parameters:

  • q (String)

    User search query

  • cursor (String)

    Pagination cursor for user search

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

Returns:

See Also:



598
599
600
601
602
603
604
605
606
607
608
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 598

def retrieve_search(params)
  parsed, options = XTwitterScraper::X::UserRetrieveSearchParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "x/users/search",
    query: query,
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#retrieve_tweets(id, any_words: nil, cashtags: nil, conversation_id: nil, cursor: nil, exact_phrase: nil, exclude_words: nil, from_user: nil, hashtags: nil, include_parent_tweet: nil, include_replies: nil, in_reply_to_tweet_id: nil, language: nil, media_type: nil, mentioning: nil, min_faves: nil, min_quotes: nil, min_replies: nil, min_retweets: 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::UserRetrieveTweetsParams for more details.

List recent tweets posted by a user

Parameters:

  • id (String)

    X user ID or username

  • any_words (String)

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

  • cashtags (String)

    Cashtags separated by spaces, commas, or lines.

  • conversation_id (String)

    Conversation ID filter.

  • cursor (String)

    Pagination cursor for user 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.

  • include_parent_tweet (Boolean)

    Include parent tweet for replies

  • include_replies (Boolean)

    Include reply tweets

  • in_reply_to_tweet_id (String)

    Only replies to this tweet ID.

  • language (String)

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

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

    Filter by media type.

  • mentioning (String)

    Filter tweets mentioning a username.

  • min_faves (Integer)

    Minimum likes threshold.

  • min_quotes (Integer)

    Minimum quote count threshold.

  • min_replies (Integer)

    Minimum replies threshold.

  • min_retweets (Integer)

    Minimum retweets threshold.

  • page_size (Integer)

    Maximum items requested from this page (1-100, default 20). The response can con

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

    Quote mode.

  • quotes_of_tweet_id (String)

    Only quotes of this tweet ID.

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

    Reply mode.

  • retweets (Symbol, XTwitterScraper::Models::X::UserRetrieveTweetsParams::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:



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 682

def retrieve_tweets(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveTweetsParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/tweets", id],
    query: query.transform_keys(
      any_words: "anyWords",
      conversation_id: "conversationId",
      exact_phrase: "exactPhrase",
      exclude_words: "excludeWords",
      from_user: "fromUser",
      include_parent_tweet: "includeParentTweet",
      include_replies: "includeReplies",
      in_reply_to_tweet_id: "inReplyToTweetId",
      media_type: "mediaType",
      min_faves: "minFaves",
      min_quotes: "minQuotes",
      min_replies: "minReplies",
      min_retweets: "minRetweets",
      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

#retrieve_verified_followers(id, cursor: nil, page_size: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers

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

List verified followers of a user

Parameters:

  • id (String)

    User ID or username for verified followers

  • cursor (String)

    Pagination cursor for verified followers

  • page_size (Integer)

    Maximum user profiles requested from this page (20-200, default 200). The respon

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

Returns:

See Also:



734
735
736
737
738
739
740
741
742
743
744
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 734

def retrieve_verified_followers(id, params = {})
  parsed, options = XTwitterScraper::X::UserRetrieveVerifiedFollowersParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/users/%1$s/verified-followers", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end