Skip to Content
The Python Book
book

The Python Book

by Rob Mastrodomenico
January 2022
Beginner to intermediate
272 pages
6h 51m
English
Wiley
Content preview from The Python Book

18APIs in Python

In this chapter, we will cover how to deal with APIs (application programming interfaces) using Python. To do this we are going to cover both how to create and access an API and build examples to do both. Before we get to writing any code we need to cover what an API is and why its useful. An API is a mechanism that allows communication between software applications and in this case will cover communication between an application and a web user. The uses of APIs have become increasingly popular allowing users to access data or communicate with services. They give a unified approach to doing so and therefore have become an important aspect to become familiar with, understanding how to communicate with.

We begin by creating our own API to do this. We are going to use the Python packages flask as well as the package flask‐restful. To see if you have the packages you can try and import them.

image

Now, flask comes by default with the Anaconda distribution of Python but you may not have flask_restful, if that is the case you will need to install it. To do so go to https://anaconda.org/conda-forge/flask-restful to find something like the one shown in Figure 18.1.

Now, while this book has intended to be self‐contained and not rely on many things outside the Anaconda distribution of Python, the url around things like the Anaconda website and subsequent links within it may ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Quick Python Book, Third Edition

The Quick Python Book, Third Edition

Naomi Ceder, David Fugate
Serious Python

Serious Python

Julien Danjou

Publisher Resources

ISBN: 9781119573319Purchase Link