Advanced level · Module 4 of 6 · 30 guided hours
Building Web APIs with Flask
Expose application features as a JSON web API that mobile apps, websites and other systems can use.
Learning objectives
- Build routes that return JSON with correct status codes
- Validate requests and connect to the database
- Apply basic API security
Topics
- Flask app structure and routing
- request parsing and JSON responses
- status codes and error handlers
- configuration and secrets
- authentication basics and input validation
Lessons
-
Lesson 1 Flask Routes and JSON Responses
Create a Flask application with routes that return JSON data.
routeHTTP methodjsonifystatus code
-
Lesson 2 Accepting and Validating Input
Accept JSON in POST and PUT requests, validate it and update the database.
POST/PUTrequest.get_json()validationerror handler
-
Lesson 3 Testing an API with the Flask Test Client
Check every endpoint automatically, including error cases, without starting a server.
test clienttest databasestatus code assertionregression
-
Lesson 4 Configuration, Secrets and API Security Basics
Configure the app for different environments and protect it with simple authentication and secure defaults.
environment variablesecret keyauthenticationleast privilege
-
Lesson 5 Structuring a Larger Flask Project
Organise a growing Flask application into an application factory and blueprints so it stays maintainable.
application factoryblueprintconfiguration objectseparation of concerns
Practical activity
Build the Tested Inventory API level project endpoints and connect them to the data-access module from the database module.
Expected outcomes
- A working, secured JSON API
- Understanding of how web and mobile apps talk to back ends
Assessment
Instructor runs a prepared request collection against each API; marks for correct responses, validation and security.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.