searchRecent abstract method
- {required String query,
- int? maxResults,
- String? nextToken,
- SortOrder? sortOrder,
- DateTime? startTime,
- DateTime? endTime,
- String? sinceTweetId,
- String? untilTweetId,
- List<
TweetExpansion> ? expansions, - List<
TweetField> ? tweetFields, - List<
UserField> ? userFields, - List<
PlaceField> ? placeFields, - List<
PollField> ? pollFields, - List<
MediaField> ? mediaFields, - ForwardPaging<
List< ? paging}TweetData> , TweetMeta>
The recent search endpoint returns Tweets from the last seven days that match a search query.
The Tweets returned by this endpoint count towards the Project-level Tweet cap.
The value returned when the paging
callback is specified is
the first object obtained that started the paging process. The value
obtained in the paging process is passed to the paging
callback
function as a PagingEvent
object.
Parameters
-
query
: One query for matching Tweets. You can learn how to build this query by reading our build a query guide. If you have Essential or Elevated access, you can use the Basic operators when building your query and can make queries up to 512 characters long. Learn more about our access levels on theabout Twitter API page
. -
maxResults
: The maximum number of search results to be returned by a request. A number between 10 and 100. By default, a request response will return 10 results. -
nextToken
: This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified. You can learn more by visiting our page on pagination. -
sortOrder
: This parameter is used to specify the order in which you want the Tweets returned. By default, a request will return the most recent Tweets first (sorted by recency). -
startTime
: YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). The oldest UTC timestamp from which the Tweets will be provided. Timestamp is in second granularity and is inclusive (for example, 12:00:01 includes the first second of the minute). By default, a request will return Tweets from up to 30 days ago if you do not include this parameter. -
endTime
: YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). Used withstartTime
. The newest, most recent UTC timestamp to which the Tweets will be provided. Timestamp is in second granularity and is exclusive (for example, 12:00:01 excludes the first second of the minute). If used withoutstartTime
, Tweets from 30 days beforeendTime
will be returned by default. If not specified,endTime
will default tonow - 30 seconds
. -
sinceTweetId
: Returns results with a Tweet ID greater than (that is, more recent than) the specified ID. The ID specified is exclusive and responses will not include it. If included with the same request as astartTime
parameter, onlysinceTweetId
will be used. -
untilTweetId
: Returns results with a Tweet ID less than (that is, older than) the specified ID. The ID specified is exclusive and responses will not include it. -
expansions
: Expansions enable you to request additional data objects that relate to the originally returned Tweets. Submit a list of desired expansions in a comma-separated list without spaces. The ID that represents the expanded data object will be included directly in the Tweet data object, but the expanded object metadata will be returned within the includes response object, and will also include the ID so that you can match this data object to the original Tweet object. -
tweetFields
: This fields parameter enables you to select which specific Tweet fields will deliver in each returned Tweet object. You can also passexpansions
to return the specified fields for both the original Tweet and any included referenced Tweets. The requested Tweet fields will display in both the original Tweet data object, as well as in the referenced Tweet expanded data object that will be located in theincludes
data object. -
userFields
: This fields parameter enables you to select which specific user fields will deliver in each returned Tweet. While the user ID will be located in the original Tweet object, you will find this ID and all additional user fields in theincludes
data object. -
placeFields
: This fields parameter enables you to select which specific place fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return place fields if the Tweet contains a place and if you’ve also included theexpansions=geo.place_id
query parameter in your request. While the place ID will be located in the Tweet object, you will find this ID and all additional place fields in theincludes
data object. -
pollFields
: This fields parameter enables you to select which specific poll fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return poll fields if the Tweet contains a poll and if you've also included theexpansions=attachments.poll_ids
query parameter in your request. While the poll ID will be located in the Tweet object, you will find this ID and all additional poll fields in theincludes
data object. -
mediaFields
: This fields parameter enables you to select which specific media fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return media fields if the Tweet contains media and if you've also included theexpansions=attachments.media_keys
query parameter in your request. While the media ID will be located in the Tweet object, you will find this ID and all additional media fields in theincludes
data object. -
paging
: If this callback function is specified, paging is performed continuously until certain conditions are met. This paging function is uni-directional, only forward, and allows for safe paging. The response and other metadata obtained when paging is performed is passed to the callback function asPagingEvent
object. So you can get the result of paging fromPagingEvent
object. Also, the direction and continuity of paging can be controlled by returningPaginationControl
object in thepaging
callback function. Please usePaginationControl.next()
to continue paging and move forward. And be sure to returnPaginationControl.stop()
to terminate paging on arbitrary conditions, otherwise paging continues until the next page runs out.
Endpoint Url
Authentication Methods
- OAuth 2.0 App-only
Rate Limits
-
App rate limit (OAuth 2.0 App Access Token): 450 requests per 15-minute window shared among all users of your app
-
User rate limit (OAuth 2.0 user Access Token): 180 requests per 15-minute window per each authenticated user
Reference
Implementation
Future<TwitterResponse<List<TweetData>, TweetMeta>> searchRecent({
required String query,
int? maxResults,
String? nextToken,
SortOrder? sortOrder,
DateTime? startTime,
DateTime? endTime,
String? sinceTweetId,
String? untilTweetId,
List<TweetExpansion>? expansions,
List<TweetField>? tweetFields,
List<UserField>? userFields,
List<PlaceField>? placeFields,
List<PollField>? pollFields,
List<MediaField>? mediaFields,
ForwardPaging<List<TweetData>, TweetMeta>? paging,
});