To interact with the Twitter API, we first need to create an instance of the Twitter package we imported earlier.

We can do this by calling the .Api() method on the twitter package and setting it equal to a variable, like twitter_api. The function also takes the four credentials you retrieved earlier as arguments, like so:

twitter_api = twitter.Api(consumer_key=twitter_consumer_key, consumer_secret=twitter_consumer_secret, access_token_key=twitter_access_token, access_token_secret=twitter_access_secret)



Call the .Api() method on the twitter package and make sure to pass in the four credentials. Store the result in a variable called twitter_api. Use the example above to help you.

Click Run to save your code.

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?