PyCon 2016 in Portland, Or
hills next to breadcrumb illustration

Tuesday 12:10 p.m.–12:40 p.m.

Prototyping New APIs with Flask

David Baumgold

Audience level:
Intermediate
Category:
Web Frameworks

Description

You need to build a new API, but which tools do you use? Flask is a microframework that makes web development a snap, and an ecosystem of extensions and other tools has grown around it to make it perfect for prototyping APIs. In this talk, we'll see how to get started with Flask, and learn the best parts of its ecosystem for API development.

Abstract

Flask is a micro web framework that has been gaining a lot of traction in the Python community for its ease of use and it's growing ecosystem of extensions and tools. Because of its shallow learning curve, many Python developers are using it for prototyping web applications and APIs. In this talk, we'll dive into Flask and build a small RESTful API from the ground up. We'll start by learning about Flask itself, and how to make it return JSON-formatted data. Next, we'll spend some time learning about the SQLAlchemy ORM and how to integrate it with Flask, to give our API a database backend. We’ll increase our API’s flexibility using Marshmallow, an object serialization/deserialization library that makes it easy to adapt to changing data models. We’ll integrate a user system into our API using Flask-Login, and restrict some APIs to logged-in users only. If there's time, we'll go into customizing error responses and deployment options.