Module: Twitter::REST::PremiumSearch

Included in:
API
Defined in:
lib/twitter/rest/premium_search.rb

Constant Summary collapse

MAX_TWEETS_PER_REQUEST =
100

Instance Method Summary collapse

Instance Method Details

#premium_search(query, options = {}, request_config = {}) ⇒ Twitter::PremiumSearchResults

Returns tweets from the 30-Day API that match a specified query.

Parameters:

  • query (String)

    A search term.

  • options (Hash) (defaults to: {})

    A customizable set of options.

  • request_config (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :tag (String)

    Tags can be used to segregate rules and their matching data into different logical groups.

  • :maxResults (Integer)

    The maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500, 100 for Sandbox environments). By default, a request response will return 100 results

  • :fromDate (String)

    The oldest UTC timestamp (from most recent 30 days) from which the Tweets will be provided. Date should be formatted as yyyymmddhhmm.

  • :toDate (String)

    The latest, most recent UTC timestamp to which the activities will be provided. Date should be formatted as yyyymmddhhmm.

Options Hash (request_config):

  • :product (String)

    Indicates the search endpoint you are making requests to, either 30day or fullarchive. Default 30day

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes



23
24
25
26
27
28
29
30
31
# File 'lib/twitter/rest/premium_search.rb', line 23

def premium_search(query, options = {}, request_config = {})
  options = options.clone
  options[:maxResults] ||= MAX_TWEETS_PER_REQUEST
  request_config[:request_method] = :json_post if request_config[:request_method].nil? || request_config[:request_method] == :post
  request_config[:product] ||= "30day"
  path = "/1.1/tweets/search/#{request_config[:product]}/#{dev_environment}.json"
  request = Twitter::REST::Request.new(self, request_config[:request_method], path, options.merge(query:))
  Twitter::PremiumSearchResults.new(request, request_config)
end