GET /2/tweets/search/all

This endpoint is only available to those users who have been approved for the Academic Research product track.

The full-archive search endpoint returns the complete history of public Tweets matching a search query; since the first Tweet was created March 26, 2006.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.



Endpoint URL

https://api.twitter.com/2/tweets/search/all

Authentication and rate limits

Authentication methods
supported by this endpoint

OAuth 2.0 Bearer token

Rate limit

300 requests per 15-minute window (app auth)

1 request per second (app auth)

Learn more about rate limits.



Query parameters

NameTypeDescription
end_time
 Optional 
date (ISO 8601)YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). Used with start_time. 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 without start_time, Tweets from 30 days before end_time will be returned by default. If not specified, end_time will default to [now - 30 seconds].
expansions
 Optional 
enum (attachments.poll_ids, attachments.media_keys, author_id, entities.mentions.username, geo.place_id, in_reply_to_user_id, referenced_tweets.id, referenced_tweets.id.author_id)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.

The following data objects can be expanded using this parameter:
  • The Tweet author's user object
  • The user object of the Tweet’s author that the original Tweet is responding to
  • Any mentioned users’ object
  • Any referenced Tweets’ author’s user object
  • Attached media’s object
  • Attached poll’s object
  • Attached place’s object
  • Any referenced Tweets’ object
max_results
 Optional 
integerThe maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500). By default, a request response will return 10 results.
media.fields
 Optional 
enum (duration_ms, height, media_key, preview_image_url, type, url, width, public_metrics)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 the expansions=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 the includes data object.
next_token
 Optional 
stringThis 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.
place.fields
 Optional 
enum (contained_within, country, country_code, full_name, geo, id, name, place_type)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 the expansions=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 the includes data object.
poll.fields
 Optional 
enum (duration_minutes, end_datetime, id, options, voting_status)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 the expansions=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 the includes data object.
query
 Required 
stringOne query for matching Tweets. Up to 1024 characters.
since_id
 Optional 
stringReturns results with a Tweet ID greater than (for example, more recent than) the specified ID. The ID specified is exclusive and responses will not include it. If included with the same request as a start_time parameter, only since_id will be used.
start_time
 Optional 
date (ISO 8601)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.
tweet.fields
 Optional 
enum (attachments, author_id, context_annotations, conversation_id, created_at, entities, geo, id, in_reply_to_user_id, lang, public_metrics, possibly_sensitive, referenced_tweets, reply_settings, source, text, withheld)This fields parameter enables you to select which specific Tweet fields will deliver in each returned Tweet object. Specify the desired fields in a comma-separated list without spaces between commas and fields. You can also pass the expansions=referenced_tweets.id expansion 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 the includes data object.
until_id
 Optional 
stringReturns results with a Tweet ID less than (that is, older than) the specified ID. Used with since_id. The ID specified is exclusive and responses will not include it.
user.fields
 Optional 
enum (created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld)This fields parameter enables you to select which specific user fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. While the user ID will be located in the original Tweet object, you will find this ID and all additional user fields in the includes data object.

You must also pass one of the user expansions to return the desired user fields:
  • expansions=author_id
  • expansions=entities.mentions.username
  • expansions=in_reply_to_user_id
  • expansions=referenced_tweets.id.author_id


Example requests

  • cURL (default fields)
  • cURL (optional fields)
      curl "https://api.twitter.com/2/tweets/search/all?query=from%3Atwitterdev%20new%20-is%3Aretweet&max_results=10" -H "Authorization: Bearer $BEARER_TOKEN"
    
      curl "https://api.twitter.com/2/tweets/search/all?query=from%3Atwitterdev%20new%20-is%3Aretweet&max_results=10&start_time=2020-01-01T00%3A00%3A00Z&end_time=2021-01-01T11%3A59%3A59Z&expansions=author_id&tweet.fields=created_at,lang,conversation_id&user.fields=created_at,entities" -H "Authorization: Bearer $BEARER_TOKEN"
    

