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

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

Overview

X Community info, members, and tweets

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:



81
82
83
# File 'lib/x_twitter_scraper/resources/x/communities/tweets.rb', line 81

def initialize(client:)
  @client = client
end

Instance Method Details

#list(community_id:, q:, cursor: nil, page_size: nil, query_type: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

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

Requires a Community ID and keyword query.

Parameters:

  • community_id (String)

    Numeric ID of the community to search

  • q (String)

    Keyword query within the selected community

  • cursor (String)

    Pagination cursor for community results

  • page_size (Integer)

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

  • query_type (Symbol, XTwitterScraper::Models::X::Communities::TweetListParams::QueryType)

    Sort order for community results (Latest or Top)

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

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/x_twitter_scraper/resources/x/communities/tweets.rb', line 31

def list(params)
  parsed, options = XTwitterScraper::X::Communities::TweetListParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "x/communities/tweets",
    query: query.transform_keys(
      community_id: "communityId",
      page_size: "pageSize",
      query_type: "queryType"
    ),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

#list_by_community(id, cursor: nil, page_size: nil, request_options: {}) ⇒ XTwitterScraper::Models::PaginatedTweets

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

List tweets posted in a community

Parameters:

  • id (String)

    Community ID for tweet lookup

  • cursor (String)

    Pagination cursor for community tweets

  • page_size (Integer)

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

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

Returns:

See Also:



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

def list_by_community(id, params = {})
  parsed, options = XTwitterScraper::X::Communities::TweetListByCommunityParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["x/communities/%1$s/tweets", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end