What Sanic Does
- Async native —
async defhandlers throughout - Built-in server — no external WSGI/ASGI server needed
- WebSocket — native support
- Streaming — request and response streaming
- Middleware — request/response lifecycle hooks
- Blueprints — modular route grouping
- OpenAPI — auto-generated API docs
- Signals — event-based hooks
- Background tasks — via
app.add_task()
Comparison
| Framework | Server | Speed |
|---|---|---|
| Sanic | Built-in (uvloop) | Very fast |
| FastAPI | Uvicorn | Very fast |
| Flask | Gunicorn | Medium |
| Tornado | Built-in | Fast |
FAQ
Q: Sanic vs FastAPI? A: FastAPI has Pydantic validation + automatic OpenAPI + a larger community; Sanic has a built-in server, more flexible middleware, and earlier async support. Most new API projects pick FastAPI.
Sources
- Docs: https://sanic.dev
- GitHub: https://github.com/sanic-org/sanic
- License: MIT