Fast API Flashcards
(12 cards)
What is Fast API?
FAPI is a fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
What are the key features of Fast API?
- Fast: on par with NodeJS and Go.
- Fast to code
- Fewer bugs
- Intuitive autocomplete
- ## Easy to use/learn
What big companies have used FastAPI?
Microsoft, Netflix, Cisco
What is FastAPI built on top of?
Starlette for web parts.
Pydantic for data parts.
How do you install FastAPI?
pip install “fastapi[standard]”. Quotes ensure it works in all terminals
How might the simplest possible Fast API main.py file look?
from fastapi import FastAPI
app = FastAPI()
@app.get(“/”)
def read_root():
. return {“Hello”: “World”}}
How to run your main.py FastAPI file?
fastapi dev main.py
What is the default port for FastAPI?
8000
How would you set up a get route for specific items?
@app.get(“/items/{item_id}”)
def read_item(item_id: int, query: str):
return {“item_id”: item_id, “query”: query}
How can you quickly see the routes that you’ve set up?
Go to port http://127.0.0.1:8000/docs in your browser or 8000/redocs (unofficial?)
What is Pydantic and how is it often used with FastAPI?