Module: Twitter::REST::Search

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

Overview

Methods for searching tweets

Constant Summary collapse

MAX_TWEETS_PER_REQUEST =

Maximum tweets per request

100

Instance Method Summary collapse

Instance Method Details

#search(query, options = {}) ⇒ Twitter::SearchResults

Note:

Not all Tweets will be indexed or made available via the search interface.

Returns tweets that match a specified query

Examples:

client.search('twitter')

Parameters:

  • query (String)

    A search term.

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

    A customizable set of options.

Options Hash (options):

  • :geocode (String)

    Returns tweets by users located within a given radius.

  • :lang (String)

    Restricts tweets to the given language.

  • :locale (String)

    Specify the language of the query you are sending.

  • :result_type (String)

    Specifies result type: mixed, recent, or popular.

  • :count (Integer)

    The number of tweets to return per page.

  • :until (String)

    Returns tweets generated before the given date.

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :include_entities (Boolean)

    Include entities node.

  • :tweet_mode (String)

    Tweet text mode: compat or extended.

Returns:

Raises:

See Also:



34
35
36
37
38
39
# File 'lib/twitter/rest/search.rb', line 34

def search(query, options = {})
  options = options.dup
  options[:count] ||= MAX_TWEETS_PER_REQUEST
  request = Request.new(self, :get, "/1.1/search/tweets.json", options.merge(q: query))
  SearchResults.new(request)
end