Professional RESTful API Design using Python Flask
This course will teach you how to build a professional API platform using pure Flask, without any supplemental libraries, so that students can learn the fundamentals of RESTful API design.
The course covers the basic concepts of the RESTful API pattern and then goes into detail and step by step building an API platform that will cover the six constraints of the architecture. Students will learn the industry-standard and will follow best practices for API architectures.
At the end of the course students will be able to design, architect and build their own RESTful API platforms, and with the deep understanding of the laws governing APIs, can go ahead and try out the API libraries available for Python and Flask, knowing the fundamentals and the advantages of using them.
If you already know the basics of Flask and you are interested in how to design, architect and build an API platform, this is the course for you.
The course is divided in 2 sections:
Introduction which covers all the concepts necessary to understand what is a RESTful API and its six constraints
A step by step explanation building a Pet Store API that will include an authentication layer, a Store endpoint and a Pet endpoint as well as search functionalities
The course has more than 5 hours of video tutorials as well as the source code at the end of each section, so that you can follow along with the coding process.
The course can take anywhere from 3 to 10 days to complete based on how much material the student completes daily.
Additionally we’re constantly updating the course, adding contents thanks to the feedback of our students.
Join this course and continue your path to becoming a professional backend web developer!
- What do we want to accomplish in this course?
- What do I need to have to complete this course?
What is an API?
- API stands for "Application programming interface", and it's a set of routines, protocols and tools for building interactions between clients and servers.
What is REST?
- REST stands for “Representational State Transfer” and it's a networked, hypermedia architectural style typified by the web
- REST by design has six constraints:
- Uniform interface
- Layered System
- Code on Demand (optional)
- Manipulation of Resources Through Representations
- Self-descriptive Messages
- Hypermedia as the Engine of Application State (HATEOAS)
A Simple API - Pet Store
Installing the Docker Client
- Docker client for Mac
- Docker compose
- Running the containers separately for pdb
- Using Flask pluggable views
- Explain Flask pluggable views - http://flask.pocoo.org/docs/0.11/views/
- Our first endpoint, /pets
- A simple GET pluggable view
Using Postman - https://www.getpostman.com/
A simple POST handler
Talk about HTTP Status Codes - http://www.restapitutorial.com/httpstatuscodes.html
- Build a GET individual pet endpoint
- Add location to all pets (HATEOAS)
Implement PUT, DELETE on pets
Explanation of the authentication design we are going to use
- Write a decorator to allow the user to access the API
- Add authentication to headers in Postman
Create the app registration endpoint and generator
Build the token-based application access decorator
Start a testing framework
- Build store models
- Don't expose MongoDB ID, use uuid
- Validation of data using jsonschema - http://python-jsonschema.readthedocs.io/en/latest/
- Great resource - https://spacetelescope.github.io/understanding-json-schema/index.html - to understanding it
Build JSON templates
Use Postman to test the Store end points
- PUT operations are the update of CRUD. It generally receives all the fields with the ones being updated changed.
- PATCH is used for updating only specific fields (we won't implement)
- Implement DELETE
- Results should always be paginate
- Links within show next and prev
- This is the HATEOAS of the app
- Testing CRUD
- Testing pagination
- Introduction to Fixtures
- Custom fixtures using mongoimport
- Create CRUD
- Postman Tests
- PUT and DELETE for Pets endpoint
- Write tests for Pets endpoint
- Pets pagination tests
- Use the same Store GET endpoint
Get all pets in a specific store using Postman
Search pets across stores
- Implementing filters across stores
- Create a pets_href template to add filters