Example responses

  • Default Fields
  • Optional Fields
      {
  "data": [
    {
      "id": "1373001119480344583",
      "text": "Looking to get started with the Twitter API but new to APIs in general? @jessicagarson will walk you through everything you need to know in APIs 101 session. She’ll use examples using our v2 endpoints, Tuesday, March 23rd at 1 pm EST.nnJoin us on Twitchnhttps://t.co/GrtBOXyHmB"
    },
    {
      "id": "1372627771717869568",
      "text": "Thanks to everyone who joined and made today a great session! 🙌 nnIf weren't able to attend, we've got you covered. Academic researchers can now sign up for office hours for help using the new product track. See how you can sign up, here 👇nhttps://t.co/duIkd27lPx https://t.co/AP9YY4F8FG"
    },
    {
      "id": "1367519323925843968",
      "text": "Meet Aviary, a modern client for iOS 14 built using the new Twitter API. It has a beautiful UI and great widgets to keep you up to date with the latest Tweets. https://t.co/95cbd253jK"
    },
    {
      "id": "1366832168333234177",
      "text": "The new #TwitterAPI provides the ability to build the Tweet payload with the fields that you want. nnIn this tutorial @suhemparack explains how to build the new Tweet payload and how it compares with the old Tweet payload in v1.1 👇 https://t.co/eQZulq4Ik3"
    },
    {
      "id": "1364984313154916352",
      "text": "“I was heading to a design conference in New York and wanted to meet new people,” recalls @aaronykng, creator of @flocknet. “There wasn't an easy way to see all of the designers in my network, so I built one.” Making things like this opened the doors for him to the tech industry."
    },
    {
      "id": "1364275610764201984",
      "text": "If you're newly approved for the Academic Research product track, our next stream is for you.nnThis Thursday, February 25th at 10AM PST @suhemparack will demo how academics can use this track to get started with the new #TwitterAPInnJoin us on Twitch! 👀nhttps://t.co/SQziibOD9P"
    }
  ],
  "meta": {
    "newest_id": "1373001119480344583",
    "oldest_id": "1364275610764201984",
    "result_count": 6
  }
}
    
      {
  "data": [
    {
      "text": "Introducing a new Tweet field on v2 endpoints: “reply_settings" shows how the Tweet author allowed others to reply to their post. This can help you filter only by Tweets you can reply to, or better analyze public conversations. Learn more about it here 👇 https://t.co/XR09zDvpmZ https://t.co/YIfg7F0En2",
      "author_id": "2244994945",
      "id": "1339981239294566401",
      "lang": "en",
      "conversation_id": "1339981239294566401",
      "created_at": "2020-12-18T17:09:57.000Z"
    },
    {
      "text": "Now in the new #TwitterAPI: user Tweet timeline and user mention timeline!nYou can now get Tweets composed by or mentioning an account with the #TwitterAPI. Check out today’s announcement for what’s new, use cases, and sample code 👇 https://t.co/L1PBSSjh1Q https://t.co/ydzhCIZ4Cy",
      "author_id": "2244994945",
      "id": "1339682027885522947",
      "lang": "en",
      "conversation_id": "1339682027885522947",
      "created_at": "2020-12-17T21:21:00.000Z"
    },
    {
      "text": "2021 can't come fast enough, but when it does, be on the lookout for functionality to follow/unfollow accounts, and manage and retrieve block and mute relationships using the new #TwitterAPI. Check out our roadmap to see what’s coming next! https://t.co/rspek8xGhV",
      "author_id": "2244994945",
      "id": "1339641862265696256",
      "lang": "en",
      "conversation_id": "1339641861263245315",
      "created_at": "2020-12-17T18:41:23.000Z"
    },
    {
      "text": "📣 We’re releasing new v2 endpoints today! The follows lookup endpoints enable you to retrieve a person’s follower and following relationships via the #TwitterAPI. Learn more 👇 https://t.co/YT13a2tPFE",
      "author_id": "2244994945",
      "id": "1339641861263245315",
      "lang": "en",
      "conversation_id": "1339641861263245315",
      "created_at": "2020-12-17T18:41:23.000Z"
    },
    {
      "text": "💡 Using Twitter data for academic research? Join our next livestream this Friday @ 9am PT on https://t.co/GrtBOXh5Y1!n n@SuhemParack will show how to get started with recent search & filtered stream endpoints on the #TwitterAPI v2, the new Tweet payload, annotations, & more. https://t.co/IraD2Z7wEg",
      "author_id": "2244994945",
      "id": "1338971066773905408",
      "lang": "en",
      "conversation_id": "1338971066773905408",
      "created_at": "2020-12-15T22:15:53.000Z"
    },
    {
      "text": "👂We want to hear what you think about our plans. As we continue to build our new product tracks, your feedback is essential to shaping the future of the Twitter API. Share your thoughts on this survey: https://t.co/dkIqFGPji7",
      "author_id": "2244994945",
      "id": "1337122535188652033",
      "lang": "en",
      "conversation_id": "1337122534173663235",
      "created_at": "2020-12-10T19:50:29.000Z"
    },
    {
      "text": "Is 2020 over yet?nDespite everything that happened this year, thousands of you still made the time to learn, play, and build incredible things on the new #TwitterAPI.nWe want to share some of your stories and give you a preview of what’s to come next year.nhttps://t.co/VpOKT22WgF",
      "author_id": "2244994945",
      "id": "1337122534173663235",
      "lang": "en",
      "conversation_id": "1337122534173663235",
      "created_at": "2020-12-10T19:50:29.000Z"
    },
    {
      "text": "🎧 Headphones on: watch @jessicagarson build an interactive app to write music using SuperCollider, Python, FoxDot, and the new Twitter API. Streaming Friday 1:30 ET on our new Twitch channel 🎶💻 https://t.co/SQziic6eyp",
      "author_id": "2244994945",
      "id": "1336463248510623745",
      "lang": "en",
      "conversation_id": "1336463248510623745",
      "created_at": "2020-12-09T00:10:43.000Z"
    },
    {
      "text": "Before we release new #TwitterAPI endpoints, we let developers test drive a prototype of our intended design. @i_am_daniele takes you behind the scenes of an endpoint in the making. https://t.co/NNTDnciwNq",
      "author_id": "2244994945",
      "id": "1334564488884862976",
      "lang": "en",
      "conversation_id": "1334564488884862976",
      "created_at": "2020-12-03T18:25:43.000Z"
    },
    {
      "text": "We’d love to see what you build with the new Twitter API v2!nnShare your work in our community forum and we might even send some cool swag to the first 10 developers who share what they build 👇nnhttps://t.co/m0jn5vkHRj",
      "author_id": "2244994945",
      "id": "1334200898042531841",
      "lang": "en",
      "conversation_id": "1334200897081987072",
      "created_at": "2020-12-02T18:20:57.000Z"
    }
  ],
  "includes": {
    "users": [
      {
        "id": "2244994945",
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.twitter.com/en/community",
                "display_url": "developer.twitter.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "created_at": "2013-12-14T04:35:55.000Z",
        "username": "TwitterDev",
        "name": "Twitter Dev"
      }
    ]
  },
  "meta": {
    "newest_id": "1339981239294566401",
    "oldest_id": "1334200898042531841",
    "result_count": 10,
    "next_token": "b26v89c19zqg8o3fosetlg0yp2g8b5onm3alivsyjjm2l"
  }
}
    

