How to Run Your First FastAPI App?

The Beginner-Friendly Blueprint You Wish You Had on Day One

How to Run Your First FastAPI App?
Photo by Douglas Lopes / Unsplash

You remember that moment when you wrote your first @app.get("/") and expected the universe to applaud?

Yeah. Same.

Running your first API app is one of those rites of passage in backend engineering—like your first failing migration, your first mysterious 500, or the first time you accidentally deleted a database because “it looked like staging.”

So here’s the clean, practical, no–BS guide I wish someone had handed me years ago.

By the end of this post, you’ll spin up your first API app with confidence—and, more importantly, understand what’s actually happening under the hood.

Step 1: Pick the Tool (FastAPI + Uvicorn, Because We Love Ourselves)

There are dozens of frameworks out there.

But for this guide, we’re going with FastAPI — a modern, async-first, beginner-friendly framework that teaches you good habits from day one.

install it:

pip install fastapi uvicorn

That uvicorn package?

That’s your ASGI server. Think of it as the engine that actually runs FastAPI and handles your requests.

Step 2: Create the Smallest, Cleanest API App Possible

Create a file called main.py:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"message": "It lives!"}

This is a minimal FastAPI service.

A “hello world” for backend folks.

You have:

  • A FastAPI app instance.
  • A single GET route.
  • A JSON response.

Beautiful. Simple. No unnecessary magic.

Step 3: Run the Server (AKA: The Moment It Feels Real)

This is where the adrenaline kicks in.

Run the app:

uvicorn main:app --reload

Breakdown:

  • main → the filename (without .py)
  • app → the FastAPI instance inside that file
  • --reload → auto-reload the server on code changes (use it locally only)

Open your browser and go to:

http://127.0.0.1:8000

Boom.

Your first API response.

But here’s the fun part — try this:

http://127.0.0.1:8000/docs

FastAPI automatically generates interactive API docs using Swagger UI.

You can test your API right from the browser.

No Postman. No cURL copy-paste gymnastics.

Step 4: Understand What You Just Did

Let’s slow down and unpack it:

1. Your Python code defined the API.

Those decorators (@app.get) create routes.

Functions define your logic.

2. Uvicorn is your server.

It listens for HTTP requests and hands them to FastAPI.

3. FastAPI handles routing, validation, and response formatting.

Automatically. Without shouting at you.

4. Your machine is now running an ASGI web service.

That’s… actually kind of wild when you think about it.

Step 5: Experiment (This Is Where Learning Happens)

Add another route:

@app.get("/hello/{name}")
def greet(name: str):
    return {"message": f"Hello, {name}!"}

Now visit:

http://127.0.0.1:8000/hello/John

Or try something weird:

/hello/Master-Chief  
/hello/Space-Cowboy  
/hello/Maybe-Don't-Use-Spaces

Suddenly this API feels like yours.

And that emotional connection matters — you’ll stick with it.

Step 6: What Happens Next?

Running your first API is step one.

But you’re not building API toys — you’re building API services.

From here, the path usually goes like this:

  1. Add data models
  2. Add validation with Pydantic
  3. Add a database
  4. Split your project into modules
  5. Add auth
  6. Add tests
  7. Containerize and deploy

Don’t panic.

We’ll go through all of it together on Backend Path.

But for now?
Celebrate this little win.

You got your first API running.
You’re officially in the game.

Your Takeaway

Running your first API app isn’t supposed to feel overwhelming.
It’s supposed to feel empowering.

You wrote a few lines of code.
You launched a local server.
You hit an endpoint.
You returned JSON.

That’s backend engineering in its purest form.

Small steps.
Clean systems.
Strong foundations.

Welcome to Backend Path.
Let’s build the real stuff next.