public interface SearchService
| Modifier and Type | Method and Description |
|---|---|
<any> |
tweets(String query,
Geocode geocode,
String lang,
String locale,
String resultType,
Integer count,
String until,
Long sinceId,
Long maxId,
Boolean includeEntities)
Returns a collection of relevant Tweets matching a specified query.
|
<any> tweets(String query,
Geocode geocode,
String lang,
String locale,
String resultType,
Integer count,
String until,
Long sinceId,
Long maxId,
Boolean includeEntities)
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.
In API v1.1, the response format of the Search API has been improved to return Tweet objects more similar to the objects you'll find across the REST API and platform. You may need to tolerate some inconsistencies and variance in perspectival values (fields that pertain to the perspective of the authenticating user) and embedded user objects.
To learn how to use Twitter Search effectively, consult our guide to Using the Twitter Search API. See Working with Timelines to learn best practices for navigating results by since_id and max_id.
query - (required) A UTF-8, URL-encoded search query of 500 characters maximum,
including operators. Queries may additionally be limited by complexity.geocode - (optional) 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. A maximum of 1,000
distinct "sub-regions" will be considered when using the radius modifier.lang - (optional) Restricts tweets to the given language, given by an ISO 639-1 code.
Language detection is best-effort.locale - (optional) Specify the language of the query you are sending (only ja is
currently effective). This is intended for language-specific consumers and the
default should work in the majority of cases.resultType - (optional) Specifies what type of search results you would prefer to
receive. The current default is "mixed." Valid values include:
mixed: Include both popular and real time results in the response.
recent: return only the most recent results in the response
popular: return only the most popular results in the response.count - (optional) The number of tweets to return per page, up to a maximum of 100.
Defaults to 15. This was formerly the "rpp" parameter in the old Search API.until - (optional) Returns tweets generated before the given date. Date should be
formatted as YYYY-MM-DD. Keep in mind that the search index may not go back as
far as the date you specify here.sinceId - (optional) 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.maxId - (optional) Returns results with an ID less than (that is, older than) or equal
to the specified ID.includeEntities - (optional) The entities node will be disincluded when set to false.