# Sanic — Async Python Web Framework Built for Speed > Sanic is an async Python web framework built for speed. Native async/await from the ground up, HTTP/1.1 and HTTP/2, WebSocket, streaming, and auto-generated API docs. Designed to be fast, flexible, and easy to use. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash pip install sanic ``` ```python from sanic import Sanic, json app = Sanic("TokRepo") @app.get("/api/assets") async def list_assets(request): return json([{"repo": "react", "stars": 230000}]) @app.post("/api/assets") async def create_asset(request): return json(request.json, status=201) if __name__ == "__main__": app.run(host="0.0.0.0", port=8000, auto_reload=True) ``` ## Intro Sanic is an async Python web framework built for speed. It was one of the first Python frameworks to embrace `async`/`await` natively (Python 3.5+), using uvloop for higher throughput. Features built-in server, WebSocket support, streaming, middleware, and auto-generated OpenAPI docs. - **Repo**: https://github.com/sanic-org/sanic - **Stars**: 18K+ - **Language**: Python - **License**: MIT ## What Sanic Does - **Async native** — `async def` handlers 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 --- Source: https://tokrepo.com/en/workflows/sanic-async-python-web-framework-built-speed-412ffff9 Author: Script Depot