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