Modern APIs with FastAPI and Python Transcripts
Chapter: Welcome to the course
Lecture: Modern Python and APIs

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The title of this course is "Modern API's with FastAPI". And that's no coincidence. Let's talk about some of the modern Python features that
0:08 FastAPI uses to allow us to create nice, modern, Python API's. We've talked about type hints. Type hints are used all over the place.
0:16 We can say, here's an API method, It takes an integer and an optional integer, It will automatically do that conversion.
0:22 But with Pydantic, It actually takes this much farther as well as throughout the whole
0:26 framework it has type hints on its types so you don't have to go to the documentation to figure out what's happening. It's async and await first.
0:34 There's basically nothing you have to do to make FastAPI async friendly or async capable.
0:39 All you gotta do is write async a few methods and use async and await within your implementation and you're done.
0:45 The web server it comes with is one of these ASGI servers, so it automatically knows how to run async enabled frameworks perfectly.
0:53 So you get great scalability anytime you're waiting on an external system; be that a database,
0:57 another web service call, a cache, any of those types of things. Also, it takes the idea of data classes and pushes them even a little bit
1:06 farther with Pydantic classes. These are ways to describe how your data is supposed to be exchanged in terms of classes with type hints,
1:15 and then do that exchange and conversion automatically with Pydantic.
1:19 And then the documentation is generated automatically for us and conforms to the OpenAPI documentation standard. The API's are super easy to test,
1:27 so testing your code with pytest is very, very straightforward, especially because all the strongly typed data exchange that you see living in
1:36 the actual API definition. So you can just call those functions and off it goes. And also because of the type hints,
1:43 we get rich editor Support. Editors like PyCharm and VS Code know how to read type hints and then give us all the auto complete information we need
1:52 so we're not diving around in the docs and asking questions "what's available here?", you can just look in the editor and just keep on coding.
1:59 Here's a bunch of the reasons, or a bunch of the aspects of modern Python that are leveraged in FastAPI.


Talk Python's Mastodon Michael Kennedy's Mastodon