Class: XTwitterScraper::Resources::X::Lists

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/x/lists.rb

Overview

X data lookups (subscription required)

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Lists

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

Parameters:



96
97
98
# File 'lib/x_twitter_scraper/resources/x/lists.rb', line 96

def initialize(client:)
  @client = client
end

Instance Method Details

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

Get list followers

Parameters:

  • id (String)

    List ID

  • cursor (String)

    Pagination cursor for list followers

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

Returns:

See Also:



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

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

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

Get list members

Parameters:

  • id (String)

    List ID for member lookup

  • cursor (String)

    Pagination cursor for list members

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

Returns:

See Also:



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

def retrieve_members(id, params = {})
  parsed, options = XTwitterScraper::X::ListRetrieveMembersParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/lists/%1$s/members", id],
    query: query,
    model: XTwitterScraper::PaginatedUsers,
    options: options
  )
end

#retrieve_tweets(id, cursor: nil, include_replies: nil, since_time: nil, until_time: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

Get list tweets

Parameters:

  • id (String)

    List ID for tweet lookup

  • cursor (String)

    Pagination cursor for list tweets

  • include_replies (Boolean)

    Include replies (default false)

  • since_time (String)

    Unix timestamp - filter after

  • until_time (String)

    Unix timestamp - filter before

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

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/x_twitter_scraper/resources/x/lists.rb', line 77

def retrieve_tweets(id, params = {})
  parsed, options = XTwitterScraper::X::ListRetrieveTweetsParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/lists/%1$s/tweets", id],
    query: query.transform_keys(
      include_replies: "includeReplies",
      since_time: "sinceTime",
      until_time: "untilTime"
    ),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end