Using the Twitter API
The Twitter API can be used to programmatically retrieve and analyze data, as well as engage with the conversation on Twitter.
This API provides access to a variety of different resources including the following:
- Direct Messages
The Twitter API currently consists of two supported versions, as well as different access tiers. We have listed these below to help you better understand which version and tiers are available, but would recommend using the newest versions (Twitter API v2) where available. Learn more about our new versioning strategy.
|Version / tier||Description|
|Twitter API v2: Early Access||
We are providing Early Access to our new v2 endpoints, which include the following:
We are also introducing several new features with this new version, including the following:
The legacy standard endpoints provide access to the following resources with the standard v1.1 offerings.
We will eventually release Twitter API v2 equivalents for most of the currently available endpoints. To learn more about Twitter API v2: Early Access, visit one of the following resources:
- Migration hub for how to upgrade your current v1.1 endpoints to v2
- Guide to the future of the Twitter API
- Tutorials on how to build with Twitter API v2
How to get access to the Twitter API
Step one: Apply and receive approval for a developer account
To make any request to the Twitter API, you must first apply for a developer account and have your use case approved.
You can choose to apply for the Standard or Academic Research product tracks, which offer tailored support, access levels, and pricing.
- Standard - The default product track for most developers, including those building something for fun, for a good cause, to learn or teach. All approved developers will be able to create and use a Standard Project.
- Academic Research - This product track provides qualified academic researchers access to elevated access and enhanced functionality, including access to the full-archive search endpoint, a higher monthly Tweet cap, and enhanced filtering capabilities with the filtered stream and recent search endpoints.
Once approved, you can create a Standard or Academic Research Project and an associated developer App which will provide you a set of credentials that you will use to authenticate all requests to the API.
We require an approved use case to use the Twitter API to protect the people that use Twitter. Before you apply, we strongly encourage you to understand our developer policy, and to review our list of restricted use cases. If your use case does not adhere to our policy, we will reject your application.
Please note: We launched a new developer portal experience in July 2020. If you have a developer account that was created before then, you can opt into this new portal experience and create a Project and App to access the Twitter API v2 endpoints and features.
For developers with Twitter Apps pre-dating July 2018, note that an approved developer account is required to utilize Twitter API v2 endpoints, as well as Twitter Developer Labs. Once your developer account is approved, your Apps will be listed in the new developer portal under Standalone Apps.
Step two: Save your App's key and tokens and keep them secure
Within your developer App, you will be provided a set of API Keys (also known as Consumer Keys). You will also have the chance to generate a set of Access Tokens that can be used to make requests on behalf of your personal Twitter account, and a Bearer Token that can be used to authenticate endpoints that require OAuth 2.0 Bearer Token. Since these keys and tokens do not expire unless regenerated, we suggest creating environment variables or using a secure password manager.
Please note: Your keys and tokens will only display once in the developer portal, so it is important that you store these credentials in your password management system as soon as you generate them.
If you misplace or forget the keys and tokens, you will need to regenerate them, which creates new credentials and invalidates the old ones. This means that you will have to update any integrations that you may have set up with your prior credentials.
Learn more about our authentication best practices.
Step three: Set up your access
At this point in time, there are a few different access tiers across two different versions of Twitter API endpoints that require different provisioning and authentication methods. Please see the below table for more details on how to get access to the different tiers and versions:
|Version or tier||Provisioning method|
|Twitter API v2: Early Access||
You must have an approved developer account, and have activated the new developer portal experience.
Want to use an existing App?
You can add an existing App to your new Project. Keep in mind that you may only have one primary or production App per approved use case. See our Developer Policy for more information, including guidelines around additional apps for development or testing.
To create a new developer App, you must have an approved developer account.
To access, you must authenticate your requests with keys and tokens from a developer App that is assigned to a premium dev environment. You can do all of this from the developer portal. The level of access is determined by the monthly subscription level tier.
To use premium, You must have an approved developer account.
To access, you must have an approved enterprise data licensing contract and set up by a sales representative. The level of access is determined by the contract and account terms.
Step five: Make your first request
Once you have access, you’re ready to get started using the Twitter API! We have quick start guides for many of our endpoints, useful tools and libraries and sample code, and the following tutorials that describe how to build solutions around different use cases:
Check out our full list of tutorials.