Introduction to Air
What is Air?
Air is a Python web framework built on top of FastAPI that enables you to build both elegant HTML interfaces and powerful REST APIs within a single application. Air streamlines common web development workflows while maintaining the flexibility and power of the underlying FastAPI ecosystem.
Key concepts:
- Web Framework: A structured approach to building web applications
- API (Application Programming Interface): Programmatic interfaces for data exchange
- HTML: The markup language for web browsers
- Python: The programming language underlying our applications
Key Features of Air
-
Air Tags: Python classes that generate HTML, offering type safety and IDE autocompletion while maintaining clean Python syntax. For example,
air.H1("Hello")generates an HTML heading<h1>Hello</h1>. -
Layouts: Intelligent document structure handling that automatically separates head and body content, eliminating boilerplate and providing styling options.
-
Streamlined Routing: Direct mapping between Python functions and URL endpoints with both decorator-based and conventional routing patterns.
-
Pydantic-Powered Forms: Built-in form validation and processing using Pydantic models, providing robust data handling with type safety.
-
HTMX Integration: Native support for HTMX's progressive enhancement approach, enabling dynamic interfaces without client-side JavaScript frameworks.
-
Jinja Compatibility: Seamless integration with Jinja2 templating for teams preferring traditional Jinja templates HTML generation.
-
Database Agnostic: Works with any Python database library (SQLAlchemy, Tortoise ORM, etc.)
-
Unified Application Architecture: First-class support for serving both HTML interfaces and API endpoints from a single codebase.
Why Choose Air?
Air is ideal for developers who want to:
- Build modern, interactive web applications quickly without heavy frontend frameworks
- Leverage FastAPI's ecosystem without HTML response boilerplate
- Create unified applications serving both UI and API clients
- Maintain type safety and IDE support throughout development
- Work with Pythonic, readable code patterns
Philosophy of Air
Air prioritizes these principles:
- Developer Experience: Intuitive, discoverable APIs that follow Python conventions
- Pythonic Design: Leverages Python's natural syntax and type system
- Type Safety: Full type hinting for better development tooling and error prevention
- Flexibility: Accommodates various architectural patterns and team preferences
- Productivity: Reduces boilerplate while preserving power for complex applications
- Frontend Simplicity: Embrace modern web practices without heavy client-side dependencies
- Documentation: Comprehensive yet well tested guides and references to support developers at all levels