Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Logo

FastOpenAPI is a library for generating and integrating OpenAPI schemas using Pydantic and various frameworks.

This project was inspired by FastAPI and aims to provide a similar developer-friendly experience.

PyPI Downloads


📦 Installation

Install only FastOpenAPI:

pip install fastopenapi

Install FastOpenAPI with a specific framework:

pip install fastopenapi[aiohttp]
pip install fastopenapi[falcon]
pip install fastopenapi[flask]
pip install fastopenapi[quart]
pip install fastopenapi[sanic]
pip install fastopenapi[starlette]
pip install fastopenapi[tornado]
pip install fastopenapi[django]

🛠️ Quick Start

Step 1. Create an application

  • Create the main.py file
  • Copy the code from an example
  • For some examples uvicorn is required (pip install uvicorn)

Examples:

  • AIOHTTP

    Click to expand the AioHTTP Example
    from aiohttp import web
    from pydantic import BaseModel
    
    from fastopenapi.routers import AioHttpRouter
    
    app = web.Application()
    router = AioHttpRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    async def hello(name: str):
        """Say hello from aiohttp"""
        return HelloResponse(message=f"Hello, {name}! It's aiohttp!")
    
    
    if __name__ == "__main__":
        web.run_app(app, host="127.0.0.1", port=8000)
    
  • Falcon

    Click to expand the Falcon Example
    from falcon import App
    from pydantic import BaseModel
    from wsgiref.simple_server import make_server
    
    from fastopenapi.routers import FalconRouter
    
    app = App()
    router = FalconRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    def hello(name: str):
        """Say hello from Falcon"""
        return HelloResponse(message=f"Hello, {name}! It's Falcon!")
    
    
    if __name__ == "__main__":
        with make_server("", 8000, app) as httpd:
            print("Serving on port 8000...")
            httpd.serve_forever()
    
    Click to expand the Falcon Async Example
    import falcon.asgi
    import uvicorn
    from pydantic import BaseModel
    
    from fastopenapi.routers import FalconAsyncRouter
    
    app = falcon.asgi.App()
    router = FalconAsyncRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    async def hello(name: str):
        """Say hello from Falcon"""
        return HelloResponse(message=f"Hello, {name}! It's Falcon!")
    
    
    if __name__ == "__main__":
        uvicorn.run(app, host="127.0.0.1", port=8000)
    
  • Flask

    Click to expand the Flask Example
    from flask import Flask
    from pydantic import BaseModel
    
    from fastopenapi.routers import FlaskRouter
    
    app = Flask(__name__)
    router = FlaskRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    def hello(name: str):
        """Say hello from Flask"""
        return HelloResponse(message=f"Hello, {name}! It's Flask!")
    
    
    if __name__ == "__main__":
        app.run(port=8000)
    
  • Quart

    Click to expand the Quart Example
    from pydantic import BaseModel
    from quart import Quart
    
    from fastopenapi.routers import QuartRouter
    
    app = Quart(__name__)
    router = QuartRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    async def hello(name: str):
        """Say hello from Quart"""
        return HelloResponse(message=f"Hello, {name}! It's Quart!")
    
    
    if __name__ == "__main__":
        app.run(port=8000)
    
  • Sanic

    Click to expand the Sanic Example
    from pydantic import BaseModel
    from sanic import Sanic
    
    from fastopenapi.routers import SanicRouter
    
    app = Sanic("MySanicApp")
    router = SanicRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    async def hello(name: str):
        """Say hello from Sanic"""
        return HelloResponse(message=f"Hello, {name}! It's Sanic!")
    
    
    if __name__ == "__main__":
        app.run(host="0.0.0.0", port=8000)
    
  • Starlette

    Click to expand the Starlette Example
    import uvicorn
    from pydantic import BaseModel
    from starlette.applications import Starlette
    
    from fastopenapi.routers import StarletteRouter
    
    app = Starlette()
    router = StarletteRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    async def hello(name: str):
        """Say hello from Starlette"""
        return HelloResponse(message=f"Hello, {name}! It's Starlette!")
    
    if __name__ == "__main__":
        uvicorn.run(app, host="127.0.0.1", port=8000)
    
  • Tornado

    Click to expand the Tornado Example
    import asyncio
    
    from pydantic import BaseModel
    from tornado.web import Application
    
    from fastopenapi.routers import TornadoRouter
    
    app = Application()
    
    router = TornadoRouter(app=app)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    def hello(name: str):
        """Say hello from Tornado"""
        return HelloResponse(message=f"Hello, {name}! It's Tornado!")
    
    
    async def main():
        app.listen(8000)
        await asyncio.Event().wait()
    
    
    if __name__ == "__main__":
        asyncio.run(main())
    
  • Django

    Click to expand the Django Example
    from django.conf import settings
    from django.core.management import call_command
    from django.core.wsgi import get_wsgi_application
    from django.urls import path
    from pydantic import BaseModel
    
    from fastopenapi.routers import DjangoRouter
    
    settings.configure(DEBUG=True, SECRET_KEY="__CHANGEME__", ROOT_URLCONF=__name__)
    application = get_wsgi_application()
    
    router = DjangoRouter(app=True)
    
    
    class HelloResponse(BaseModel):
        message: str
    
    
    @router.get("/hello", tags=["Hello"], status_code=200, response_model=HelloResponse)
    def hello(name: str):
        """Say hello from django"""
        return HelloResponse(message=f"Hello, {name}! It's Django!")
    
    
    urlpatterns = [path("", router.urls)]
    
    if __name__ == "__main__":
        call_command("runserver")
    

