Skip to main content
Please note: We have released a new version of search Posts and Post counts in X API v2. We encourage you to review what’s new with X API v2.  These endpoints have been updated to include Post edit metadata. Learn more about these metadata on the “Edit Posts” fundamentals page

Overview

Enterprise The enterprise APIs are available within our managed access levels only. To use these APIs, you must first set up an account with our enterprise sales team. To learn more see HERE. You can view all of the X API search Post offerings HERE. There are two enterprise search APIs:
  1. 30-Day Search API provides data from the previous 30 days.
  2. Full-Archive Search API provides complete and instant access to the full corpus of X data dating all the way back to the first Post in March 2006.
These RESTful APIs supports a single query of up to 2,048 characters per request. Queries are written with the PowerTrack rule syntax - see Rules and filtering for more details. Users can specify any time period, to the granularity of a minute. However, responses will be limited to the lesser of your specified maxResults OR 31 days and include a next token to paginate for the next set of results. If time parameters are not specified, the API will return matching data from the 30 most recent days. The enterprise search APIs provide low-latency, full-fidelity, query-based access to the Post archive with minute granularity. Post data is served in reverse chronological order, starting with the most recent Post that matches your query. Posts are available from the search API approximately 30 seconds after being published. These search endpoints provide edited Post metadata. All objects for Posts created since September 29, 2022, include Post edit metadata, even if the Post was never edited. Each time a Post is edited, a new Post ID is created. A Post’s edit history is documented by an array of Post IDs, starting with the original ID. These endpoints will always return the most recent edit, along with any edit history. Any Post collected after its 30-minute edit window will represent its final version. To learn more about Edit Post metadata, check out the Edit Posts fundamentals page. Requests include a maxResultsparameter that specifies the maximum number of Posts to return per API response. If more Posts are associated with the query than this maximum amount of results per response, a next token is included in the response. These next tokens are used in subsequent requests to page through the entire set of Posts associated with the query. These enterprise search APIs provide a counts endpoint that enables users to request the data volume associated with their query. 

Request types

The enterprise search APIs support two types of requests:

Search requests (data)

Search requests to the enterprise search APIs allow you to retrieve up to 500 results per response for a given timeframe, with the ability to paginate for additional data. Using the maxResults parameter, you can specify smaller page sizes for display use cases (allowing your user to request more results as needed) or larger page sizes (up to 500) for larger data pulls. The data is delivered in reverse chronological order and compliant at the time of delivery.

Counts requests (Post count)

Counts requests provide the ability to retrieve historical activity counts, which reflect the number of activities that occurred which match a given query during the requested timeframe. The response will essentially provide you with a histogram of counts, bucketed by day, hour, or minute (the default bucket is hour). It’s important to note that counts results do not always reflect compliance events (e.g., Posts deletes) that happen well after (7+ days) a Post is published; therefore, it is expected that the counts metric may not always match that of a data request for the same query. Billing note: each request – including pagination requests – made against the data and counts endpoints are counted as a billed request. Therefore, if there are multiple pages of results for a single query, paging through the X pages of results would equate to X requests for billing.

Available operators

