API Development
Caspian is built on top of FastAPI. Whether you need a dedicated backend service or hybrid API routes within your fullstack app, you have native access to high-performance async endpoints.
1
Backend-Only Mode
Best for when you want a standalone API service without the templating engine. This enables standard FastAPI features like automatic Swagger UI documentation by default.
Terminal
➜
~
npx create-caspian-app@latest
...
?
What is your project named?
› my-api
?
Would you like to create a backend-only project?
» Yes
Swagger UI
Automatic interactive docs available at /docs.
Lightweight
Disables the HTML rendering engine for maximum raw throughput.
2
Fullstack Hybrid Routes
In a fullstack application, you can mix UI pages and API endpoints.
Simply return a JSONResponse
from your page function to bypass the HTML renderer.
src/app/api/users/index.py
from fastapi import Request from fastapi.responses import JSONResponse # This function runs when you visit /api/users def page(request: Request): # Perform your logic (DB queries, etc.) users = [ {"id": 1, "name": "Jefferson"}, {"id": 2, "name": "Alice"} ] # Return JSONResponse to bypass Caspian's HTML renderer return JSONResponse(content={"data": users})
How it works: Caspian checks the return type of your
page() function.
If it sees a FastAPI Response object (like JSONResponse), it skips the Jinja2 template engine entirely,
giving you raw API performance.