Get startedGet started for free

Using request and response headers

Headers contain additional information about your API calls, including the desired or used response format. Using accept and content-type headers, client and server can negotiate what response format to use.

In this exercise, you'll use headers to inspect response formats after making a request and make a new request specifying the desired format via the accept header.

The requests package has been 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.

response = requests.get('http://localhost:3000/lyrics')

# Print the response content-type header
print(response.____)
Edit and Run Code