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 on Twitter API v1.1.
We will eventually release Twitter API v2 equivalents for most of the currently available endpoints. To learn more about the enw version, visit one of the following resources:
- Twitter API v2 migration resources
- 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. Once approved, you can create a Project and connect 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, authentication and App authorization from Twitter users when making OAuth 1.0a User Context, 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 an existing developer account, 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. As 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 keys and tokens, 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. Until January 2021, you can retrieve an App’s key and tokens through the developer portal.
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.
To access this version, you must authenticate your requests with keys and tokens generated from a developer App that is attached to a Project. You can create a project and App in the developer portal.
Want to use an existing App instead?
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.
Access is available with active keys and tokens for any active developer App.
To create a new developer App, you must have an approved developer account.
Access is available with active keys and tokens for a developer App, set up for a dev environment for a premium subscription endpoint. The level of access is determined by the monthly subscription level tier.
To use premium, You must have an approved developer account.
Access is available with 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, several useful tools and libraries, and the following tutorials that describe how to build solutions around different use cases:
Check out our full list of tutorials.