Class: XTwitterScraper::Resources::X::Users
- Inherits:
-
Object
- Object
- XTwitterScraper::Resources::X::Users
- 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
-
#follow ⇒ XTwitterScraper::Resources::X::Users::Follow
readonly
X write actions (tweets, likes, follows, DMs).
Instance Method Summary collapse
-
#initialize(client:) ⇒ Users
constructor
private
A new instance of Users.
-
#remove_follower(id, account:, idempotency_key:, request_options: {}) ⇒ XTwitterScraper::Models::X::UserRemoveFollowerResponse
Some parameter documentations has been truncated, see Models::X::UserRemoveFollowerParams for more details.
-
#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::UserProfile
Get user profile with follower counts & verification.
-
#retrieve_batch(ids:, request_options: {}) ⇒ XTwitterScraper::Models::X::UserRetrieveBatchResponse
Some parameter documentations has been truncated, see Models::X::UserRetrieveBatchParams for more details.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#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.
-
#retrieve_search(q:, cursor: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers
Search users by name or username.
-
#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.
-
#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.
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.
760 761 762 763 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 760 def initialize(client:) @client = client @follow = XTwitterScraper::Resources::X::Users::Follow.new(client: client) end |
Instance Attribute Details
#follow ⇒ XTwitterScraper::Resources::X::Users::Follow (readonly)
X write actions (tweets, likes, follows, DMs)
13 14 15 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 13 def follow @follow end |
Instance Method Details
#remove_follower(id, account:, idempotency_key:, request_options: {}) ⇒ XTwitterScraper::Models::X::UserRemoveFollowerResponse
Some parameter documentations has been truncated, see Models::X::UserRemoveFollowerParams for more details.
Remove follower
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 53 def remove_follower(id, params) parsed, = XTwitterScraper::X::UserRemoveFollowerParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :post, path: ["x/users/%1$s/remove-follower", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: XTwitterScraper::Models::X::UserRemoveFollowerResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::UserProfile
Get user profile with follower counts & verification
26 27 28 29 30 31 32 33 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 26 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
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 80 def retrieve_batch(params) parsed, = 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: ) 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
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 114 def retrieve_followers(id, params = {}) parsed, = 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: ) 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
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 145 def retrieve_followers_you_know(id, params = {}) parsed, = 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: ) 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
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 179 def retrieve_following(id, params = {}) parsed, = 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: ) 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
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 259 def retrieve_likes(id, params = {}) parsed, = 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: ) 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
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 358 def retrieve_media(id, params = {}) parsed, = 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: ) 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
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 461 def retrieve_mentions(id, params = {}) parsed, = 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: ) 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.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 564 def retrieve_replies(id, params = {}) parsed, = 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: ) end |
#retrieve_search(q:, cursor: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedUsers
Search users by name or username
609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 609 def retrieve_search(params) parsed, = 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: ) 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
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 693 def retrieve_tweets(id, params = {}) parsed, = 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: ) 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
745 746 747 748 749 750 751 752 753 754 755 |
# File 'lib/x_twitter_scraper/resources/x/users.rb', line 745 def retrieve_verified_followers(id, params = {}) parsed, = 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: ) end |