Skip to main content

The new Python web framework by the authors of Two Scoops of Django. Built with FastAPI, Starlette, and Pydantic.

Project description

Air 💨: The new web framework that breathes fresh air into Python web development. Built with FastAPI, Starlette, and Pydantic

CI - main CI - Latest Tag codecov GitHub License

PyPI - Version PyPI Total Downloads PyPI Monthly Downloads PyPI Weekly Downloads

Running on Windows macOS Ubuntu Python Versions

GitHub commit activity GitHub commits since latest release GitHub last commit GitHub Release Date

GitHub contributors Discord X Bluesky MkDocs

Frameworks FastAPI Pydantic Jinja Astral


[!CAUTION] Air is currently in an alpha state. While breaking changes are becoming less common, nevertheless, anything and everything could change.

[!IMPORTANT] If you have an idea for a new feature, discuss it with us by opening an issue before writing any code. Do understand that we are working to remove features from core, and for new features you will almost always create your own package that extends or uses Air instead of adding to this package. This is by design, as our vision is for the Air package ecosystem to be as much a "core" part of Air as the code in this minimalist base package.

Why use Air?

  • Powered by FastAPI - Designed to work with FastAPI so you can serve your API and web pages from one app
  • Fast to code - Tons of intuitive shortcuts and optimizations designed to expedite coding HTML with FastAPI
  • Air Tags - Easy to write and performant HTML content generation using Python classes to render HTML
  • Jinja Friendly - No need to write response_class=HtmlResponse and templates.TemplateResponse for every HTML view
  • Mix Jinja and Air Tags - Jinja and Air Tags both are first class citizens. Use either or both in the same view!
  • HTMX friendly - We love HTMX and provide utilities to use it with Air
  • HTML form validation powered by pydantic - We love using pydantic to validate incoming data. Air Forms provide two ways to use pydantic with HTML forms (dependency injection or from within views)
  • Easy to learn yet well documented - Hopefully Air is so intuitive and well-typed you'll barely need to use the documentation. In case you do need to look something up we're taking our experience writing technical books and using it to make documentation worth boasting about

Documentation: https://docs.airwebframework.org

Source Code: https://github.com/feldroy/air

Installation

Install using pip install -U air or conda install air -c conda-forge.

For uv users, just create a virtualenv and install the air package, like:

uv venv
source .venv/bin/activate
uv init
uv add air

Install optional features (with uv add)

You can install each optional feature (extras) like this:

  1. Standard — FastAPI’s recommended extras
    uv add "air[standard]"
    

Agentic Coding

The library and its dependencies are available through Context7. For effective AI assistance, register the Context7 MCP server in your coding environment and configure your agent to use it.

You can also use:

For the canonical long-form context, please use: llms-full.txt, it follows the llmstxt format.

A Simple Example

Create a main.py with:

import air

app = air.Air()


@app.get("/")
async def index():
    return air.Html(air.H1("Hello, world!", style="color: blue;"))

Run the app with:

air run

If you have fastapi installed globally, you may see an error:

To use the fastapi command, please install "fastapi[standard]":

	pip install "fastapi[standard]"

In that case, run the app with:

uv run air run

[!NOTE] This example uses Air Tags, which are Python classes that render as HTML. Air Tags are typed and documented, designed to work well with any code completion tool. You can also run this with uv run uvicorn main:app --reload if you prefer using Uvicorn directly.

Then open your browser to http://127.0.0.1:8000 to see the result.

Combining FastAPI and Air

Air is just a layer over FastAPI. So it is trivial to combine sophisticated HTML pages and a REST API into one app.

import air
from fastapi import FastAPI

app = air.Air()
api = FastAPI()


@app.get("/")
def landing_page():
    return air.Html(
        air.Head(air.Title("Awesome SaaS")),
        air.Body(
            air.H1("Awesome SaaS"),
            air.P(air.A("API Docs", target="_blank", href="/api/docs")),
        ),
    )


@api.get("/")
def api_root():
    return {"message": "Awesome SaaS is powered by FastAPI"}


# Combining the Air and FastAPI apps into one
app.mount("/api", api)

Combining FastAPI and Air using Jinja2

Want to use Jinja2 instead of Air Tags? We've got you covered.

import air
from air.requests import Request
from fastapi import FastAPI

app = air.Air()
api = FastAPI()

# Air's JinjaRenderer is a shortcut for using Jinja templates
jinja = air.JinjaRenderer(directory="templates")


@app.get("/")
def index(request: Request):
    return jinja(request, name="home.html")


@api.get("/")
def api_root():
    return {"message": "Awesome SaaS is powered by FastAPI"}


# Combining the Air and and FastAPI apps into one
app.mount("/api", api)

Don't forget the Jinja template!

<!doctype html>
<html>
    <head>
        <title>Awesome SaaS</title>
    </head>
    <body>
        <h1>Awesome SaaS</h1>
        <p>
            <a target="_blank" href="/api/docs">API Docs</a>
        </p>
    </body>
</html>

[!NOTE] Using Jinja with Air is easier than with FastAPI. That's because as much as we enjoy Air Tags, we also love Jinja!

Sponsors

Maintenance of this project is made possible by all the contributors and sponsors. If you would like to support this project and have your avatar or company logo appear below, please sponsor us. 💖💨

Consider this low-barrier form of contribution yourself. Your support is much appreciated.

Contributing

For guidance on setting up a development environment and how to make a contribution to Air, see Contributing to Air.

Contributors

Thanks to all the contributors to the Air 💨 web framework!

PyPI Stats

Star History

Star History Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

air-0.45.0.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

air-0.45.0-py3-none-any.whl (80.8 kB view details)

Uploaded Python 3

File details

Details for the file air-0.45.0.tar.gz.

File metadata

  • Download URL: air-0.45.0.tar.gz
  • Upload date:
  • Size: 73.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for air-0.45.0.tar.gz
Algorithm Hash digest
SHA256 9044b8a335d28cc5c148f7eb113cd612f4cff3ca67ab75f1ac4dc88fd5ef9f15
MD5 1ae891f55258a907c7386d9752ed6a97
BLAKE2b-256 6cbcfcf677d6764c6e45828c8d3adc7902a2baca13995706fcb9e5768f4c0eae

See more details on using hashes here.

File details

Details for the file air-0.45.0-py3-none-any.whl.

File metadata

  • Download URL: air-0.45.0-py3-none-any.whl
  • Upload date:
  • Size: 80.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for air-0.45.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14c12aaeb6800fe216ea9aed69141ec801c1bcaa81e65f5a9b16c5e683e619c0
MD5 a7fc540474d2133f8b9ebe34930be232
BLAKE2b-256 5c252a35b00ed14930d46c4113168bcdef185d9bbf59030f59f1bec86ef6a34f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page