This video is a recording from the workshop "Build API Applications with Python", which took place on November 8, 2022.
During the workshop, we built an API for a jobs portal using Python's popular FastAPI framework. As we worked on the API, we also learned about hexagonal architecture, API testing frameworks, deployments, and more.
Here's list of useful resources related to the workshop:
✅ The supplementary material for the workshop is available in this document: https://docs.google.com/document/d/1m.... I've updated the document with additional content that came up during the workshop, like hexagonal architecture, datamodel-code-generator, schemathesis, and so on.
✅ Here's the repository with the code from the workshop: https://github.com/abunuwas/fastapi-w....
✅ API specification for PyJobs (the API we build during the workshop): https://algorizm.stoplight.io/docs/fa....
🚀 If you liked this video, please like it and share it with your network! You can also subscribe to my channel!
I'll be running similar workshops in the coming months. If you want to stay up to date, please subscribe to my newsletter (https://microapis.substack.com/) or check my eventbrite events page (https://www.eventbrite.co.uk/o/jose-h....
0:00 Introduction
05:00 Understanding API implementation requirements
09:26 Setting up the environment
10:55 Setting up project structure and hexagonal architecture explanation
17:00 Creating a FastAPI application
17:43 Implementing the API endpoints
23:42 Running the server
29:06 Adding an in-memory list of jobs
33:59 Adding response validation models with Pydantic
45:13 Capturing and processing request payloads
50:17 What is schemathesis
52:57 Implementing URL path parameters
57:37 Debugging URL path parameters
59:43 Implementing the PUT /jobs/{job_id} endpoint
03:25 Implementing the validation models with Pydantic
01:06:21 Setting response status codes
01:07:35 Returning empty responses (204 status code)
01:08:33 Implementing the cancel job and reactivate job endpoints
01:09:16 Q&A
01:12:45 Testing the implementation with the Swagger UI
01:13:00 Implementing URL query parameters
01:23:19 Testing and debugging the API
01:28:22 Deploying to Heroku
01:28:17 Handling OpenAPI optional attributes in Pydantic
01:38:55 Wrapping up
FastAPI is a high-performant REST API framework for Python. It's built on top of Starlette (https://www.starlette.io/) and it uses Pydantic (https://pydantic-docs.helpmanual.io/) for data validation. It can generate OpenAPI documentation from your code and also produces a Swagger UI that you can use to test your application.
Check out FastAPI's official repository (https://github.com/tiangolo/fastapi) and give it a star! Also make sure to check out its excellent documentation online: https://fastapi.tiangolo.com/.
Please let me know in the comments if you liked this video and whether you found it useful.
Let me know also what other kinds of topics you'd like me to address in future videos!