/ justapi / docs / migrating_from_fastapi.md
swadhinbiswas docs: add MkDocs site with API reference, migration guide, and security docs · 7/10/2026
626927d
42 lines · 906 Bytes
Raw Download

Migrating from FastAPI

JustAPI aims for high compatibility with FastAPI. In most cases, migration is as simple as changing imports.

Import Changes

# FastAPI
from fastapi import FastAPI, Depends, HTTPException

# JustAPI
from justapi import JustAPIApp, Depends, HTTPException

The Application Object

Replace FastAPI() with JustAPIApp():

# FastAPI
app = FastAPI()

# JustAPI
app = JustAPIApp()

Middlewares

Middleware in JustAPI acts exactly like FastAPI middlewares using the http interceptor:

@app.middleware("http")
async def process_time_header(request, call_next):
    # Your logic
    response = await call_next(request)
    return response

Performance Differences

Once you switch, you should immediately notice a dramatic drop in CPU overhead for routing and connection handling, translating to much higher throughput under load.