Learn
Using the Twitter API
Querying Twitter I

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)

Instructions

1.

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.

Folder Icon

Take this course for free

Already have an account?