Logo
Twitter API Documentation

Recent search

GET https://api.twitter.com/2/tweets/search/recent?query=

Search for public Tweets created in the last 7 days.

For full details, see the API reference for this endpoint.

 

Body PARAM

Key Datatype Required Description 
query
null Required. Query for matching Tweets. Up to 512 characters.
start_time
null The oldest UTC timestamp (from most recent 7 days) from which the Tweets will be provided. YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339).
end_time
null The newest, most recent UTC timestamp to which the Tweets will be provided. YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339).
since_id
null 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.
until_id
null 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.
max_results
null The maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 100). By default, a request response will return 10 results.
next_token
null 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.
tweet.fields
null Comma-separated list of fields for the Tweet object. Allowed values: attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,reply_settings,source,text,withheld Default values: id,text OAuth1.0a User Context authorization required if any of the following fields are included in the request: non_public_metrics,organic_metrics,promoted_metrics
expansions
null Comma-separated list of fields to expand. Expansions enable requests to expand an ID into a full object in the includes response object. Allowed values: attachments.poll_ids,attachments.media_keys,author_id,geo.place_id,in_reply_to_user_id,referenced_tweets.id,entities.mentions.username,referenced_tweets.id.author_id Default values: none
media.fields
null Comma-separated list of fields for the media object. Expansion required. Allowed values: duration_ms,height,media_key,non_public_metrics,organic_metrics,preview_image_url,promoted_metrics,public_metrics,type,url,width Default values: media_key,type OAuth1.0a User Context authorization required if any of the following fields are included in the request: non_public_metrics,organic_metrics,promoted_metrics
place.fields
null Comma-separated list of fields for the place object. Expansion required. Allowed values: contained_within,country,country_code,full_name,geo,id,name,place_type Default values: id,full_name
poll.fields
null Comma-separated list of fields for the poll object. Expansion required. Allowed values: duration_minutes,end_datetime,id,options,voting_status Default values: id, options
user.fields
null Comma-separated list of fields for the user object. Expansion required. Allowed values: created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld Default values: id,name,username



HEADERS

Key Datatype Required Description 




RESPONSES

status OK

