DatAfrik Blog

Register now for the  October, 7th  Data BootCamp!

In order to create a tweet, you need a Twitter account. However, I’m not talking about the normal Twitter account you have logged in on your Twitter app, I’m talking about a Developer Account that allows you create tweets using code instead of the app’s GUI. You need a Developer Account to be able to access the Twitter API and create tweets using Python. Good news is, it’s an extension of your normal Twitter account and you can apply for a Developer Account within a couple of minutes here. Once the page opens:

  • scroll down and click on the FREE access,
  • log into your normal Twitter account,
  • apply for a Developer Account by filling a short form,
  • click submit.

After clicking Submit, it automatically creates a Developer Account for you and takes you to the Developer Portal.

To the left of the Developer Portal, you’d find Projects & Apps. Projects allow you to organize your work based on how you intend to use the Twitter API so you can effectively manage your access to the API and monitor your usage. Each Project can contain one or multiple Apps depending on your access level. You will use these Apps to generate authentication credentials such as API Keys and Secrets, user Access Tokens, and App Access Token.

Since you can only afford the FREE access, you shouldn’t bother yourself with all the technical jargons that surround Projects, and Apps. All you need to know is that you’re entitled to only 1 Project and 1 App. So, let’s create a Project and an App. To do this, you can just edit the default Project name and the App name.

We’d change the Project name from ‘Default project-1766250805760339968’ to ‘Twitter Project’ by clicking on the Project then clicking on Settings. We can also change the App name to a unique name such as ‘Creating A Tweet App’. Now that we have the Project and App names out of the way we need to get our Keys and Secrets. These will allow us connect our account to the API using Tweepy.

Before getting to the keys and secrets part, we need one final detail. Click on the Settings icon and click to edit the User authentication settings. Change the app permission from read to read and write and direct message, leave type of app as native app. Finally in the app info section, input the link to your profile as the callback url and website url. Then save.

Keys & Secrets

There are a couple of weird looking strings you need in order to be able to authenticate your app and have access to the Twitter API using your account. I won’t bore you with the technicalities but just for the sake of it, these are the different ‘weird looking strings’ you’d need:

  • API Key and Secret: Essentially the username and password for your App. You will use these to authenticate requests that require OAuth 1.0a User Context, or to generate other tokens such as user Access Tokens or App Access Token.
  • Access Token and Secret: In general, Access Tokens represent the user that you are making the request on behalf of. The ones that you can generate via the developer portal represent the user that owns the App.`

These Keys, Tokens, and Secrets are very necessary as you’d see in the other articles when we use them alongside the Tweepy library. You need to get them and store them securely. Exposing them can enable others have access to your Twitter account.

We firstly need to get the API key and Secret. We do this, by clicking on the app we created earlier on the left called ‘Creating A Tweet App’ and then selecting Keys and Tokens. This will show a page that contains the different secret weird strings we need. We need the Consumer Keys and Authentication Tokens, so click on the regenerate and generate keys to get them and save them securely. We’ll be using them in another article with the Tweepy API to write a tweet programmatically.

 

 

 

By James Gabriel

SENIOR DATA ANALYST, WITH OVER 5 YEARS OF EXPERIENCE IN THE AUTOMOBILE, RETAIL, TECH AND EDUCATION INDUSTRIES. POSSESS EXTENSIVE EXPERIENCE IN BUSINESS AND PEOPLE ANALYTICS WITH PROFICIENCY IN PYTHON, R, TABLEAU, POWER BI, AND ALL DIALECTS OF SQL. WHEN I'M NOT GENERATING INSIGHTS FROM BIG DATA, I'M TUTORING AND MENTORING A GROUP OF PROFESSIONAL DATA ANALYSTS.

One thought on “Getting a Twitter Developer Account”

Leave a Reply

Your email address will not be published. Required fields are marked *