Response fields

NameTypeDescription
id
 Default 
stringUnique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
text
 Default 
stringThe content of the Tweet.

To return this field, add tweet.fields=text in the request's query parameter.
created_atdate (ISO 8601)Creation time of the Tweet.

To return this field, add tweet.fields=created_at in the request's query parameter.
author_idstringUnique identifier of this user. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.users by adding expansions=author_id in the request's query parameter.
conversation_idstringThe Tweet ID of the original Tweet of the conversation (which includes direct replies, replies of replies).

To return this field, add tweet.fields=conversation_id in the request's query parameter.
in_reply_to_user_idstringIf this Tweet is a Reply, indicates the user ID of the parent Tweet's author. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.users by adding expansions=in_reply_to_user_id in the request's query parameter.
referenced_tweetsarrayA list of Tweets this Tweet refers to. For example, if the parent Tweet is a Retweet, a Retweet with comment (also known as Quoted Tweet) or a Reply, it will include the related Tweet referenced to by its parent.

To return this field, add tweet.fields=referenced_tweets in the request's query parameter.
referenced_tweets.typeenum (retweeted, quoted, replied_to)Indicates the type of relationship between this Tweet and the Tweet returned in the response: retweeted (this Tweet is a Retweet), quoted (a Retweet with comment, also known as Quoted Tweet), or replied_to (this Tweet is a reply).
referenced_tweets.idstringThe unique identifier of the referenced Tweet.

