Get startedGet started for free

Creating and deleting resources using an API

Now that you have learned how to construct a URL, you can send requests to specific API resources. Let's see what more you can do with HTTP verbs on these resources.

In this exercise, you will use the playlists API available via http://localhost:3000/playlists/. This API offers the following actions:

Verb Path Description
GET playlists get a list of all playlists
GET /playlists/{PlaylistId} get information on a single playlist using it's unique identifier PlaylistId
POST /playlists create a new playlist
DELETE /playlists/{PlaylistId} remove an existing playlist using it's unique identifier PlaylistId

You will start by getting a list of all existing playlists, then you will learn how to create a new playlist and verify it's creation, and last you will learn how to remove an existing playlist.

The requests library is already imported for your convenience.

This exercise is part of the course

Introduction to APIs in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Get a list of all playlists from the API
response = requests.____('____')
print(response.text)
Edit and Run Code