Python REST API libraries

Updated Nov 2026

Python REST API frameworks receive HTTP requests, route them to handler functions, and return JSON responses. An ASGI framework accepts async endpoints and runs them on an event loop rather than through synchronous WSGI workers. These libraries let backend services expose their data and actions to apps and AI agents over HTTP.

Popularity

Starlette has the most monthly downloads in this comparison, at 706.4M.

LibraryMonthly downloadsStarsLast releaseLicense
Starlette
706.4M
12.7KOct 2026BSD-3-Clause
aiohttp
562.2M
16.6KOct 2026Apache-2.0 AND MIT
FastAPI
544.0M
104.9KNov 2026MIT
Flask
208.0M
75.2KFeb 2026BSD-3-Clause
Tornado
122.3M
22.2KNov 2026Apache-2.0
Django
51.9M
91.8KNov 2026BSD-3-Clause
Django REST framework
30.2M
30.2KOct 2026BSD-3-Clause
Bottle
9.6M
8.8KJun 2025MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Builds web applications on ASGI.

Downloads / mo
706.4M
Stars
12.7K
Last release
1.10.0
License
BSD-3-Clause

Quickstart

From index.html
$ python -m pip install starlette==1.10.0 uvicorn
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route

async def status(request):
    return JSONResponse({"message": "Hello"})

app = Starlette(routes=[Route("/api/status", status)])

Serves and sends HTTP requests on asyncio.

Downloads / mo
562.2M
Stars
16.6K
Last release
3.14.5
License
Apache-2.0 AND MIT

Quickstart

From web_quickstart.html
$ python -m pip install aiohttp==3.14.5
from aiohttp import web

routes = web.RouteTableDef()

@routes.get("/api/status")
async def status(request):
    return web.json_response({"message": "Hello"})

app = web.Application()
app.add_routes(routes)
web.run_app(app)

aiohttp examples

From open-source projects on GitHub

Builds Python APIs with typed request models and generated OpenAPI documentation.

Downloads / mo
544.0M
Stars
104.9K
Last release
0.165.0
License
MIT

Strengths

  • Validates typed request bodies. Declare models to parse and validate JSON request bodies.
  • Generates interactive API documentation. Explore declared endpoints through the included Swagger UI.

Limitations

  • Blocking libraries need sync handlers. Use regular def when an I/O library cannot be awaited.

Quickstart

From body.md
$ python -m pip install "fastapi[standard]==0.165.0"
from fastapi import FastAPI

app = FastAPI()

@app.get("/api/status")
async def status():
    return {"message": "Hello"}

FastAPI examples

From open-source projects on GitHub

Provides a compact web framework that can serve Python HTTP APIs.

Downloads / mo
208.0M
Stars
75.2K
Last release
3.1.3
License
BSD-3-Clause

Strengths

  • Returns JSON from dictionaries. Return dictionaries or lists to create JSON responses.
  • Adds explicit API extensions. Use flask-smorest, a REST extension, for validation, and OpenAPI generation.

Limitations

  • Async views still occupy workers. Each request ties up a worker, including an async view.
  • Spawned background tasks are cancelled. Use a task queue instead of spawning work inside a view.

Quickstart

From api.md
$ python -m pip install Flask==3.1.3
from flask import Flask

app = Flask(__name__)

@app.get("/api/status")
def status():
    return {"message": "Hello"}

Flask examples

From open-source projects on GitHub

Provides a Python web framework and asynchronous networking library.

Downloads / mo
122.3M
Stars
22.2K
Last release
6.6.1
License
Apache-2.0

Quickstart

From web.html
$ python -m pip install tornado==6.6.1
import asyncio
import tornado.web

class StatusHandler(tornado.web.RequestHandler):
    def get(self):
        self.write({"message": "Hello"})

async def main():
    app = tornado.web.Application([(r"/api/status", StatusHandler)])
    app.listen(8888)
    await asyncio.Event().wait()

if __name__ == "__main__":
    asyncio.run(main())

Tornado examples

From open-source projects on GitHub

Provides a high-level Python web framework.

Downloads / mo
51.9M
Stars
91.8K
Last release
6.1.3
License
BSD-3-Clause

Quickstart

From README.md
$ python -m pip install Django==6.1.3
# demo/views.py
from django.http import JsonResponse

def status(request):
    return JsonResponse({"message": "Hello"})

# demo/urls.py
from django.urls import path
from .views import status

urlpatterns = [path("api/status", status)]

Django REST framework

Builds web APIs around Django models, serializers, and viewsets.

Downloads / mo
30.2M
Stars
30.2K
Last release
3.18.3
License
BSD-3-Clause

Strengths

  • Connects serializers and model views. Build model-backed APIs with serializers, viewsets, and automatic routing.
  • Reports structured validation errors. Call is_valid to validate data and inspect serializer errors.

Limitations

  • Built-in schemas are deprecated. Use drf-spectacular, an OpenAPI generator, for the recommended replacement.
  • Async path uses adrf. Use adrf, an async adapter, for coroutine-based views.

Quickstart

From generic-views.md
$ python -m pip install djangorestframework==3.18.3 Django==6.1.3
# demo/settings.py: append to generated project settings
INSTALLED_APPS += ["rest_framework"]

# demo/views.py
from rest_framework.decorators import api_view
from rest_framework.response import Response

@api_view(["GET"])
def status(request):
    return Response({"message": "Hello"})

# demo/urls.py
from django.urls import path
from .views import status

urlpatterns = [path("api/status", status)]

Django REST framework examples

From open-source projects on GitHub

Runs small web applications on WSGI.

Downloads / mo
9.6M
Stars
8.8K
Last release
0.13.4
License
MIT

Quickstart

From tutorial.html
$ python -m pip install bottle==0.13.4
from bottle import Bottle

app = Bottle()

@app.get("/api/status")
def status():
    return {"message": "Hello"}

app.run(host="127.0.0.1", port=8080)

FAQ

FastAPI suits new APIs that declare request models with Pydantic and generate OpenAPI documentation. Django REST framework suits Django projects that need serializers, generic views, and authentication. Flask suits small services with explicit routes.

aiohttp is an asyncio HTTP framework with a web server and a separate HTTP client in one package.

Django REST framework adds API serializers, parsers, generic views, authentication, and response rendering to Django.

Flask is a WSGI microframework that keeps routes and request handling explicit. Django is a full application framework with an ORM, authentication, and generic views.

FastAPI is an ASGI framework that validates requests against declared Pydantic models and generates OpenAPI documentation. Flask is a WSGI microframework whose async views stay inside the WSGI worker lifecycle.

Starlette is a low-level ASGI toolkit with routing, request and response objects, middleware, and async endpoints.

For coding agents

Found your REST API library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official