You can obtain the expanded object in includes.tweets by adding expansions=referenced_tweets.id in the request's query parameter.
attachmentsobjectSpecifies the type of attachments (if any) present in this Tweet.

To return this field, add tweet.fields=attachments in the request's query parameter.
attachments.media_keysarrayList of unique identifiers of media attached to this Tweet. These identifiers use the same media key format as those returned by the Media Library.

You can obtain the expanded object in includes.media by adding expansions=attachments.media_keys in the request's query parameter.
attachments.poll_idsarrayList of unique identifiers of polls present in the Tweets returned. These are returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.polls by adding expansions=attachments.polls_ids in the request's query parameter.
geoobjectContains details about the location tagged by the user in this Tweet, if they specified one.

To return this field, add tweet.fields=geo in the request's query parameter.
geo.coordinatesobjectContains details about the coordinates of the location tagged by the user in this Tweet, if they specified one.

To return this field, add tweet.fields=geo.coordinates in the request's query parameter.
geo.coordinates.typestringDescribes the type of coordinate. The only value supported at present is Point.
geo.coordinates.coordinatesarrayA pair of decimal values representing the precise location of the user (latitude, longitude). This value be null unless the user explicitly shared their precise location.
geo.place_idstringThe unique identifier of the place, if this is a point of interest tagged in the Tweet.

You can obtain the expanded object in includes.places by adding expansions=geo.place_id in the request's query parameter.
context_annotationsarrayContains context annotations for the Tweet.

To return this field, add tweet.fields=context_annotations in the request's query parameter.
context_annotations.domainobjectContains elements which identify detailed information regarding the domain classification based on Tweet text.
context_annotations.domain.idstringContains the numeric value of the domain.
context_annotations.domain.namestringDomain name based on the Tweet text.
context_annotations.domain.descriptionstringLong form description of domain classification.
context_annotations.entityobjectContains elements which identify detailed information regarding the domain classification bases on Tweet text.
context_annotations.entity.idstringUnique value which correlates to an explicitly mentioned Person, Place, Product or Organization
context_annotations.entity.namestringName or reference of entity referenced in the Tweet.
context_annotations.entity.descriptionstringAdditional information regarding referenced entity.
entitiesobjectContains details about text that has a special meaning in a Tweet.

To return this field, add tweet.fields=entities in the request's query parameter.
entities.annotationsarrayContains details about annotations relative to the text within a Tweet.
entities.annotations.startintegerThe start position (zero-based) of the text used to annotate the Tweet.
entities.annotations.endintegerThe end position (zero based) of the text used to annotate the Tweet.
entities.annotations.probabilitynumberThe confidence score for the annotation as it correlates to the Tweet text.
entities.annotations.typestringThe description of the type of entity identified when the Tweet text was interpreted.
entities.annotations.normalized_textstringThe text used to determine the annotation type.
entities.urlsarrayContains details about text recognized as a URL.
entities.urls.startintegerThe start position (zero-based) of the recognized URL within the Tweet.
entities.urls.endintegerThe end position (zero-based) of the recognized URL within the Tweet.
entities.urls.urlstringThe URL in the format tweeted by the user.
entities.urls.expanded_urlstringThe fully resolved URL.
entities.urls.display_urlstringThe URL as displayed in the Twitter client.
entities.urls.unwound_urlstringThe full destination URL.
entities.hashtagsarrayContains details about text recognized as a Hashtag.
entities.hashtags.startintegerThe start position (zero-based) of the recognized Hashtag within the Tweet.
entities.hashtags.endintegerThe end position (zero-based) of the recognized Hashtag within the Tweet.
entities.hashtags.tagstringThe text of the Hashtag.
entities.mentionsarrayContains details about text recognized as a user mention.
entities.mentions.startintegerThe start position (zero-based) of the recognized user mention within the Tweet.
entities.mentions.endintegerThe end position (zero-based) of the recognized user mention within the Tweet.
entities.mentions.usernamestringThe part of text recognized as a user mention.

