Using the Twitter API
Lesson 1 of 1
  1. 1
    In this unit, we’ll begin writing code for the Celebrity Match application. We’ll start by using the Twitter API to retrieve tweets from two different Twitter users and compare them. Twitter …
  2. 2
    Before we can interact with the Twitter API, we’ll need to import the following Python packages: * sys - a basic interpreter that can handle low level functions of the computer’s operating system….
  3. 3
    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 d…
  4. 4
    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…
  5. 5
    Great! But to retrieve data from Twitter, we need to make an actual call to the API. So far, we’ve only created the object (twitter_api)that represents the Twitter API we’ll interact with. To ma…
  6. 6
    We’ve done a lot of work, but we still haven’t seen any data from Twitter. Let’s fix that! The GetUserTimeline() method returns will return data from Twitter in the form of a Python list , so we …
  7. 7
    The data we retrieve from Twitter doesn’t include just tweets, it also contains a lot of metadata . Unfortunately, the metadata contains information that we won’t use (i.e., when the tweet was c…
  8. 8
    Great! Now that we have the text we need, it’s time to prepare it so that we can send it to the Personality Insights (PI) API for analysis. First, we’ll concatenate the text into one long string…