Introduction to APIs in Python
Learn to call REST APIs from Python with the requests package: build requests, read status codes, authenticate, exchange JSON and handle errors.
Web APIs carry data between clients and servers over HTTP, and using one from code depends on knowing how a request is put together and how to read the reply. You call a REST API from Python with the requests package, shape URLs with parameters, check headers and status codes, sign in with Basic or API key authentication, exchange JSON, and keep an integration working when calls fail or hit a rate limit.
What You Will Achieve
- Send GET, POST and DELETE calls with the requests package and add query parameters to a URL
- Read status codes and response headers to judge whether a call worked and what content came back
- Authenticate against a web service using Basic Authentication or an API key token
- Send and parse JSON payloads, catch request exceptions, and pace calls to stay within rate limits
Program Overview
Web API Requests, HTTP Verbs, and Status Codes
Starts with what a Web API is and works through building, sending and reading requests, with a music catalog API as the running example.
- Web APIs and first requests with urllib and requests
- The anatomy of a request and the main HTTP verbs
- Building URLs with parameters; creating and deleting resources
- Request and response headers, response codes, and content-type errors
Authentication, JSON Data, and Error Handling
Moves on to securing calls, working with structured data, and writing code that copes with failed requests and service limits.
- Basic and API key authentication methods
- Requesting, receiving and sending JSON
- Handling errors with requests
- Respecting API rate limits
Certificate Awarded (Paid)
Job Outlook
Calling web APIs from Python is everyday work in software development and data work, wherever a script or application has to pull data from another service or send updates to it.
Good for: Python programmers who need to pull data from a REST service or connect a script to one, and want guided practice with requests, headers and authentication.
Keep in mind: The two chapters stay with REST and the requests package, and authentication is limited to Basic and API key methods, so other sign-in schemes need study elsewhere.
Bottom line: A tight, code-first walk through the HTTP request and response cycle in Python, with authentication, JSON and rate-limit handling in its second half.
Frequently Asked Questions
Which Python library does the course use for API calls?
Almost all of the work uses the requests package, including its methods for sending data and its error classes. An early lesson also makes a request with the standard urllib module.
What API do the practice examples use?
The first chapter builds its examples around a music catalog API, using it to show how URLs, parameters, headers and status codes behave when you create, fetch and delete resources.
What makes up the anatomy of an API request?
The lessons break a request into its URL, path and parameters, then look at the start line, headers and status code of the request and the response, so you can tell what was sent and what came back.
How does the course handle API rate limits?
A late lesson shows how to recognize the error a service returns when calls arrive too quickly, and how to pause between requests with time.sleep so the script is not blocked.
User Reviews
Write your review
You must be logged in to post a review.
Reviews can only be posted by registered learners. Log in or create a free account, then you will return here to post.


There are no reviews yet.