Twitter Tweets & Archive Search (V2) - Data API Endpoint

Tweets & Archive Search (V2) by query, bearer token, pagination token, expansions, fields (media), fields (places), fields (polls) and fields (tweets).


Get bulk Tweets & Archive Search (V2) data from the Twitter API | Official API: https://developer.twitter.com/en/docs | 👥  Contributors: steve 🚩  Report

✏️ Inputs

Query query Required

Search query to run on Twitter, see their docs for examples on how to search.

Also see their quick start guide for more information: https://developer.twitter.com/en/docs/twitter-api/tweets/search/quick-start/recent-search

Some common example:

  • from:twitterdev Gets tweets from the @twitterdev account (leave out the @ in your query)
  • #beer Gets tweets containing the hashtag #beer
  • @twitterdev Gets tweets mentioning @twitterdev

These require the Academic Research Project:

  • $TWTR Gets tweets mentioning the cashtag $TWTR

You may also want to add -is:retweet -is:reply -is:quote to your query to avoid these other types.

E.g. #beer
Bearer Token access_token Required

Your Twitter app’s Bearer Token for collecting data with. If you don’t have one, see How to Get a Twitter API Key Without Approval or check out Twitter’s docs on Bearer Tokens for more information.

Pagination Token pagination_token Optional

Used for pagination. Provide the next_token you see in a response here to get the next page of results.

Expansions expansions Optional

A comma-separates list of expanded object data attached to the Tweet. See https://developer.twitter.com/en/docs/twitter-api/expansions for more and possible values.

E.g. author_id,referenced_tweets.id,in_reply_to_user_id,attachments.media_keys,attachments.poll_ids,geo.place_id,entities.mentions.username,referenced_tweets.id.author_id
Fields (Media) media_fields Optional

A comma-separated list of fields you would like back from the Media Model: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media

E.g. duration_ms,height,preview_image_url,public_metrics,width
Fields (Places) place_fields Optional

A comma-separated list of fields you would like back from the Place Model: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place

E.g. contained_within,country,country_code,geo,name,place_type
Fields (Polls) poll_fields Optional

A comma-separated list of fields you would like back from the Poll Model: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll

E.g. duration_minutes,end_datetime,voting_status
Fields (Tweets) tweet_fields Optional

A comma-separated list of fields you would like back from the Tweet Model: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet

E.g. attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,reply_settings,source,withheld
Fields (Users) user_fields Optional

A comma-separated list of fields you would like back from the User Model: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user

E.g. created_at,description,entities,location,pinned_tweet_id,profile_image_url,protected,public_metrics,url,verified,withheld
Time Range (Ending Time) end_time Optional

End time range of the Tweets to fetch. This is exclusive, e.g. 2021-01-01T00:00:01Z will exclude the first second of 2021. Format is in YYYY-MM-DDTHH:mm:ssZ.

E.g. 2021-01-01T00:00:01Z
Time Range (Starting Time) start_time Optional

The starting timestamp of Tweets to return in the query. This is inclusive, so 2020-01-01T00:00:00 will include the first second of the new year.

E.g. 2020-01-01T00:00:00Z
Recent or All recent_or_all Default recent

Leave this as the default recent to search for Tweets published in the last 7 days. Change this to all to access the V2 Full Archive Search (only available to users on the Academic Research product track). Learn more here: https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all

Limit limit Optional

How many results to return on each request.

Articles

📝 Notes

Posted by steve on Jan. 20, 2022, 6:30 a.m. 🚩  Report

⚡️ Endpoint

GET https://api.twitter.com/2/tweets/search/{{recent_or_all}}?query={{query}}&max_results={{ limit }}&tweet.fields={{tweet_fields}}&user.fields={{user_fields}}&media.fields={{media_fields}}&poll.fields={{poll_fields}}&place.fields={{place_fields}}&expansions={{expansions}}&next_token={{pagination_token}}&end_time={{end_time}}&start_time={{start_time}}

Body

None

Headers

Authorization
Bearer {{access_token}}