Unit 3 of 3

Python REST with requests

15 min +150 points

Learning objectives

When you finish this unit, you will be able to:

  • Construct a Python script that calls a REST API using the requests library.

Python and the requests library

The requests library is the standard way to make HTTP calls from Python scripts in DevNet workflows.

Typical pattern

import requests

response = requests.get(
    "https://api.example.com/devices",
    headers={"Authorization": "Bearer TOKEN"},
)
response.raise_for_status()
data = response.json()

Key concepts

  • Set appropriate headers (Content-Type, Authorization).
  • Handle response status codes and errors.
  • Parse JSON responses into Python structures.

Exam focus: read or complete Python scripts that call REST APIs using requests.

Sign in to save your progress

Mark units complete, earn points, and work toward Certification Pro status.