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

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

Overview

X data lookups (subscription required)

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:



64
65
66
# File 'lib/x_twitter_scraper/resources/x/communities/tweets.rb', line 64

def initialize(client:)
  @client = client
end

Instance Method Details

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

Search tweets across all communities

Parameters:

  • q (String)

    Search query for cross-community tweets

  • cursor (String)

    Pagination cursor for cross-community results

  • query_type (String)

    Sort order for cross-community results (Latest or Top)

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

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/x_twitter_scraper/resources/x/communities/tweets.rb', line 24

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(query_type: "queryType"),
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end

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

Get community tweets

Parameters:

  • id (String)

    Community ID for tweet lookup

  • cursor (String)

    Pagination cursor for community tweets

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

Returns:

See Also:



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/x_twitter_scraper/resources/x/communities/tweets.rb', line 49

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,
    model: XTwitterScraper::PaginatedTweets,
    options: options
  )
end