All courses
· intermediate

Working with APIs in Python

Talk to a service over HTTP and handle what comes back. Building URLs correctly, reading JSON safely, telling a retryable failure from a permanent one, and paging through results without holding them all.

Pathaxis · Original content

Written in house, from the work rather than from a syllabus. Every example is one we would use ourselves, and every exercise is checked against the same engine that grades your answer.

83 min 6 lessons 20 quiz questions 6 exercisesStart course

What you’ll learn

  • Build a URL with query parameters that survives spaces and symbols
  • Read a JSON response without exploding on a missing key
  • Tell a client error from a server error, and know which are worth retrying
  • Back off between retries instead of hammering a struggling service
  • Page through a large result set lazily with a generator
  • Keep credentials out of the code and out of the URL

Before you start

  • · Comfortable writing functions and handling exceptions
  • · Familiar with dictionaries and lists

Syllabus

01

The shape of an HTTP call

What goes out, what comes back, and how to build it correctly.

02

Handling the response

Reading the body safely, and reacting to what the status says.

03

Making it reliable

Retries, paging and credentials, which is where real integrations live.