The Twitter API
Updated
May 14, 2021
To collect data from Twitter, you need to have keys to the Twitter API. API documentation can be overtly technical and confusing to even experienced developers. Twitter's API is comparatively easy to navigate - once you know how.
This guide will walk through the process of accessing the keys required to authenticate your requests for data from Twitter. Ultimately, you want to finish this guide with four keys in hand; a API key, an API secret key, an Access token and an Access token secret. These are the codes that gain you access to collecting Twitter data using whichever method you prefer. To do this, you need to create a Twitter developers account and a Twitter app (it's not as complicated as it sounds).
"An API that isn't comprehensible isn't usable."
- James Gosling
After you have retrieved your keys, you are good to go! We've written this follow-up guide and notebook to help you collect tweets using the Twitter API. If you already have the keys, you should head straight over there.
Creating a Twitter Developers Account
To access the Twitter API, you need a Twitter account and a Twitter developers account. A developers account gives you a set of tools to start creating and managing projects that request data from Twitter.
In order to get a developers account you need to tell Twitter about yourself and your intentions for the account. Twitter will then review and approve your application. Give thoughtful and concise answers and they will normally get back to you pretty quickly. Sign up for a developers account here.

How to Create a Developer Account with Twitter?
- Start here.
- Click 'Apply for developers account'.
- Select 'Hobbyist' or whichever category suits you best. We will use 'Hobbyist'.
- Select 'Exploring the API' and then 'Get Started'.
- Complete the text fields on the 'Basic info' form and select 'Next'.
- Inside the 'Intended use' form, Twitter requires some detailed information from you regarding how you intend to use their API. Take your time and fill in each text box thoroughly. When you are finished, click 'Next'.
- Inside the 'Review' form, review the information you've just provided.
- Inside the 'Terms' form, check over the terms of use and tick the checkbox.
- Select 'Submit Application'.
- Done ... Twitter will review your application and get back to you.
Once your developer's account has been approved you can create an app giving you access to the keys required to start making requests. Head over to the 'Developer Portal' to start creating an app.
Creating a Twitter Developer App
Twitter apps aren't necessarily apps in the way that we understand them. They are the entity that you use to request data from Twitter but they don't have to have a fancy UI or in fact any UI at all. In reality, they are just a way of telling Twitter where your request is coming from. It's important to remember that apps are not the same thing as projects.
You want to create an app, not a project. Make sure your developer account has been approved and then start creating an app.

How to Create a Twitter App?
- Start here.
- Click 'Developer Portal' from the top menu.
- Select 'Overview' within the 'Projects & Apps' dropdown from the sidebar of your Twitter developer dashboard.
- Under 'Standalone Apps', click 'Create App'.
- Enter a name for your app.
- Select 'Complete'.
- Done ... Twitter will now present you with your API key and your API secret key. Make a note of these!
The Keys
Now that you have a developers account and have created an app using it, you should have access to all of the keys you need to start retrieving data from the Twitter API. If you didn't collect your API key and API secret key as you created the app, head over to your app's Keys and Tokens window to regenerate them.
It's important to remember that once you regenerate keys for an app, every instance of these keys will change. If you build projects using the old keys, you'll need to change everything over so that your requests are made using the new keys.
As well as the API key and the API secret key, you need to make a note of your Access token and Access token secret. You should see a way to regenerate these inside of your app's Keys and Tokens window. The same regeneration rules apply.

How to Find Twitter API Keys?
- Start from inside of your Twitter developer portal.
- Navigate to the app you just created using the left sidebar.
- Switch to the Keys and Tokens window inside of the app.
- Regenerate your API key and API secret key using the button under the Consumer Keys section.
- Make a note of these.
- Regenerate your Access token and Access token secret using the button under the Authentication Tokens section.
- Make a note of these.
- Done ... You are ready to start collecting data from Twitter
Now that you've got these keys, it is time to start putting them to use. We've written a guide on collecting tweets here and provided all of the code you need to do it inside of the guide. Don't forget your keys!
Need Something Different?
We know that data isn't always clean and simple.
Have a look through these topics if you can't see what you are looking for.