Squadbase
Squadbase Docs

FastAPI

Learn how to leverage Squadbase's features with FastAPI.

FastAPI is a modern, fast web framework for building APIs with Python. It offers high performance, automatic API documentation, and type safety, making it perfect for developing robust web APIs.

Squadbase provides comprehensive support for FastAPI applications with the following features:

  • Automated deployment from GitHub repositories to cloud environments
  • Built-in API key authentication and security
  • Log monitoring

Resources

Get started with these essential FastAPI resources:

Creating a New FastAPI Application

This guide shows you how to create a FastAPI application using uv, our recommended package manager for Python projects.

Start by initializing your project and installing the necessary dependencies:

Terminal
uv init my-fastapi-app
cd my-fastapi-app
Terminal
uv add fastapi uvicorn

Now create your main application file:

main.py
from fastapi import FastAPI
 
app = FastAPI()
 
@app.get("/")
def read_root():
    return {"Hello": "World"}
 
 
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

Launch your FastAPI application with hot reloading:

Terminal
uv run uvicorn main:app --reload

Your FastAPI application is now ready for development! 🎉

Test your API to ensure everything is working:

Terminal
curl http://127.0.0.1:8000/

For comprehensive FastAPI documentation and tutorials, visit the FastAPI Official Documentation.

Deploying with GitHub Integration

Setting up squadbase.yml

Create a squadbase.yml configuration file in your project root. For a typical FastAPI project with main.py and pyproject.toml, your file structure should look like this:

main.py
pyproject.toml
squadbase.yml

Here's a minimal squadbase.yml configuration:

squadbase.yml
# squadbase.yml
version: '1'
 
build:
  framework: fastapi
  runtime: python3.11  # Supported: python3.9, python3.10, python3.11, python3.12, python3.13
  package_manager: uv # Supported: pip, poetry, uv
  entrypoint: main:app

For advanced configuration options, see our squadbase.yml reference.

If you need to customize your deployment environment (e.g., install system packages) or want to inspect the generated Dockerfile, check out our Docker framework guide.

Connecting Your GitHub Repository

Import your GitHub repository through the Squadbase dashboard. Deployment will begin automatically once the import process completes.

Continuous Deployment

Make changes to your application and push them to your GitHub repository. Squadbase will automatically detect the changes and deploy the new version.

Monitoring and Logs

Squadbase provides comprehensive log monitoring for your deployed applications. You can view logs for each deployment and track application performance across different versions.

Log Monitoring

On this page