{ "data": [ { "attachments": { "media_keys": [ "16_1276035971193044992" ] }, "author_id": "63046977", "created_at": "2020-06-25T06:14:19.000Z", "entities": { "mentions": [ { "start": 0, "end": 8, "username": "snowman" } ], "urls": [ { "start": 90, "end": 113, "url": "https://t.co/14TzLYBBXi", "expanded_url": "https://twitter.com/happycamper/status/1276035977375477760/photo/1", "display_url": "pic.twitter.com/14TzLYBBXi" } ] }, "geo": { "place_id": "f7eb2fa2fea288b1" }, "id": "1276035977375477760", "in_reply_to_user_id": "17200003", "lang": "en", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1275653067283759104" } ], "source": "Twitter for iPhone", "text": "@snowman Ooo, thanks error message, public_metircs are not the metrics you’re looking for https://t.co/14TzLYBBXi" }, { "author_id": "17200003", "created_at": "2020-06-24T20:04:54.000Z", "id": "1275882613572583424", "in_reply_to_user_id": "17200003", "lang": "en", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1273733248749690880" } ], "source": "Twitter for Android", "text": "Using Labs Recent search for polling use cases has been πŸ”₯πŸ‘. A simple alternative to streaming in many cases..." }, { "attachments": { "media_keys": [ "16_1275763720522625029" ] }, "author_id": "196883832", "created_at": "2020-06-24T12:12:29.000Z", "entities": { "mentions": [ { "start": 0, "end": 8, "username": "snowman" }, { "start": 9, "end": 21, "username": "happycamper" } ], "urls": [ { "start": 22, "end": 45, "url": "https://t.co/qvk5BCBtqh", "expanded_url": "https://twitter.com/jellybeanjones/status/1275763727908798470/photo/1", "display_url": "pic.twitter.com/qvk5BCBtqh" } ] }, "geo": { "place_id": "f7eb2fa2fea288b1" }, "id": "1275763727908798470", "in_reply_to_user_id": "17200003", "lang": "und", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1275653067283759104" } ], "source": "Twitter for iPhone", "text": "@snowman @happycamper https://t.co/qvk5BCBtqh" }, { "author_id": "17200003", "created_at": "2020-06-24T04:52:46.000Z", "entities": { "mentions": [ { "start": 0, "end": 12, "username": "happycamper" } ] }, "id": "1275653067283759104", "in_reply_to_user_id": "63046977", "lang": "en", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1274086728471461889" } ], "source": "Twitter Web App", "text": "@happycamper Wait, when I try that, I get an error: {\n \"errors\": [\n { \"message\": \"[public_metircs] is not one of [attachments,author_id,context_annotations,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,promoted_metrics,public_metrics]\"" } ], "includes": { "users": [ { "created_at": "2009-08-05T05:46:48.000Z", "description": "Part-time fiddler, wanderer, yogi, scubadiver #savegamehenge Full time explorer, festvarian, music lover, nerd, @TwitterBoulder - Opinions are my own. she/her", "id": "63046977", "name": "Emily Waligoske πŸ•", "username": "happycamper" }, { "created_at": "2008-11-05T23:06:37.000Z", "description": "family, travel, music, farming, photography, coding, weather, rain, snow, snowmelt, hydrology, flood early-warning systems. From MN, live in CO. @TwitterDev", "id": "17200003", "name": "Jim Moffitt", "username": "snowman" }, { "created_at": "2010-09-30T03:36:40.000Z", "description": "IT wizard @ Twitter Boulder πŸ§™\u200dβ™‚οΈπŸ—»πŸ’» 🎧🌞✌🏽Turn my headphones up! #BlackLivesMatter", "id": "196883832", "name": "zachariah jones", "username": "jellybeanjones" } ], "tweets": [ { "author_id": "17200003", "created_at": "2020-06-24T04:52:46.000Z", "entities": { "mentions": [ { "start": 0, "end": 12, "username": "happycamper" } ] }, "id": "1275653067283759104", "in_reply_to_user_id": "63046977", "lang": "en", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1274086728471461889" } ], "source": "Twitter Web App", "text": "@happycamper Wait, when I try that, I get an error: {\n \"errors\": [\n { \"message\": \"[public_metircs] is not one of [attachments,author_id,context_annotations,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,promoted_metrics,public_metrics]\"" }, { "author_id": "17200003", "created_at": "2020-06-18T21:44:05.000Z", "id": "1273733248749690880", "lang": "en", "possibly_sensitive": false, "source": "Twitter Web App", "text": "So, what's your favorite thing about Twitter Developer Labs? \n\nI find it hard to pick one and am loving the ability to select the Tweet object fields of interest. \n\ntweet.fields=created_at,author_id,context_annotations" }, { "author_id": "63046977", "created_at": "2020-06-19T21:08:42.000Z", "entities": { "hashtags": [ { "start": 209, "end": 215, "tag": "fresh" } ], "mentions": [ { "start": 0, "end": 8, "username": "snowman" } ] }, "id": "1274086728471461889", "in_reply_to_user_id": "17200003", "lang": "en", "possibly_sensitive": false, "referenced_tweets": [ { "type": "replied_to", "id": "1273733248749690880" } ], "source": "Twitter Web App", "text": "@snowman My fave is the new the metrics, especially for building apps to help Twitter users track the metrics for their Tweets.\ntweet.fields=public_metircs,non_public_metrics,organic_metrics,promoted_metrics #fresh" } ] }, "meta": { "newest_id": "1276035977375477760", "oldest_id": "1275653067283759104", "result_count": 4 } }



Curl
curl -X GET 'https://api.twitter.com/2/tweets/search/recent?query=?query=&start_time=&end_time=&since_id=&until_id=&max_results=&next_token=&tweet.fields=&expansions=&media.fields=&place.fields=&poll.fields=&user.fields='

ENDPOINTS