Step 2. Run the server

Launch the application:

python main.py

Once launched, the documentation will be available at:

Swagger UI:

http://127.0.0.1:8000/docs

ReDoc UI:

http://127.0.0.1:8000/redoc

⚙️ Features

  • Generate OpenAPI schemas with Pydantic v2.
  • Data validation using Pydantic models.
  • Supports multiple frameworks: AIOHTTP, Falcon, Flask, Quart, Sanic, Starlette, Tornado, Django.
  • Proxy routing provides FastAPI-style routing

📖 Documentation

Explore the Docs for an overview of FastOpenAPI, its core components, and usage guidelines. The documentation is continuously updated and improved.


📂 Advanced Examples

Examples of integration and detailed usage for each framework are available in the examples directory.


📊 Quick & Dirty Benchmarks

Fast but not perfect benchmarks. Check the benchmarks directory for details.


✅ Development Recommendations

  • Use Pydantic models for strict typing and data validation.
  • Follow the project structure similar to provided examples for easy scalability.
  • Regularly update dependencies and monitor library updates for new features.

🛠️ Contributing

If you have suggestions or find a bug, please open an issue or create a pull request on GitHub.


🤝 Acknowledgements

JetBrains logo

Supported by JetBrains under the Open Source Support Program.


📄 License

This project is licensed under the terms of the MIT license.

Download files

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

Source Distribution

fastopenapi-1.0.0rc2.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

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

fastopenapi-1.0.0rc2-py3-none-any.whl (74.3 kB view details)

Uploaded Python 3

File details

Details for the file fastopenapi-1.0.0rc2.tar.gz.

File metadata

  • Download URL: fastopenapi-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1018-azure

File hashes

Hashes for fastopenapi-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 c64d0e4c7a07723ecc28e3982648ac3d02fc4e26cadb219339b5ad1c9597714d
MD5 cb8ec8d191d6ac0ba7293ae9d2eeee40
BLAKE2b-256 9b9d929f62bdc39b8151b0eb7cd30d3396f3c2471107c9aab84fa28bc0810eb2

See more details on using hashes here.

File details

Details for the file fastopenapi-1.0.0rc2-py3-none-any.whl.

File metadata

  • Download URL: fastopenapi-1.0.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 74.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1018-azure

File hashes

Hashes for fastopenapi-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 9271da3439800978ef931c7c0bd6bf2038871105c3282e921292dfee3e070116
MD5 5f4d26ec25cb6b66c37bbd0ffe41f498
BLAKE2b-256 ec5524c4a5acb013ec2d5050ee11ad8325ad313a940c1a7316eead49930201f4

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 Sentry Error logging StatusPage Status page