Modern APIs with FastAPI and Python Transcripts
Chapter: Welcome to the course
Lecture: Fastapi vs. x

Login or purchase this course to watch this video and the rest of the course contents.
0:00 One of the questions people always ask is
0:02 "Which Web framework should I use for building an API? Should
0:05 I use flask? Should I use Django? Should I
0:07 use Django REST framework?" like, all these different things.
0:09 So let's take a moment and look at FastAPI versus other frameworks,
0:13 real briefly. Well, the big two have got to be Django and Flask.
0:17 Django has Django REST framework.
0:19 Flask has some REST-ful extensions,
0:21 you can add to it. But here's the thing,
0:24 FastAPI is an API framework
0:26 first. It's an async framework
0:28 first. It automatically creates documentation with openAPI documentation, all those things.
0:34 So it's built specifically to be what it is,
0:37 an API framework, where as Django,
0:39 yes it also does API's,
0:41 but that's not it's main goal. Flask also does API's,
0:45 but it's not got all that infrastructure there to help you make it go fast.
0:49 Oh yeah, and both Django and Flask don't fully embrace the async and await
0:54 style programming. At the time of this
0:55 recording, Django is working on it,
0:57 Flask has plans that are not really there
0:59 yet. So, if you want a modern API and you're starting from now,
1:03 you're starting from scratch, your starting
1:04 now, why not choose the most modern framework that has some momentum behind it?
1:09 We also might compare it to Pyramid or Tornado. Pyramid,
1:12 I love Pyramid. I think it's a great framework,
1:14 but it does not, and has no plans to, support async as far as I
1:18 know. Also, it's more on the web, less on the
1:22 API framework side. Pyramid's great.
1:25 There's a lot of things I like about it and I actually created some open source libraries to
1:28 bring those features that I like about Pyramid to
1:30 FastAPI, but that sort of not exactly the main topic of this course.
1:34 But Pyramid, nice. Tornado, Tornado is interesting because it's one of the few frameworks
1:40 that embraces the async and await style of programming.
1:43 But FastAPI is the modern version of Python's async.
1:48 And also there's other specific API frameworks,
1:51 right? So Django, Flask, all these,
1:53 they're about building Web apps. They can also build API's. Hug,
1:56 for example, built on Falcon, is one of these frameworks that's specifically about building
2:01 API's. "Embrace the API's of the future",
2:03 the happy Koala hugging bear things says.
2:06 And Hug is actually nice, but the guy who created Hug actually talked about his
2:11 admiration for FastAPI and how it's really,
2:13 really special. Let's look at one more aspect of these here.
2:16 Programming is not exactly a popularity contest,
2:19 but when things are popular, that means there's more momentum behind it,
2:23 there's more other tools to go with it,
2:25 there's more tutorials and whatnot, so let's just look at the number of GitHub
2:29 stars around each of these. So, Django: 54,000, Flask: 53,000, Pyramid: 3,000,
2:36 Tornado: 20,000, Hug: 6,000.
2:38 You look at FastAPI,
2:39 It's at 22, 23,000 right now.
2:43 What's interesting though, you might say,
2:45 Well, "it's less popular than Django and flask",
2:47 Yeah, it's only been around a year and a half,
2:49 and Django and Flask have been around like 10 years.
2:51 So, that tells you a sense of just how popular FastAPI is. It's way
2:56 popular more than all the other ones below that have been around a while.
3:00 But even for the big hitters,
3:01 it's like halfway there, 1/7, 1/6 the time it's been around, so really,
3:06 really exciting. There's so much momentum behind FastAPI and I do think
3:10 it's because of this modern aspect that we've talked about.