Now that we have the basic setup in our file, it’s time to start retrieving some data from Twitter.

Before we can interact with the Twitter API, we need to authenticate with the Twitter API. To do this, make sure you have your Twitter credentials handy:

  1. Start by navigating to https://apps.twitter.com (make sure you are logged in to Twitter, or create an account first)
  2. Click on “Create New App”
  3. Fill out the “Application Details”
  4. Navigate to the “Keys and Access Tokens” tab
  5. Take note of your Consumer Key (API Key) and Consumer Secret (API Secret)
  6. Click on “Create my access token” under “Token Actions” at the bottom of the page
  7. Take note of your Access Token and Access Token Secret

Once you have the credentials, add them to the correct variables in the following lines of code:

twitter_consumer_key = '' twitter_consumer_secret = '' twitter_access_token = '' twitter_access_secret = ''

These credentials will allow us to call the Twitter API using the Twitter package we imported earlier.


Add your Twitter credentials to CelebrityMatch.py. Make sure you add them to the correct variables.

twitter_consumer_key = '' twitter_consumer_secret = '' twitter_access_token = '' twitter_access_secret = ''

Note: Remember, without Twitter credentials, your Watson-powered application will not work. If you don’t have a Twitter account, first create one and then retrieve your credentials.

Click Run to save your code, then click Next to continue.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?