Why You NEED To Learn FastAPI | Hands On Project

Поделиться
HTML-код
  • Опубликовано: 16 май 2024
  • FastAPI is my absolute favorite Python API because of its modern features not found in other APIs.
    In this video, I'll discuss 7 advantages that FastAPI has over other alternatives, like an API built with Flask, and I'll do this WHILE building out a fun little ToDo app.
    Code along with me!
    Become a community member to access Part 2 and Part 3 of this course where we connect the API to SQL and then build out a React front-end for it. More information here - travis.media/community/
    Timestamps
    00:00 Intro
    00:43 Why are APIs so important?
    03:30 Project setup
    04:07 Installation and server
    04:40 First basic route
    05:10 Advantage 1 - It's just plain Python
    05:35 Advantage 2 - Async built-in
    06:50 Structuring our routes
    07:52 GET todos
    08:28 POST todo
    09:00 Advantage 3 - Data validation built-in
    10:37 Advantage 4 - Typed Python!
    11:44 GET todo
    14:13 DELETE todo
    15:35 UPDATE todo
    18:19 Advantage 5 - Errors are in JSON
    18:28 Advantage 6 - Authentication methods built-in
    18:50 Advantage 7 - Swagger and ReDoc built-in
    20:41 Outro
    Dive deep with FastAPI on Udemy
    geni.us/y3m6
    ** Career Path Coding Tracks **
    Web Developer - geni.us/jBigBd
    Software Engineer - geni.us/AbMxjrX
    Machine Learning - geni.us/GporLlT
    Python Developer - geni.us/tv2FJBU
    DevOps Engineer - geni.us/MgHtJ
    ** My Coding Blueprints **
    Learn to Code Web Developer Blueprint - geni.us/HoswN2
    AWS/Python Blueprint - geni.us/yGlFaRe
    ** I write regularly **
    travis.media
    ** FREE EBOOKS **
    📘 travis.media/ebooks
    LET'S CONNECT!
    📰 LinkedIn ➔ / travisdot. .
    🐦 Twitter ➔ / travisdotmedia​
    🙋🏼‍♂️ Website ➔ travis.media
    #fastapi #pythonprogramming #api
    ** Some of the links in this description may be affiliate links that I may get a little cut of. Thank you.
  • НаукаНаука

