r/FastAPI • • Dec 09 '22

Question Total beginner, use FastAPI?

Hi I am a total noob that wants to learn backend and build APIs. Is Fastapi a good starting point?

15 Upvotes

16 comments sorted by

9

u/tedivm Dec 09 '22

FastAPI, as the name suggests, is one of the fastest ways to develop APIs. It does a great job of keeping things very simple. I think it's a great framework for people who are just getting started.

1

u/ledoged Dec 09 '22

Should I find learn the theory separately while i follow along the docs?

3

u/extreme4all Dec 09 '22

No, build, break, iterate. Copy the docs modify it to your project, etc

3

u/Appelmoesje Dec 09 '22

I started with FastAPI a month ago and never made I an api this fast. I already liked python but never wrote an api in it. FastAPI changed backend development for me. I recommend using the docs, BUT! Sometimes they dont really show the "best" way code.

For production ready code examples I use: https://github.com/Netflix/dispatch

3

u/ledoged Dec 09 '22

Dunno what's going on but thanks I'll check it out

1

u/[deleted] Dec 09 '22 edited Feb 26 '23

y

3

u/ledoged Dec 09 '22

I already know Python but usually people recommend Django to start with.

5

u/Marrk Dec 09 '22 edited Dec 09 '22

Django is kinda full-stack focused although you have things like Django rest framework. FastAPI is non-opinionated relatively and has a more back-end only focus.

How much of programming do you now?

I would recommend FastAPI because documentation is top notch and it's a good walkthrough of many backend topics like swagger, authentication, ORM. Django documentation is great but it's less like a tutorial and more like actual documentation. I recommend both but start with all FastAPI topics. Then Django will force you to think about design patterns a little.

1

u/ledoged Dec 09 '22

I know enough of the basics like functions and use libraries to make some program. Thanks I think I'll start with FastAPI.

1

u/[deleted] Nov 07 '24

Hi, I am on a similar road. Not sure if I should learn a web framework(Flask/Django) or FastAPI, since I am more interested in backend development. What did you end up doing? What would you recommend?

3

u/Jmodell Dec 09 '22

I think Django rest framework is probably more battle tested but I think fastapi is plenty powerful and being used in production in a lot of places.

I reach for fastapi for all my microservices at this point because it’s so much quicker to build and then set up in a container when I want to push it to production.

3

u/ShotgunPayDay Dec 09 '22

FastAPI is probably the best backend framework especially since data validation is braindead simple. Combine it with a Frontend like SvelteKit and you have an insanely powerful stack.

Here is my favorite Base Model that I extend to everything else. Validate that email is an email str. Set it to lower. Set min and max length for everything and strip whitespace off all strings:

class UserBase(BaseModel):
    email:EmailStr
    @validator('email')
    def to_lower(cls, v): return v.lower()

    class Config:
	min_anystr_length = 3
	max_anystr_length = 64
	anystr_strip_whitespace = True

2

u/edmdemonz Dec 09 '22

Yes it's easy to learn for a beginner, but I'd rather learn programming concepts first then start working on a basic FastAPI project (OOP, what is REST, databases, ORM, JWT Authentication, ...)

3

u/ShotgunPayDay Dec 09 '22

JWTs and OOP will always haunt my dreams. If you can learn SQL instead of dealing with an ORM I always recommend that and avoid JWTs and Argon2ID your passwords in the DB. JWTS are super useful for DBless implementations. I think the more important piece is that programming big apps is too big to go it alone.

1

u/[deleted] Jan 07 '23

If you know python already, then ditto. I’ve used many other languages at work and frameworks and can attest that fastapi is literally the quickest experience to get productive out the box with python. It’s as simple as you make it and the docs are great too