Member-only story

FastAPI: In Just 1 Minute Create Your First API Using FastAPI

2 min readJan 29, 2024
Photo by Rene Böhmer on Unsplash

Fastapi is an another most popular framework of python for building powerful web api’s just like Django. FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints. python for building powerful web api’s just like Django. FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.

Installation

Before move to create our first api, let’s install these two required dependencies.

pip install fastapi
pip install "uvicorn[standard]"

Let’s create an API

Now create a main.py file and open it in any code editor.

# main.py


from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
    return {"Hello": "World"}

Run the Server

To start the development server just hit this command in your terminal.

uvicorn main:app --reload

It will start the development server on the default port 8000

INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

--

--

Aashish Kumar
Aashish Kumar

Written by Aashish Kumar

Hi, I’m Aashish Kumar, a passionate software engineer from India 🇮🇳, specialize in Python | Django | AI | LLM | Full Stack Development.

No responses yet