The Python Package Index (PyPI) is home to almost 100,000 code library packages that help Python programmers accomplish many tasks ranging from building web applications to analyzing data. PyPI is also home to many helper libraries for APIs such as Twilio.

Let’s demonstrate the power of PyPI packages by taking look at how to retrieve and parse JSON results from a RESTful API using four different Python HTTP libraries.

Each example in this post will:

Define a URL to be parsed. We’ll use the Spotify API because it allows requests without authentication. Make an HTTP GET request to that URL. Parse the JSON result.

All four of these libraries provide a different path to the same destination; if you pprint the results, you’ll see a dictionary with Spotify search results:

*Notice: Results may vary depending on which version of Python you’re using. In this post, we will use Python 3 for all of the examples. Consider setting up a virtualenv for Python 3 if you are still running Python 2.X system wide.

The following instructions will help you use virtualenv with Python 3:

Create a directory called pythreetest for your Python 3 testing. Once virtualenv is installed execute the following commands from within the project directory:

Create a new virtualenv with the following command: