Chapter 11. 10 using web apis: You Really Should Get Out More

Image

You’ve been writing some great code, but you really need to get out more. There’s a whole world of data just waiting for you on the web: Need weather data? Or how about access to a huge database of recipes? Or are sports scores more your thing? Maybe a music database of artists, albums, and songs? They’re all out there for the taking from Web APIs. To use them all you need is to learn a bit more about how the web works, how to speak the local web lingo, and how to use a couple of new Python modules: requests and json. In this chapter we’re going to explore Web APIs and take your Python skills to new heights; in fact, we’re going to take them all the way to outer space and back.

Note

You think we’re kidding!

Extending your reach with Web APIs

You’ve seen a recurring pattern in this book: first you took your code and abstracted it away into functions. Once you did that, you could make use of the functionality in a function without having to worry about all the details of how the function does what it does. This allowed you to elevate your thinking above the level of simple statements.

Next you packaged things up into modules that contained a whole set of functions and values. Remember the code you handed to Cory? He was able to quickly look at your documentation, see what functions were available, and make use of ...

Get Head First Learn to Code 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.