Code Editor
Learn
Using the Twitter API

Import Packages

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.

  • operator - a package that allows arithmetic and comparison functions, such as comparing two strings or multiplying two numbers.

  • requests - a package that makes it easy to make HTTP requests, so we dont have to code any HTTP interactions.

  • json - the most widely used format for data exchange on the Internet today. This package makes it easier to work with JSON objects in Python.

  • twitter - the package needed to interact with the Twitter API.

  • watson_developer_cloud - the package needed to interact with the Personality Insights API.

These Python packages are dependencies for the python-twitter and watson-developer-cloud packages we manually installed earlier. Without them, the python-twitter and watson-developer-cloud packages won't function correctly.

The packages will also help us directly communicate with the Twitter API and format the results we'll display to users.

Report a Bug
If you see a bug or any other issue with this page, please report it here.