Generate your keys and tokens for the Twitter API

Before you create a Twitter bot, you first need to generate all the required keys and tokens.

Table of contents

Step 1: Head over to the Twitter Developer Platform

You will first need a regular Twitter account. Once you have one, you can go to the Twitter Developer Platform.

Once there, click on the Developer Portal button next to your image at the top right hand corner.

Developer Portal

Twitter may prompt you to have a valid email and/or phone number on your account. It may also ask you why you want to use the Twitter API, you can just enter 'exploring the API'. Enter these in. You should eventually arrive at this page.

Welcome to the Twitter Developer Platform

Enter a name for your application, and click Get Keys. You should be shown a page similar to this, with an API key, API key secret, and Bearer Token. Copy them all into a safe place. Then click Dashboard.

API keys and bearer token

Step 2: Set up user authentication settings

On the dashboard, click the cog icon under Project App.

Click the cog icon

Then click on Set Up, under User Authentication Settings.

User Authentication Settings

This will take you to a page where we can change a number of settings. Under App permissions, we will select Read and Write, under Type of App we will select Web App, Automated App or Bot.

Set read and write and type of app

Under the callback URI, enter, which is essentially http://localhost:3000, and finally, enter your/any website URL. Then click Save.

Enter callback url and website

Step 3: Generate Access Token and Secret

Click on the Keys and tokens tab.

Keys and tokens

Once there, click on the Generate button for Access Token and Secret. In the image below, it says Regenerate, this is because I had previously generated keys.

Generate access token and secret

This will generate your Access Token and Access Token Secret. Save these in a safe place.

Once you have done this, the message below the Access Token and Secret should say Created with Read and Write permissions. If it doesn't, this means that you did not click Read and Write in step 2.

Read and write access

Now you should be done! You should have a API Key, API Key Secret, Bearer Token, Access Token and Access Token Secret.

You would have also generated a Client ID and Client Secret. You will not need these for the following tutorials on creating twitter bots.

Image of the Author, Ryan Carmody

About the Author

Open for work

Hi, I'm Ryan from Adelaide, South Australia.

I'm a web developer and computer science tutor. I also rock climb, play wheelchair basketball and brew beer.

Check out some of the games I made

Smug Chicken

Smug Chicken

The daily AI art word game.



How does google autocomplete this search?



Guess the country from a photo.

Retro Snake Game

Retro Snake

Eat the food but don't hit the walls or your own body!