Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Introduction to FastAPI

00:00 In this lesson, you will learn what FastAPI is and how it relates to other web technologies in the Python ecosystem of packages. First, you should know that FastAPI is written with creating REST Web APIs in mind.

00:15 What is REST? It’s an acronym that stands for REpresentation State Transfer. It was conceived by Roy Fielding in the year 2000.

00:25 A REST API uses HTTP, the same protocol used to deliver the web page that you are viewing this course on. So you don’t need any special server platform to host REST APIs.

00:37 A REST API repurposes the existing HTTP methods to implement the four standard CRUD operations of a database. REST maps the HTTP methods—POST, GET, PUT, and DELETE—to the CRUD functions—create, read, update, and delete—respectively. And it also repurposes HTTP status codes.

01:03 A REST API is accessed using an HTTP endpoint, conceptually a web address. You are viewing this course on a page hosted on www.realpython.com, followed by a path corresponding to the course in question.

01:19 A REST API does the same thing.

01:22 So if Real Python hosted a REST API with a list of available courses, it might be accessible at www.realpython.com/api/courses. But this would not return HTML to be rendered in a browser.

01:37 It would return plain text, a JSON document, that could then be consumed by other application. Again, familiarity with JSON is assumed as a prerequisite to follow along.

01:51 FastAPI makes it easy to create REST Web APIs. It is straightforward and does not include a lot of ceremony that other frameworks burden you with. It’s super fast, rivaling other web frameworks, such as node.js and Go. The reduced code you have to write lets you create APIs that have fewer errors while taking less time to develop.

02:14 And finally, it relies upon standards such as OpenAPI and JSON Schema and the latest Python features like type hinting. It even provides async support, but you don’t have to get into the weeds of the Python asyncio library.

02:32 You might be asking, why another framework for APIs? After all, we have the Django REST framework, Flask-RESTful, and others. It will become clear after you see the demos, but here are some spoilers.

02:45 As mentioned before, FastAPI was designed with REST APIs in mind. Django is designed to create information delivery forms over data web applications, not APIs. If you were using Django REST Framework, creating an API require some acrobatics that make it feel as if you were writing a Django web application instead of a REST API.

03:08 The Django REST Framework is a Django app and therefore has to follow the Django application model. This isn’t to say that it’s garbage. In fact, it works very well!

03:19 But if you don’t have an investment in Django already, you may have to learn things that might seem confusing. In the next lesson, you’ll learn about a free online development tool called Replit that you can use to develop the demo.

Become a Member to join the conversation.