To use the Twitter API, you need to create a Twitter App and get your credentials for the app.
Your credentials are essentially the username and password of your API application.
This tutorial is part of the complete guide on the Twitter API with Python.
Getting Started
Before you can create your app, you will need to Apply for a Twitter Developer Account.
Create Your Twitter API Project
Once approved, go to the Twitter Developer Portal and click on create project.

Name your project.

Fill the “Which best describes you?” box.

Fill-in the “Describe your new project box”.
I am creating a bot that shares my favorite wikipedia articles, blog posts from my favorite authors and like randomly posts from my favorite Twitter users.
Name your application with a name no-one ever gave before.

Complete your form
Get Your Twitter API Keys
Now, you can use these API keys to build your Twitter App.
Make sure that you keep these secret and delete them once in a while.

Get Your Access Token and Secret
To use Tweepy, you will also need your access token and secrets.
Go to Projects & Apps > Your Project > Your App > Generate Access Token and Secret.

Set Permissions to Read + Post
To be able to post to Twitter, you will need the read and write access.
Go to Projects & Apps > <PROJECT_NAME>
> <APP_NAME>
> App permissions.
If it is not set to Read + Post Tweets and profile information, click on Edit.

Edit the application permissions for your need.

What are the API Credentials?
API key
Your API key is like your username. It is used to verify who you are to Twitter.
API Secret Key
Your secret key is used like a password. It identifies your account. Keep this safe!
Bearer Token
The bearer token is an Access Token used in authentication that allows you to pull specific data.
Bearer Tokens are used to in HTTP requests to access OAuth 2.0 protected resources.
Think of it as the authenticated credentials. To better understand Bearer tokens, you can imagine that it is like when cookies remember your username and password to keep you logged-in to Twitter.
Adding the bearer token to your API call will let you skip the authentication of your Application.
Conclusion
Now, we have our Twitter API credentials:
- api_key
- api_secret
- access_token
- access_secret
You will need them to run your first Twitter API call with Python.

SEO Strategist at Tripadvisor, ex- Seek (Melbourne, Australia). Specialized in technical SEO. Writer in Python, Information Retrieval, SEO and machine learning. Guest author at SearchEngineJournal, SearchEngineLand and OnCrawl.