You can obtain the expanded object in includes.users by adding expansions=entities.mentions.username in the request's query parameter.
entities.cashtagsarrayContains details about text recognized as a Cashtag.
entities.cashtags.startintegerThe start position (zero-based) of the recognized Cashtag within the Tweet.
entities.cashtags.endintegerThe end position (zero-based) of the recognized Cashtag within the Tweet.
entities.cashtags.tagstringThe text of the Cashtag.
withheldobjectContains withholding details for withheld content.

To return this field, add tweet.fields=withheld in the request's query parameter.
withheld.copyrightbooleanIndicates if the content is being withheld for on the basis of copyright infringement.
withheld.country_codesarrayProvides a list of countries where this content is not available.
withheld.scopeenum (tweet, user)Indicates whether the content being withheld is a Tweet or a user.
public_metricsobjectEngagement metrics for the Tweet at the time of the request.

To return this field, add tweet.fields=public_metrics in the request's query parameter.
public_metrics.retweet_countintegerNumber of times this Tweet has been Retweeted.
public_metrics.reply_countintegerNumber of Replies of this Tweet.
public_metrics.like_countintegerNumber of Likes of this Tweet.
public_metrics.quote_countintegerNumber of times this Tweet has been Retweeted with a comment (also known as Quote).
possibly_sensitivebooleanIndicates if this Tweet contains URLs marked as sensitive, for example content suitable for mature audiences.

To return this field, add tweet.fields=possibly_sensitive in the request's query parameter.
langstringLanguage of the Tweet, if detected by Twitter. Returned as a BCP47 language tag.

To return this field, add tweet.fields=lang in the request's query parameter.
reply_settingsstringShows who can reply to this Tweet. Fields returned are everyone, mentionedUsers, and following.

To return this field, add tweet.fields=reply_settings in the request's query parameter.
sourcestringThe name of the app the user Tweeted from.

To return this field, add tweet.fields=source in the request's query parameter.
includesobjectIf you include an expansion parameter, the referenced objects will be returned if available.
includes.tweetsarrayWhen including the expansions=referenced_tweets.id parameter, this includes a list of referenced Retweets, Quoted Tweets, or replies in the form of Tweet objects with their default fields and any additional fields requested using the tweet.fields parameter, assuming there is a referenced Tweet present in the returned Tweet(s).
includes.usersarrayWhen including the expansions=author_id parameter, this includes a list of referenced Tweet authors in the form of user objects with their default fields and any additional fields requested using the user.fields parameter.
includes.placesarrayWhen including the expansions=geo.place_id parameter, this includes a list of referenced places in Tweets in the form of place objects with their default fields and any additional fields requested using the place.fields parameter, assuming there is a place present in the returned Tweet(s).
includes.mediaarrayWhen including the expansions=attachments.media_keys parameter, this includes a list of images, videos, and GIFs included in Tweets in the form of media objects with their default fields and any additional fields requested using the media.fields parameter, assuming there is a media attachment present in the returned Tweet(s).
includes.pollsstringWhen including the expansions=attachments.poll_ids parameter, this includes a list of polls that are attached to Tweets in the form of poll objects with their default fields and any additional fields requested using the poll.fields parameter, assuming there is a poll present in the returned Tweet(s).
errorsobjectContains details about errors that affected any of the requested Tweets. See Status codes and error messages for more details.
Was this document helpful?
Thank you

Thank you for the feedback. We’re really glad we could help!

Thank you for the feedback. How could we improve this document?
Thank you for the feedback. Your comments will help us improve our documents in the future.