The goal of this article is to show you how to use Python 3, Flask, and Connexion to build useful REST APIs that can include input and output validation, and provide Swagger documentation as a bonus. Also included is a simple but useful single page web application that demonstrates using the API with JavaScript and updating the DOM with it.
The REST API you’ll be building will serve a simple people data structure where the people are keyed to the last name, and any updates are marked with a new timestamp.
This data could be represented in a database, saved in a file, or be accessible through some network protocol, but for us an in-memory data structure works fine. One of the purposes of an API is to decouple the data from the application that uses it, hiding the data implementation details.
Flask-RESTful
Flask-RESTful is an extension for Flask that adds support for quickly building REST APIs. It is a lightweight abstraction that works with your existing ORM/libraries. Flask-RESTful encourages best practices with minimal setup. If you are familiar with Flask, Flask-RESTful should be easy to pick up.
Best RESTful API books in 2017
One of the great things of RESTful APIs is that it can be used along with React.
RESTful Web APIs is very clearly written and accessible, requiring no prior knowledge of RESTful APIs. This is a book filled with solutions that will show you how to build epic Restful APIs. If you are looking to get started, look no further than RESTful Web APIs.
RESTful API Design: Teach a Dog to REST
While many claim REST has arrived, many APIs in the wild exhibit arbitrary, productivity-killing deviations from true REST. In this presentation, I start with a typical poorly-designed API and iterate it into a well-behaved RESTful API. Check out the presentation (with audio!) below for rules and advice on how to do REST right, including handling complex variations, pagination and API versioning.