Module: Twitter::API::Search

Defined in:

Instance Method Summary collapse

Instance Method Details

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


Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.

Returns tweets that match a specified query.


Return tweets related to twitter'twitter')


  • q (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 of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by “latitude,longitude,radius”, where radius units must be specified as either “mi” (miles) or “km” (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.

  • :lang (String)

    Restricts tweets to the given language, given by an ISO 639-1 code.

  • :locale (String)

    Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.

  • :result_type (String)

    Specifies what type of search results you would prefer to receive. Options are “mixed”, “recent”, and “popular”. The current default is “mixed.”

  • :count (Integer)

    The number of tweets to return per page, up to a maximum of 100.

  • :until (String)

    Optional. Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD.

  • :since_id (Integer)

    Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

  • :max_id (Integer)

    Returns results with an ID less than (that is, older than) or equal to the specified ID.

  • :include_entities (Boolean, String, Integer)

    The tweet entities node will be disincluded when set to false.


  • (Twitter::SearchResults)

    Return tweets that match a specified query with search metadata


  • (Twitter::Error::Unauthorized)

    Error raised when supplied user credentials are not valid.

See Also:

# File 'lib/hackeroo/api/search.rb', line 31

def search(q, options={})
  object_from_response(Twitter::SearchResults, :get, "/1.1/search/tweets.json", options.merge(:q => q))