Комментарии • 139

  • @hndr91
    @hndr91 9 месяцев назад +4

    Mann, this video is crystal clear intro to FastAPI

  • @miluna94
    @miluna94 9 месяцев назад +53

    I knew FastAPI was good but it is actually great! Much more production ready than Flask and much closer to Spring framework

    • @keylanoslokj1806
      @keylanoslokj1806 9 месяцев назад

      What do all those weird terms mean?

    • @miluna94
      @miluna94 9 месяцев назад

      @@keylanoslokj1806 Flask is another Python library and Spring is a Java framework

    • @rl6382
      @rl6382 9 месяцев назад

      ​@@keylanoslokj1806they represent different ways of doing things.

    • @danielkirsch4351
      @danielkirsch4351 7 месяцев назад

      What makes it closer to Spring in your view @miluna94 ? - interested to know as I am looking into python frameworks and wish to pick something which may make it simpler in terms of congnitive load and context switching . Thanks

    • @miluna94
      @miluna94 7 месяцев назад

      ​@@danielkirsch4351I would say the autoconfigured validation, swagger and all those sweet things that Flask does not have out of the box

  • @ratzule
    @ratzule Месяц назад

    Outstanding, Travis. Crystal clear and fun. This is the first of your videos I have found, but I enjoyed and learned so much useful stuff in it I immediately subscribed.

  • @ragsbigfella
    @ragsbigfella 8 месяцев назад +3

    Travis, thank you for this video. Can you please create a video with async/await in fastapi with a bigger project which has a multiple folders/files?

  • @mattmarshall1834
    @mattmarshall1834 7 месяцев назад +2

    Great, to the point, tutorial. Thank you.

  • @hellomelloyello
    @hellomelloyello 2 месяца назад +1

    Excellent tutorial. I did a Coursera Cert on Back-End using Django and was entirely overwhelmed! Lol. This clarified a lot for me.

  • @click66
    @click66 7 месяцев назад +5

    My favourite part was when you told us what API stands for.
    "OH, what doesnt it stand for..."
    Kidding of course, great video. Im an experienced dev getting deeper into how to leverage python for more scalable apps so FastAPI is quickly beomcing ny weapon of choice, and this video really helped. Thanks

  • @jonathanjohnson2785
    @jonathanjohnson2785 9 месяцев назад +14

    Great content as usual. Im more a javascript guy but it doesn't hurt to see things from a python's perspective💯👍👍

  • @phaneendhraajaythota1025
    @phaneendhraajaythota1025 9 месяцев назад +1

    awesome.. I worked with flask apis .. it pretty much looked the same.. with built in async etc.. thank you.

  • @armans4494
    @armans4494 9 месяцев назад +2

    Wonderfully done. Thank you

  •  8 месяцев назад +1

    nice video. how do you compare it with something like Ruby-Sinatra or Hanami ?

  • @ronjones1587
    @ronjones1587 5 месяцев назад +1

    Amazing ! This video got me started very FAST, thank you very much!

  • @muhammadumarsotvoldiev8768
    @muhammadumarsotvoldiev8768 8 месяцев назад

    Thank you for your efforts! Respect

  • @incognito_789
    @incognito_789 Месяц назад

    I'm sort of a newbie so it takes me some hours to follow up, but your video is incredibly concisely and informative. Thumbs up for you, thank you soooo much!!!

  • @AstorSkywalker
    @AstorSkywalker 6 месяцев назад

    Great tutorial, nice way to spend my Sunday morning!

  • @neusprach
    @neusprach 8 месяцев назад

    Awesome tutorial! Thanks!

  • @techeye7005
    @techeye7005 8 месяцев назад

    Man loved your content , Thankyou

  • @whisperingadventurespnw
    @whisperingadventurespnw 8 месяцев назад +7

    Could you do a follow up on this video using a database? I’ve seen fast api tutorials like this before but they all stop before they implement the database layer. If you made that video you’d be the only one with that content.

  • @AaronGayah
    @AaronGayah 7 месяцев назад

    Thank you. I enjoyed this.

  • @darrenlefcoe
    @darrenlefcoe 7 месяцев назад

    a very clear video with good example(s) of why one might use FastAPI...

  • @casper905
    @casper905 4 месяца назад

    Coming from Rails world, fast and right to the point! love it, smooth teaching style!

  • @_MagL
    @_MagL 8 месяцев назад +5

    At 16:42 line 32 just updating the Todo item would suffice since the Todo id isn't expected to change

  • @user-fs3gh8ey1u
    @user-fs3gh8ey1u 8 месяцев назад +1

    Thank you so mach!

  • @Patronesofly
    @Patronesofly Месяц назад

    Definitely like how enthusiastic he is about everything

  • @parkerrex
    @parkerrex 5 месяцев назад

    Caught me a bit off guard that you kept calling it FastTrack and then got the count off, but forget that this video was great!!! Thanks Travis.

  • @omarhassoun636
    @omarhassoun636 4 месяца назад

    Love the video! Where are the next parts?

  • @aitools24
    @aitools24 6 месяцев назад +12

    00:03 Creating an API first allows for easy integration and maintenance of multiple applications.
    02:30 Fast API is a better alternative than Flask as an API.
    05:20 FastAPI provides built-in async support and is more efficient than Flask
    07:57 Create and validate a to-do item for the API
    10:44 Fast API provides typed APIs, allowing for easy declaration of types in Python.
    13:29 Implementing CRUD Operations
    16:14 Updating to-do items
    18:46 Fast API provides a built-in Swagger UI for easy API documentation and testing.
    Crafted by Merlin AI.

  • @thomasanderson9539
    @thomasanderson9539 8 месяцев назад +1

    Great! How do you have the autocompletion in your terminal? Is it a plug-in or a special terminal

    • @kylehodgetts
      @kylehodgetts 7 месяцев назад

      Im not sure about Travis, but I use zsh as my shell and use the zsh-autosuggestions zsh-syntax-highlighting plugins

  • @jironymojirolamus913
    @jironymojirolamus913 3 месяца назад

    Great turorial, thanks!

  • @theBidon
    @theBidon 9 месяцев назад +3

    100k incoming!

  • @tesla9527
    @tesla9527 8 месяцев назад

    how to flash message to jinja2 template using fastapi just like flash in flask?

  • @terribletruth8201
    @terribletruth8201 7 месяцев назад +4

    11:25 If you're dumb or blind like me, make sure the menu item next to GraphQL is set to "JSON". Mine was defaulted to text, it took me forever to figure out why mine wasn't working.

    • @sanderweide6245
      @sanderweide6245 5 месяцев назад

      you saved me from insanity with this comment, thanks!

  • @Carterofmars
    @Carterofmars 9 месяцев назад

    Since I'll be concentrating on HTML/CSS a Web API is something I'll need to add to my curriculum.
    Question: Do you still recommend Zoho Books?

  • @circulartext
    @circulartext 4 месяца назад

    love working with fast api

  • @vannakvy9109
    @vannakvy9109 8 месяцев назад

    how to we structure our project when it gets bigger.

  • @sameergaikwad222
    @sameergaikwad222 2 месяца назад

    Awesome. Thanks it helped. 👍👍

  • @akramsystems
    @akramsystems 8 месяцев назад +1

    How about this vs Quart?

  • @timbrap4693
    @timbrap4693 9 месяцев назад +5

    You mention when building a webapp, you can use a frontend like react to call the routes. When you do this, the calls are visible from the network tab in devtools. But when I visit some of the more famous websites, those calls arent always visible. Why is that? Do they not use an API, or do they serverside render it (prefetch serverside and send the data over some way)

    • @Crypt0mite
      @Crypt0mite 9 месяцев назад +3

      This is a good question I would like to know this as well.

    • @AdefemiGreat
      @AdefemiGreat 9 месяцев назад +1

      Most big companies have an active socket connection for transferring data between the backend and frontend. So what you see most times is just interaction between the frontend and the socket service

    • @timbrap4693
      @timbrap4693 8 месяцев назад +1

      @@AdefemiGreat Do you happen to have by any chance some literature about this topic?

    • @AdefemiGreat
      @AdefemiGreat 8 месяцев назад

      @@timbrap4693 not literature really, more like experience

    • @extremelyangryman2583
      @extremelyangryman2583 8 месяцев назад

      They're probably using next or nuxt to make server side requests

  • @StrategicCIS
    @StrategicCIS 8 месяцев назад

    I've got a database on a digital ocean droplet that I'm trying to connect to with FastAPI and SQLModel. I can connect to the DB when it's local. Do you have any tutorials on getting things up on the cloud? Thanks.

    • @TravisMedia
      @TravisMedia  8 месяцев назад

      So a database installed and running on a droplet that you manage, or a managed database that DO manages? Just wanted to clarify.

    • @StrategicCIS
      @StrategicCIS 8 месяцев назад

      It's a database on a droplet that I manage. I've made some progress: I've got FastAPI/SQLModel on a Deta space. I'm getting a {"detail":"Not Found"}, and in the Swagger docs I'm getting a 200 Successful response and then a 422 Validation Error.
      From my research, it looks like everything is good on the server side of things and that there's something wrong with my code - either the ORM or the API.
      Is that accurate?

  • @Darbokst
    @Darbokst 3 месяца назад

    went to join your community for vid 2 and 3, hopefully it'll be back soon.

  • @andybecker5001
    @andybecker5001 8 месяцев назад

    Built in swagger is cool. This Definitely seems more intuitive than JavaScript

  • @adiljamshad215
    @adiljamshad215 6 месяцев назад +2

    I'm asking about fastapi being typed (I am talking about developer experience). As I have worked with c#. The typed characteristic is what I admire the most about it. Python being a dynamic language, how can fastapi be typed while running on python?
    Is it compile time typed or is it run time typed too?

    • @paulChannel196
      @paulChannel196 6 месяцев назад

      Serialization time typed, it uses Pydantic

  • @bakasenpaidesu
    @bakasenpaidesu 9 месяцев назад +4

    Django 🔥

  • @user-jg4ci4mf8w
    @user-jg4ci4mf8w 9 месяцев назад +5

    Question: Why do you create a new project and environment using a terminal program outside of VS Code when you're going to end up using vs-code to build out your app? Please someone answer this question, I noticed many people do this.

    • @TravisMedia
      @TravisMedia  9 месяцев назад +22

      Two reasons for me:
      1. I by default just start with the terminal by habit when I do things like this.
      2. If you start with VSCode, often when you bootstrap a project it creates a new folder. Then you have to cd into that and reopen VSCode to show the file tree from that folder. If you start with the terminal, you can install, cd into a directory, and get into the path where you need to be, and then at last open up a text editor in that path.

    • @BboyKeny
      @BboyKeny 8 месяцев назад

      I used to use the terminal to go to the project directory and start vscode with code .
      Now I use neovim instead of vscode. I like the terminal because it gives easy access to many programs / functionalities.

  • @christofferagger4072
    @christofferagger4072 3 месяца назад

    Great vid!

  • @cikgutaiff
    @cikgutaiff 9 месяцев назад +2

    Though dated, I'm so used to Yii2 and Gii for automatically generating MVC from a database. There doesn't seem to be anything equivalent in the Python world for now, that is free. Or is there...?

    • @brendanmclearie4278
      @brendanmclearie4278 8 месяцев назад

      django

    • @cikgutaiff
      @cikgutaiff 8 месяцев назад

      @@brendanmclearie4278 I wonder how Django compares with Yii2, as a pure REST API backend...

  • @MrProgrammerSharmaJi
    @MrProgrammerSharmaJi 3 месяца назад

    🥺🥺 now python can be my primary goto for small and medium projects as it resolves my concern of oversized setup of anything like django... Also it made easy to structure our project by ourselves.

  • @chriskeo392
    @chriskeo392 9 месяцев назад +7

    Need a video with fastapi + htmx

    • @TravisMedia
      @TravisMedia  9 месяцев назад +4

      Expect it soon. Been looking for a reason to use htmx.

    • @chriskeo392
      @chriskeo392 9 месяцев назад +1

      @@TravisMedia I'll be on alert for the video

  • @dev.info.2000
    @dev.info.2000 7 месяцев назад

    Which version of python should be used for fastapi?

  • @zbyszeks3657
    @zbyszeks3657 Месяц назад

    6:46 "ERROR: Error loading ASGI app. Attribute "app" not found in module "main".
    Just didn't "save" on the file and there was not autosave mode on

  • @istwishmeister9368
    @istwishmeister9368 День назад

    does anyone know why the FastAPI document in this video is shown differently than the currently available version?
    How can I get the proper documentation version of FastAPI?

  • @pramudyadika_
    @pramudyadika_ 2 месяца назад

    Thanks!

  • @jameszack7158
    @jameszack7158 8 месяцев назад

    Hi. I want to build a web application. I know coding in python and javascript. But that's all. I don't know anything about web applications, HTML, CSS, frontend, backend, routing, HTTP, databases, servers, protocols etc. So, how can I learn about these things and how do I build a web application? Could you please recommend a book explaining all these things for a complete beginner? Thanks.

  • @PANDURANG99
    @PANDURANG99 7 месяцев назад

    is it feasible for ML apps?

  • @Tommysbuilds
    @Tommysbuilds 8 месяцев назад

    wow.. i need to rewrite my flask api. like right now

  • @TotallyNotAuroras2ndChannel
    @TotallyNotAuroras2ndChannel 9 месяцев назад +2

    I did but no one has taken my crud operations seriously

  • @Shadow01Net
    @Shadow01Net 4 месяца назад

    Is there a good tutorial about authentication ?

  • @Roman_Carter
    @Roman_Carter 9 месяцев назад +4

    Any recommendations for older tech guy getting into development starting from scratch…?

    • @SergioBallestrero
      @SergioBallestrero 9 месяцев назад +3

      It depends a lot on your background and your goal (personal or career move). But anyway what I feel is most important is to be motivated and enjoy doing it, so find some hobby project to experiment, like automating some task, some home IoT with RasPi, Arduino etc. The second one is to read not just books but other people's code too.

    • @confidential303
      @confidential303 8 месяцев назад +2

      Age doesn't matter. The intent to learn is

    • @martinkrauser4029
      @martinkrauser4029 6 месяцев назад +1

      I recommend not being fooled into thinking age is a factor for learning skills. When you're new, you're new. :) Better question to ask would be "with my background in this and interests in this, where do you recommend I start"

  • @Proviper666
    @Proviper666 8 месяцев назад

    Did he talk about FastAPI minuses? There got to at least one?

  • @paulgupta2454
    @paulgupta2454 8 месяцев назад

    Can you please add a link to the code that you're writing, I know you want us to 'code along with you' but it's difficult to find syntax errors as we're watching a video. It's especially insensitive to those with accessibility needs. Good video otherwise though!

  • @AbderrahmanFodili
    @AbderrahmanFodili 8 месяцев назад

    Coming from Laravel this seems so painful to watch. No model route binding
    Don't mind me 😅 I'm a noob with only six months of experience
    The swagger thing was neat 😎

  • @God-uf6yc
    @God-uf6yc 5 месяцев назад

    Bottle is good too?

  • @browaruspierogus2182
    @browaruspierogus2182 8 месяцев назад

    except mvc is a mistake - cqrs seems to be the future and also improved minimal APIs

  • @RowafaEdits
    @RowafaEdits 9 месяцев назад

    Can I edit your videos?

  • @MrAtomUniverse
    @MrAtomUniverse 7 месяцев назад

    How do i host it remotely

    • @TravisMedia
      @TravisMedia  7 месяцев назад

      fastapi.tiangolo.com/deployment/

  • @santoshbandichode3449
    @santoshbandichode3449 4 месяца назад

    Learning something like msgspec also pays off

  • @rakly3473
    @rakly3473 7 месяцев назад

    FYI whomever is reading:
    There's a Postman extension in VScode

    • @TravisMedia
      @TravisMedia  7 месяцев назад +1

      That’s new to me. Thanks!

  • @FickleHead
    @FickleHead 7 месяцев назад

    Thats alot todo in one day ;)

  • @himankshu
    @himankshu 5 месяцев назад

    hey loki

  • @not_a_human_being
    @not_a_human_being 3 месяца назад

    put? delete? looks like FastAPI puts new wind into the sails of the REST. Having worked with APIs I'm yet to see anything other than "GET" or "POST" in production.

  • @baloney_sandwich
    @baloney_sandwich 2 месяца назад

    No corporate developers use vscode. There’s so much work to do and so much integration but vscode is just a skeleton program and all companies disable vscode market place.

  • @hoegge
    @hoegge 8 месяцев назад

    It is not an API - it is a backend framework / library

    • @atetraxx
      @atetraxx 8 месяцев назад

      What do you think an API is?

    • @hoegge
      @hoegge 8 месяцев назад

      @@atetraxx An API is (application programming interface) is originally an interface to interact with an application, i.e., could be the objects you interact with in Visual Basic for Applications, it could be a way to automated things in a CAD program via. Python, or control a music program like Ableton Live from objects in Max for Live. Of course it can also be a way to interact with a bigger system over a network interface, hence the term being used in web development. If you have a service, where there is an API for users to get the data or update things, that interface is an API. When developing an application that consists of both a backend and a front-end to be complete, the HTTP (REST or not) interface, is not really an API, but a communication interface inside the "application" between front-end and backend. Over time it became good practice to use the same interface for your own app as the one you provided to users / customers - i.e., the internal client/server communication became the same as the API for others, and therefore people began to call that API too. But in general it is not an API. Finally, the framework or library to create a service (e.g. Node, Django, Deno, Bun, whatever, and tools like Express etc) are not an API - they are API SDKs - or actually they are "server SDKs". So FastAPI is an server SDK that can also be used to make APIs, if you want to connect to an application that way.

  • @handsomelyhung
    @handsomelyhung 9 месяцев назад +2

    Why this dude accent sound like he from Arkansas and England? 😂😂😂

    • @TravisMedia
      @TravisMedia  9 месяцев назад +1

      😂😂😂 I think you nailed it. I get asked all the time, and I'm like "Umm I'm from Virginia.?" But most people guess either the south US or England. England though, really? The other two I get are that I'm from NY (??? what) and of course, I have a hundred comments on YT saying I sound like Obama. Whatever it is, you all keep me laughing about it.

  • @zeus7914
    @zeus7914 8 месяцев назад

    i feel that using the command prompt is a large step backwards. i had to stop right there.

    • @kennedymuhumuza283
      @kennedymuhumuza283 5 месяцев назад

      Use anaconda prompt

    • @kennedymuhumuza283
      @kennedymuhumuza283 5 месяцев назад

      Use anaconda prompt

    • @ipodtouch470
      @ipodtouch470 5 месяцев назад

      Nope the terminal is a crucial feature and something all developers should at least familiarize themselves with

  • @user-tz3cw5hy6k
    @user-tz3cw5hy6k 8 месяцев назад

    travis you got a lil twang in your voice lol. You grew up in the south lmao?

  • @thedoctor5478
    @thedoctor5478 4 месяца назад

    Socketify

  • @eskomo34
    @eskomo34 8 месяцев назад

    Anything python is an immediate no from me. Python is just a trend and the language has nothing good going for it.

    • @publicname
      @publicname 8 месяцев назад +2

      chatgpt written in python

  • @svyatoslavartyukhov2692
    @svyatoslavartyukhov2692 9 месяцев назад +4

    maaaan
    I know it's the lesson for dummies, but cmon, don't teach them bad things from start, ```for todo in todos```? rly? If your subs started with fastapi they should know about dicts...right???

    • @dirtslayer123
      @dirtslayer123 9 месяцев назад +1

      he goes on to explain that you would replace the array with a database - point was to create endpoints

  • @anonymous_anonymity
    @anonymous_anonymity 9 месяцев назад +32

    Why we need to learn? No we do not need to learn.

    • @i_clock4783
      @i_clock4783 8 месяцев назад +9

      Bro if you want you can learn it it's not required that you learn it

    • @HypnosisBear
      @HypnosisBear 8 месяцев назад +15

      That's your EGO speaking there buddy. If you don't wanna learn you can happily leave. Nobody's forcing you.

    • @illuminated2438
      @illuminated2438 8 месяцев назад +1

      What rebels!

    • @yehudamakarov
      @yehudamakarov 8 месяцев назад

      Loving it good comment :p

    • @Action2me
      @Action2me 7 месяцев назад +3

      It’s not literal. The “NEED” is for emphasis.

  • @antonpictures
    @antonpictures 9 месяцев назад

    Bro. I subscribed, them went to join your “community” and you ask for $15. Come on man. Let me join , let’s start building an llm app together, team community, and then after we become friends ask me for 15, disappointed. Unsubscribed. Scam.

    • @TravisMedia
      @TravisMedia  9 месяцев назад +3

      Not sure what the problem is here. The community is extra, optional, and outside of RUclips.

  • @thewelder3538
    @thewelder3538 8 месяцев назад

    There are NO fast APIs. They're just things that people who want to be called "programmers" use. Nothing that has to be Base64 encoded should ever be considered to be fast.

  • @user-xm2nq3ek7y
    @user-xm2nq3ek7y 9 месяцев назад

    Azure functions are better. Fastapi isnt supported on windows when deployment so useless framework

    • @bakasenpaidesu
      @bakasenpaidesu 9 месяцев назад +6

      Lol imagine deploying in windows 😂

  • @ahmedmusawir
    @ahmedmusawir 4 месяца назад

    You my friend are simply Awesome!! Now I know Fastapi... thanx!

  • @joyavila6254
    @joyavila6254 3 месяца назад

    I tried to follow your tutorial, however I got this error "$ uvicorn main:app --reload
    bash: uvicorn: command not found" . What did I missed?

  • @zbyszeks3657
    @zbyszeks3657 Месяц назад

    4:05 source venv/bin/activate?
    if ms win? maybe: venv\Scripts\activate

  • @anyak885
    @anyak885 25 дней назад

    venv\Scripts\activate for those on Windows

  • @ratzule
    @ratzule Месяц назад

    Thanks!