Enterprise search APIs support rules with up to 2,048 characters. The enterprise search APIs support the operators listed below. For detailed descriptions see HERE Notes: Do not embed/nest operators (“#cats”) will resolve to cats with the search APIs.   The ‘lang:’ operator and all ‘is:’ and ‘has:’ operators cannot be used as standalone operators and must be combined with another clause (e.g. @XDevelopers has:links).     Search APIs use a limited set of operators due to tokenization/matching functionality. enterprise real-time and batched historical APIs provide additional operators. See HERE for more details. For more details, please see the Getting started with operators guide.

Data availability / important date

When using the Full-Archive search API, keep in mind that the X platform has continued to evolve since 2006. As new features were added, the underlying JSON objects have had new metadata added to it. For that reason it is important to understand when Post attributes were added that search operators match on. Below are some of the more fundamental ‘born on’ dates of important groups of metadata. To learn more about when Post attributes were first introduced, see this guide.  
  • First Post: 3/21/2006
  • First Native Retweets: 11/6/2009
  • First Geo-tagged Post: 11/19/2009
  • URLs first indexed for filtering: 8/27/2011
  • Enhanced URL expansion metadata (website titles and descriptions): 12/1/2014
  • Profile Geo enrichment metadata and filtering: 2/17/2015

Data Updates and Mutability

With the enterprise search APIs, some of the data within a Post is mutable, i.e. can be updated or changed after initial archival. This mutable data falls into two categories:
  • User object metadata:
    • User’s @handle (numeric ID does not ever change)
    • Bio description
    • Counts: statuses, followers, friends, favorites, lists
    • Profile location
    • Other details such as time zone and language
  • Post statistics - i.e. anything that can be changed on the platform by user actions (examples below):
    • Favorites count
    • Retweet count
In most of these cases, the search APIs will return data as it exists on the platform at query-time, rather than Post generation time. However, in the case of queries using select operators (e.g. from, to, @, is:verified), this may not be the case. Data is updated in our index on a regular basis, with an increased frequency for most recent timeframes. As a result, in some cases, the data returned may not exactly match the current data as displayed on X.com, but matches data at the time it was last indexed. Note, this issue of inconsistency only applies to queries where the operator applies to mutable data. One example is filtering for usernames, and the best workaround would be to use user numeric IDs rather than @handles for these queries.

Single vs. Multi-threaded Requests

Each customer has a defined rate limit for their search endpoint. The default per-minute rate limit for Full-Archive search is 120 requests per minute, for an average of 2 queries per second (QPS). This average QPS means that, in theory, 2 requests can be made of the API every second. Given the pagination feature of the product, if a one-year query has one million Posts associated with it, spread evenly over the year, over 2,000 requests would be required (assuming a ‘maxResults’ of 500) to receive all the data. Assuming it takes two seconds per response, that is 4,000 seconds (or just over an hour) to pull all of that data serially/sequentially through a single thread (1 request per second using the prior response’s “next” token). Not bad! Now consider the situation where twelve parallel threads are used to receive data. Assuming an even distribution of the one million Posts over the one-year period, you could split the requests into twelve parallel threads (multi-threaded) and utilize more of the per-second rate limit for the single “job”. In other words, you could run one thread per-month you are interested in and by doing so, data could be retrieved 12x as fast (or ~6 minutes). This multi-threaded example applies equally well to the counts endpoint. For example, if you wanted to receive Post counts for a two-year period, you could make a single-threaded request and page back through the counts 31 days at a time. Assuming it takes 2 seconds per response, it would take approximately 48 seconds to make the 24 API requests and retrieve the entire set of counts. However, you also have the option to make multiple one-month requests at a time. When making 12 requests per second, the entire set of counts could be retrieved in approximately 2 seconds.

Retry Logic

If you experience a 503 error with the enterprise search APIs, it is likely a transient error and can be resolved by re-trying the request a short time later. If the request fails 4 times in a row, and you have waited at least 10 minutes between failures, use the following steps to troubleshoot:
  • Retry the request after reducing the amount of time it covers. Repeat this down to a 6-hour time window if unsuccessful.
  • If you are ORing a large number of terms together, split them into separate rules and retry each individually.
  • If you are using a large number of exclusions in your rule, reduce the number of negated terms in the rule and retry.

Quick start

Getting started with enterprise Search Posts: 30-Day API

The enterprise Search Posts: 30-Day API provides you with Posts posted within the last 30 days. Posts are matched and sent back to you based on the query you specify in your request. A query is a rule in which you define what the Post you get back should contain. In this tutorial, we will search for Posts originating from the X account @XDevelopers in English. The Posts you get back in your payload can be in a data format, which provides you with the full Post payload, or it can be in a counts format which gives you numerical count data of matched Posts. We will be using cURL to make requests to the data and counts endpoints. You will need the following:

Accessing the data endpoint

The data endpoint will provide us with the full Post payload of matched Posts. We will use the from: and lang: operators to find Posts originating from @XDevelopers in English. For more operators click here.
cURL is a command-line tool for getting or sending files using the URL syntax.Copy the following cURL request into your command line after making changes to the following:
  • Username <USERNAME> e.g. email@domain.com
  • Account name <ACCOUNT-NAME> e.g. john-doe
  • Label <LABEL> e.g. prod
  • fromDate and toDate e.g. "fromDate":"201811010000", "toDate":"201811122359"
After sending your request, you will be prompted for your password.

Data endpoint response payload

The payload you get back from your API request will appear in JSON format, as shown below.

Accessing the counts endpoint

With the counts endpoint, we’ll retrieve the number of Posts originating from the @XDevelopers account in English grouped by day.
cURL is a command-line tool for getting or sending files using the URL syntax.Copy the following cURL request into your command line after making changes to the following:
  • Username <USERNAME> e.g. email@domain.com
  • Account name <ACCOUNT-NAME> e.g. john-doe
  • Label <LABEL> e.g. prod
  • fromDate and toDate e.g. "fromDate":"201811010000", "toDate":"201811122359"
After sending your request, you will be prompted for your password.

Counts endpoint response payload

The payload you get back from your API request will appear in JSON format, as shown below.
Great job! Now you’ve successfully accessed the enterprise Search Posts: 30-Day API.
Referenced articles

Getting started with enterprise Search Posts: Full-Archive API

The enterprise Search Posts: Full-Archive API provides you with Posts since the first one posted in 2006. Posts are matched and sent back to you based on the query you specify in your request. A query is a rule in which you define what the Post you get back should contain. In this tutorial, we will search for Posts originating from the X account @XDevelopers in English. The Posts you get back in your payload can be in a data format, which provides you with the full Post payload, or it can be in a counts format which gives you numerical count data of matched Posts. We will be using cURL to make requests to the data and counts endpoints. You will need the following:

Accessing the data endpoint

The data endpoint will provide us with the full Post payload of matched Posts. We will use the from: and lang: operators to find Posts originating from @XDevelopers in English. For more operators click here.
cURL is a command-line tool for getting or sending files using the URL syntax.Copy the following cURL request into your command line after making changes to the following:
  • Username <USERNAME> e.g. email@domain.com
  • Account name <ACCOUNT-NAME> e.g. john-doe
  • Label <LABEL> e.g. prod
  • fromDate and toDate e.g. "fromDate":"201802010000", "toDate":"201802282359"
After sending your request, you will be prompted for your password.
Data endpoint response payload
The payload you get back from your API request will appear in JSON format, as shown below.

Accessing the counts endpoint

With the counts endpoint, we’ll retrieve the number of Posts originating from the @XDevelopers account in English grouped by day.
cURL is a command-line tool for getting or sending files using the URL syntax.Copy the following cURL request into your command line after making changes to the following:
  • Username <USERNAME> e.g. email@domain.com
  • Account name <ACCOUNT-NAME> e.g. john-doe
  • Label <LABEL> e.g. prod
  • fromDate and toDate e.g. "fromDate":"201802010000", "toDate":"201802282359"
After sending your request, you will be prompted for your password.

Counts endpoint response payload

The payload you get back from your API request will appear in JSON format, as shown below.
Great job! Now you’ve successfully accessed the enterprise Search Posts: Full-Archive API.
Referenced articles

Guides

Building search queries

Enterprise operators

Below is a list of all operators supported in X’s enterprise search APIs:
  • Enterprise 30-day search API
  • Enterprise Full-archive search API
For a side-by-side comparison of available operators by product see HERE.
NOTE: All is: and has: operators cannot be used as standalone operators when using the Search API, and must be combined with another clause.For example, @XDeevelopers has:links

Product overview

The enterprise-tier Full-archive Search was launched in August 2015, and the premium-tier version was launched in February 2018. These search products enable customers to immediately access any publicly available Post. With Full-archive Search you submit a single query and receive a response in classic RESTful fashion. Full-archive Search implements (up to) 500-Posts-per-response pagination, and supports up to a 60-requests-per-minute (rpm) rate-limit for premium, 120 rpm for enterprise. Given these details, Full-archive Search can be used to rapidly retrieve Posts, and at large scale using concurrent requests. Unlike Historical PowerTrack, whose archive is based on a set of Post flat-files on disk, the Full-archive Search Post archive is much like an on-line database. As with all databases, it supports making queries on its contents. It also makes use of an index to enable high-performance data retrieval. With Full-archive search endpoints, the querying language is made up of PowerTrack Operators, and these Operators each correspond to a Post JSON attribute that is indexed. Also, like Historical PowerTrack, there are Post attributes that are current to the time a query is made. For example, if you are using Search API to access a Post posted in 2010 today, the user’s profile description, account ‘home’ location, display name, and Post metrics for Favorites and Retweet counts will be updated to today’s values and not what they were in 2010. 

Metadata timelines

Below is a timeline of when Full-archive search endpoint Operators begin matching. In some cases Operator matching began well after a ‘communication convention’ became commonplace on X. For example, @Replies emerged as a user convention in 2006, but did not become a first-class object or event with ‘supporting’ JSON until early 2007. Accordingly, matching on @Replies in 2006 requires an examination of the Post body, rather than relying on the to: and in_reply_to_status_id: PowerTrack Operators. The details provided here were generated using Full-Archive Search (a product of hundreds of searches). This timeline is not 100% complete or precise. If you identify another filtering/metadata “born on date” fundamental to your use-case, please let us know. Note that the underlying Search index is subject to being rebuilt. Accordingly, these timeline details are subject to change.

2006

  • March 26 - lang:. An example of Post metadata being backfilled while generating the Search index.
  • July 13 - has:mentions begins matching.
  • October 6 - has:symbols. cashtags(orsymbols)fordiscussingstocksymbolsdoesnotbecomecommonuntilearly2009.Untilthenmostusageswereprobablyslang(e.g.,cashtags (or symbols) for discussing stock symbols does not become common until early 2009. Until then most usages were probably slang (e.g., slang).
  • October 26 - has:links begins matching.
  • November 23 - has:hashtags begins matching.

2007

  • January 30 - First first-class @reply (in_reply_to_user_id), reply_to_status_id: begins matching.
  • August 23 - Hashtags emerge as a common convention for organizing topics and conversations. First real use a week later.

2009

  • May 15 - is:retweet. Note that this Operator starts matching with the ‘beta’ release of official Retweets and its “Via @’ pattern. During this beta period, the Post verb is ‘post’ and the original Post is not included in the payload.
  • August 13 - Final version of official Retweets is released with “RT @” pattern, a verb set to ‘share’, and the ‘retweet_status’ attribute containing the original Post (thus approximately doubling the JSON payload size).

2010

  • March 6 - has:geo, bounding_box: and point_radius: geo Operators begin matching.
  • August 28 - has:videos (Until February 2015, this Operator matches on Posts with links to select video hosting sites such as youtube.com, vimeo.com, and vivo.com).

2011

  • July 20 - has:media and has:images begin matching. Native photos officially announced August 9, 2010.

2014

  • December 3 - (Approximately) Some Enhanced URL metadata with HTML title and description begins in payloads. Enhanced metadata more fully emerged in May 2016.

2015

  • February 10 - has:videos matches on ‘native’ X videos.
  • February 17 - has:profile_geo, profile_country:, profile_region:, profile_locality: Profile Geo Operators begin matching.
  • February 17 - place_country: and place: Post geo Operators begin matching.

2016

2017

  • February 22 - Poll metadata become available in enriched native format. No associated Operators for these metadata.

2022

  • September 27 - All Post objects created since this date have Edited Post metadata available. All Enterprise endpoints that provide Post objects were updated to provide this metadata starting on this date. The edit metadata provided includes edit_history and edit_controls objects. These metadata will not be returned for Posts that were created before September 27, 2022. Currently, there are no Enterprise Operators available that match these metadata.  To learn more about Edit Post metadata, check out the Edit Posts fundamentals page.

2022

  • September 29 - All Post objects created since this date have Edited Post metadata available. All Enterprise endpoints that provide Post objects were updated to provide this metadata starting on this date. The edit metadata provided includes edit_history and edit_controls objects. These metadata will not be returned for Posts that were created before September 27, 2022. Currently, there are no Enterprise Operators available matching these metadata.  To learn more about Edit Post metadata, check out the Edit Posts fundamentals page.

Filtering tips

Given all the above timeline information, it is clear that there are a lot of details to consider when writing Search APIs filters. There are two key things to consider:
  • Some metadata have ‘born-on’ dates so filters can result in false negatives. Such searches include Operators reliant on metadata that did not exist for all of part of the search period. For example, if you are searching for Posts with the has:images Operator, you will not have any matches for periods before July 2011. That is because that Operator matches on native photos (attached to a Post using the X user-interface). For a more complete data set of photo-sharing Posts, filters for before July 2011 would need to contain rule clauses that match on common URLs for photo hosting.
  • Some metadata has been backfilled with metadata from a time after the X was posted.
There are several attribute types that are commonly focused on when creating PowerTrack queries:
  • X Profiles
  • Original or shared Posts
  • Post language classification
  • Geo-referencing Posts
  • Shared links media
Some of these have product-specific behavior while others have identical behavior. See below for more details.

X Profiles

The Search APIs serves historical Posts with the user profile data set as it is at the time of retrieval. If you request a Post from 2014, the user’s profile metadata will reflect how it exists at query-time.

Original Posts and Retweets

The PowerTrack _is:retweet_ Operator enables users to either include or exclude Retweets. Users of this Operator need to have two strategies for Retweet matching (or not matching) for data before August 2009. Before August 2009, the Post message itself needs to be checked, using exact phrase matching, for matches on the “@RT ” pattern (Actually, if you are filtering on Retweets from between May-August 2009, the “Via @” pattern should be included). For periods after August 2009, the is:retweet Operator is available.

Post language classifications

For filtering on a Post’s language classification, X’s historical products are quite different. When the Search archive was built, all Posts were backfilled with the X language classification. Therefore the lang: Operator is available for the entire Post archive.

Geo-referencing Posts

There are three primary ways to geo-reference Posts:
  • Geographical references in Post message. Matching on geographic references in the Post message, while often the most challenging method since it depends on local knowledge, is an option for the entire Post archive. Here is an example geo-referenced match from 2006 for the San Francisco area based on a ‘golden gate’ filter.
  • Posts geo-tagged by the user. With the search APIs the ability to start matching on Posts with some Geo Operators started in March 2010, and with others in February 2015:
    • March 6, 2010: has:geo, bounding_box: and point_radius:
    • February 17, 2015: place_country: and place:
  • Account profile ‘home’ location set by the user. Profile Geo Operators are available in both Historical PowerTrack and the Search APIs. With the Search APIs, these Profile Geo metadata is available starting in February 2015. For Posts posted before Profile Geo metadata became available, the bio_location: Operator is available which can be used to match on non-normalized user input.
In March 2012, the expanded URL enrichment was introduced. Before this time, the Post payloads included only the URL as provided by the user. So, if the user included a shortened URL it can be challenging to match on (expanded) URLs of interest. With the Search APIs, these metadata are available starting in March 2012. In July 2016, the enhanced URL enrichment was introduced. This enhanced version provides a web site’s HTML title and description in the Post payload, along with Operators for matching on those. These metadata begin emerging in December 2014. In September 2016 X introduced ‘native attachments’ where a trailing shared link is not counted against the 140 Post character limit. Both URL enrichments still apply to these shared links. Here are when related Search Operators begin matching:
  • 2006 October 26 - has:links
  • 2011 July 20 - has:images and has:media
  • 2011 August - url: with the Expanded URLs enrichment As early as September 2006 (url:"spotify.com" OR url:gnip OR url:microsoft OR url:google OR url:youtube) matches http://x.com/Adam/statuses/16602, even though there is no urls[] metadata in twitter_entities and gnip objects. “youtube.com” is an example of message content that, without any urls[] metadata, matches url:youtube.
  • 2015 February 10 - has:videos for native videos. Between 2010/08/28 and 2015/02/10, this Operator matches on Posts with links to select video hosting sites such as youtube.com, vimeo.com, and vivo.com.
  • 2016 May 1 - url_title: and url_description:, based on the Enhanced URLs enrichment, generally available. First Enhanced URL metadata began appearing in December 2014.

Frequently asked questions(FAQ)

General Search Post API questions

There is a known difference between results provided by the counts endpoint and the data endpoint. You may see a discrepancy in your results because the counts endpoint is pre-compliance (meaning that it does not account for things like deleted Posts, scrub geo, etc.) whereas the data endpoint is compliant at the time of delivery and accounts for all compliance events.
There are a few different reasons why this might have happened, including
  1. the Post you expected to see is from a protected account
  2. because the data endpoint accounts for all compliance events (meaning that deleted Posts, scrubbed geos, etc. will not be included in the response).
This is likely due to a wrong usage of our premium rules & filtering. Please review our documentation here and ensure you understand the restrictions around building rules.
Yes, there are, including:
  • Tweepy - good for using the standard search/Posts product (Python)
  • X API - good for using the standard Search Post APIs (Python)
  • Search Posts Python and Search Posts Ruby - two good tools that can be used for enterprise (and v2!) Search Post APIs
All of the libraries that we directly support can be found on our xdevplatform GitHub page: https://github.com/xdevplatform.There are other third-party libraries that may also be helpful; however, please note that some of these may not work with our premium and enterprise products.
Yes. Our data endpoint paginates at either the specified maxResults or after 30 days.For example, if you have 800 Posts in a given 30 day period, you will have to make two requests to pull the complete results; because the maximum number of Posts that can be returned per request is 500 (maxResults). And if you just have 400 Posts in month one, and then 100 Posts in month two, you will also have to use two requests to pull the full results; because pagination takes place after a period of 30 days even if the first request returns less than the specified maxResults Posts.
Posts are returned in reverse chronological order. For example, the first page of results will show the most recent Posts that match the query, pagination will continue until the results posted dates get to the fromDate initially requested.
Only the original Post will count for billing purposes. Any subsequent edits will be ignored and not contribute to your overall activity count. Enterprise
Our enterprise solutions are customized with predictable pricing to meet the needs of your business. Please apply here for more information.
  • Please refer to our enterprise Search Post APIs documentation here
  • Useful information on rules and filering can be found here
  • Useful information for using the data endpoint can be found here
  • Useful information for using the counts endpoint can be found here
  • A list of available operators can be found here
Please get in touch with your Account Manager at X who will be able to help you with this.

Error troubleshooting guide

Code 404 - Not Found
  1. Please ensure you are using the right parameters for each endpoint (e.g. the bucketsfield can only be used with the counts endpoint, not the data endpoint)
  2. Please double check the :product :account_name and :label fields are correct. You can find your :label field in the GNIP Console (enterprise customers only).

API Reference

Enterprise search APIs

There are two enterprise search APIs:
  • 30-Day Search API - provides Tweets posted with the last 30 days.
  • Full-Archive Search API - provides Tweets from as early as 2006, starting with the first Tweet posted in March 2006.
These search APIs share a common design and the documentation below applies to both. Note that for Tweets created starting September 29, 2022, Tweet objects will include Tweet edit metadata that describes its edit history. See the “Edit Tweets” fundamentals page for more details. Below you will find important details needed when integrating with the enterprise search APIs:
  • Methods for requesting Tweet data and counts
  • Authentication
  • Pagination
  • API request parameters and example requests
  • API response JSON payloads and example responses
  • HTTP response codes
The enterprise APIs provide low-latency, full-fidelity, query-based access to the Tweet archive. The only difference in the two APIs is the time frame you can search, either the previous 30 days or from as early as 2006. Time frames can be specified with minute granularity. Tweet data is served in reverse chronological order, starting with the most recent Tweet that matches your query. Tweets are available from the search API approximately 30 seconds after being published.

Methods

The base URI for enterprise search is https://gnip-api.x.com/search/. Where:
  • :product indicates the search endpoint you are making requests to, either 30day or fullarchive.
  • :account_name is the (case-sensitive) name associated with your account, as displayed at console.gnip.com
  • :label is the (case-sensitive) label associated with your search endpoint, as displayed at console.gnip.com
For example, if the TwitterDev account has the 30-Day search product with a label of ‘prod’ (short for production), the search endpoints would be: Your complete enterprise search API endpoint is displayed at https://console.gnip.com. Below there are several example requests using a simple HTTP utility called curl. These examples use URLs with :product, :account_name, and :label. To use these examples, be sure to update the URLs with your details.

Authentication

All requests to the enterprise search APIs must use HTTP Basic Authentication, constructed from a valid email address and password combination used to log into your account at https://console.gnip.com. Credentials must be passed as the Authorization header for each request.

Request/response behavior

Using the fromDate and toDate parameters, you can request any time period that the API supports. The 30-Day search API provides Tweets from the most recent 31 days (even though referred to as the ‘30-Day’ API, it makes 31 days available to enable users to make complete-month requests). The Full-Archive search API provides Tweets back to the very first tweet (March 21, 2006). However, a single response will be limited to the lesser of your specified ‘maxResults’ or 31 days. If matching data or your time range exceeds your specified maxResults or 31 days, you will receive a ‘next’ token which you should use to paginate through the remainder of your specified time range. For example, say you are using Full-Archive search and want all Tweets matching your query from January 1, 2017 to June 30, 2017. You will specify that full six-month time period in your request using the fromDate and toDate parameters. The search API will respond with the first ‘page’ of Tweets, with the number of Tweets matching your maxResults parameter (which defaults to 100). Assuming there are more Tweets (and there most likely will be more), the API will also provide a ‘next’ token that enables you to make a request for the next ‘page’ of data. This process is repeated until the API does not return a ‘next’ token. See the next section for more details.

Pagination

When making both data and count requests it is likely that there is more data than can be returned in a single response. When that is the case the response will include a ‘next’ token. The ‘next’ token is provided as a root-level JSON attribute. Whenever a ‘next’ token is provided, there is additional data to retrieve so you will need to keep making API requests. Note: The ‘next’ token behavior differs slightly for data and counts requests, and both are described below with example responses provided in the API Reference section.
Data pagination
Requests for data will likely generate more data than can be returned in a single response. Each data request includes a parameter that sets the maximum number of Tweets to return per request. This maxResults parameter defaults to 100 and can be set to a range of 10-500. If your query matches more Tweets than the ‘maxResults’ parameter used in the request, the response will include a ‘next’ token (as a root-level JSON attribute). This ‘next’ token is used in the subsequent request to retrieve the next portion of the matching Tweets for that query (i.e. the next ‘page”). Next tokens will continue to be provided until you have reached the last ‘page’ of results for that query when no ‘next’ token is provided. To request the next ‘page’ of data, you must make the exact same query as the original, including query, toDate, and fromDate parameters, if used, and also include a ‘next’ request parameter set to the value from the previous response. This can be utilized with either a GET or POST request. However, the ‘next’ parameter must be URL encoded in the case of a GET request. You can continue to pass in the ‘next’ element from your previous query until you have received all Tweets from the time period covered by your query. When you receive a response that does not include a ‘next’ element, it means that you have reached the last page and no additional data is available for the specified query and time range.
Counts pagination
The ‘counts’ endpoint provides Tweet volumes associated with a query on either a daily, hourly, or per-minute basis. The ‘counts’ API endpoint will return a timestamped array of counts for a maximum of a 31-day payload of counts. If you request more than 31 days of counts you will be provided a ‘next’ token. As with the data ‘next’ tokens, you must make the exact same query as the original and also include a ‘next’ request parameter set to the value from the previous response. Beyond requesting more than 31 days of counts, there is another scenario when a ‘next’ token is provided. For higher volume queries, there is the potential that the generation of counts will take long enough to trigger a response timeout. When this occurs you will receive less than 31 days of counts but will be provided a ‘next’ token in order to continue making requests for the entire payload of counts. Important: Timeouts will only issue full “buckets” - so 2.5 days would result in 2 full day “buckets”.
Additional notes
  • When using a fromDate or toDate in a search request, you will only get results from within your time range. When you reach the last group of results within your time range, you will not receive a ‘next’ token.
  • The ‘next’ element can be used with any maxResults value between 10-500 (with a default value of 100). The maxResults determines how many Tweets are returned in each response, but does not prevent you from eventually getting all results.
  • The ‘next’ element does not expire. Multiple requests using the same ‘next’ query will receive the same results, regardless of when the request is made.
  • When paging through results using the ‘next’ parameter, you may encounter duplicates at the edges of the query. Your application should be tolerant of these.

Data endpoint

POST /search/:product/:label
Endpoint pattern:
This endpoint returns data for the specified query and time period. If a time period is not specified the time parameters will default to the last 30 days. Note: This functionality can also be accomplished using a GET request, instead of a POST, by encoding the parameters described below into the URL.
Data request parameters
Additional details
Example data requests and responses
Example POST request
  • Request parameters in a POST request are sent via a JSON-formatted body, as shown below.
  • All portions of the PowerTrack rule being queried for (e.g. keywords, other operators like bounding_box:) should be placed in the ‘query’ parameter.
  • Do not split portions of the rule out as separate parameters in the query URL.
Here is an example POST (using cURL) command for making an initial data request:
If the API data response includes a ‘next’ token, below is a subsequent request that consists of the original request, with the ‘next’ parameter set to the provided token:
Example GET request
  • Request parameters in a GET request are encoded into the URL, using standard URL encoding.
  • All portions of the PowerTrack rule being queried for (e.g. keywords, other operators like bounding_box:) should be placed in the ‘query’ parameter.
  • Do not split portions of the rule out as separate parameters in the query URL.
Here is an example GET (using cURL) command for making an initial data request:
Example data responses
Note that for Tweets created starting September 29, 2022, Tweet objects will include Tweet edit metadata that describes its edit history. See the “Edit Tweets” fundamentals page for more details. Below is an example response to a data query. This example assumes that there were more than ‘maxResults’ Tweets available so a ‘next’ token is provided for subsequent requests. If ‘maxResults’ or fewer Tweets are associated with your query, no ‘next’ token would be included in the response. The value of the ‘next’ element will change with each query and should be treated as an opaque string. The ‘next’ element will look like the following in the response body:
The response to a subsequent request might look like the following (note the new Tweets and different ‘next’ value):
You can continue to pass in the ‘next’ element from your previous query until you have received all Tweets from the time period covered by your query. When you receive a response that does not include a ‘next’ element, it means that you have reached the last page and no additional data is available in your time range.

Counts endpoint

/search/:stream/counts
Endpoint pattern:
/search/fullarchive/accounts/:account_name/:label/counts.json This endpoint returns counts (data volumes) data for the specified query. If a time period is not specified the time parameters will default to the last 30 days. Data volumes are returned as a timestamped array on either daily, hourly (default), or by the minute. Note: This functionality can also be accomplished using a GET request, instead of a POST, by encoding the parameters described below into the URL.
Counts request parameters
Additional details
Example counts requests and responses
Example POST request
  • Request parameters in a POST request are sent via a JSON-formatted body, as shown below.
  • All portions of the PowerTrack rule being queried for (e.g. keywords, other operators like bounding_box:) should be placed in the ‘query’ parameter.
  • Do not split portions of the rule out as separate parameters in the query URL.
Here is an example POST (using cURL) command for making an initial counts request:
If the API counts response includes a ‘next’ token, below is a subsequent request that consists of the original request, with the ‘next’ parameter set to the provided token:
Example GET request
  • Request parameters in a GET request are encoded into the URL, using standard URL encoding
  • All portions of the PowerTrack rule being queried for (e.g. keywords, other operators like bounding_box:) should be placed in the ‘query’ parameter
  • Do not split portions of the rule out as separate parameters in the query URL
Here is an example GET (using cURL) command for making an initial counts request:

Example counts responses

Below is an example response to a counts (data volume) query. This example response includes a ‘next’ token, meaning the counts request was for more than 31 days, or that the submitted query had a large enough volume associated with it to trigger a partial response. The value of the ‘next’ element will change with each query and should be treated as an opaque string. The ‘next’ element will look like the following in the response body:
The response to a subsequent request might look like the following (note the new counts timeline and different ‘next’ value):
You can continue to pass in the ‘next’ element from your previous query until you have received all counts from the query time period. When you receive a response that does not include a ‘next’ element, it means that you have reached the last page and no additional counts are available in your time range.

HTTP response codes