Exercise 53
Getting Data from APIs
In this exercise you’ll access the application programmer interface (API) I use for my learncodethehardway.com website. In web development, an API is usually a combination of the following:
A web server that you can access with the HTTP protocol. You used HTTP when you used
urllib
to get the beer production PDFs from the ttb.gov website. HTTP is also what your browser uses to display the web application to you.This web server responds in some data format that’s easily parsed. This is what differentiates a PDF from an API. Sure, you’re getting data on beer production from ttb.gov, but you have to parse that data out of a PDF. An API gives you the data ready to go in a format that loads directly into your application ...
Get Learn Python the Hard Way: A Deceptively Simple Introduction to the Terrifyingly Beautiful World of Computers and Data Science, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.