Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
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.
async def post(self, request: web.Request, entity_id: str) -> web.Response:
"""Update state of entity."""
user: User = request[KEY_HASS_USER]
if not user.is_admin:
raise Unauthorized(entity_id=entity_id)
hass = request.app[KEY_HASS]
body = await request.text()
try:
data: Any = json_loads(body) if body else None
except ValueError:
return self.json_message("Invalid JSON specified.", HTTPStatus.BAD_REQUEST)
if not isinstance(data, dict):
return self.json_message(
"State data should be a JSON object.", HTTPStatus.BAD_REQUEST
)
if (new_state := data.get("state")) is None:
return self.json_message("No state specified.", HTTPStatus.BAD_REQUEST)
attributes = data.get("attributes")
force_update = data.get("force_update", False)
is_new_state = hass.states.get(entity_id) is None
# Write state try:
hass.states.async_set(
entity_id, new_state, attributes, force_update, self.context(request)
)
except InvalidEntityFormatError:
return self.json_message(
"Invalid entity ID specified.", HTTPStatus.BAD_REQUEST
)
except InvalidStateError:
return self.json_message("Invalid state specified.", HTTPStatus.BAD_REQUEST)
# Read the state back for our response status_code = HTTPStatus.CREATED if is_new_state else HTTPStatus.OK
if (state := hass.states.get(entity_id)) is None:
return self.json_message(
"Error storing state.", HTTPStatus.INTERNAL_SERVER_ERROR
)
return web.Response(
body=state.as_dict_json,
content_type=CONTENT_TYPE_JSON,
status=status_code,
headers={"Location": f"/api/states/{entity_id}"},
)
FastAPI
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.
def create_app(
superset_config_module: Optional[str] = None,
superset_app_root: Optional[str] = None,
) -> Flask:
app = SupersetApp(__name__)
try:
# Allow user to override our config completely config_module = superset_config_module or os.environ.get(
"SUPERSET_CONFIG", "superset.config"
)
app.config.from_object(config_module)
# Allow application to sit on a non-root path # *Please be advised that this feature is in BETA.* app_root = cast(
str,
superset_app_root
or os.environ.get("SUPERSET_APP_ROOT")
or app.config["APPLICATION_ROOT"],
)
# Normalize once at the source: a trailing slash ("/myapp/") would # otherwise leak into STATIC_ASSETS_PREFIX ("/myapp//static/...") # and APPLICATION_ROOT (the session-cookie path). The middlewares # below re-normalize defensively, but every consumer derives from # this value. app_root = app_root.rstrip("/") or "/"
if app_root != "/":
# If not set, manually configure options that depend on the # value of app_root so things work out of the box if not app.config["STATIC_ASSETS_PREFIX"]:
app.config["STATIC_ASSETS_PREFIX"] = app_root
# Prefix APP_ICON with the static assets prefix so the brand logo # resolves in subdirectory and CDN deployments alike. Using # STATIC_ASSETS_PREFIX (which defaults to app_root just above) # honours a custom CDN/static prefix when the operator sets one. if app.config.get("APP_ICON", "").startswith("/static/"):
app.config["APP_ICON"] = (
f"{app.config['STATIC_ASSETS_PREFIX']}{app.config['APP_ICON']}"
)
if app.config["APPLICATION_ROOT"] == "/":
app.config["APPLICATION_ROOT"] = app_root
app_initializer = app.config.get("APP_INITIALIZER", SupersetAppInitializer)(app)
app_initializer.init_app()
# Must be applied before AppRootMiddleware so the path prefix # is stripped before the extension asset path regex runs. app.wsgi_app = ExtensionCacheMiddleware(app.wsgi_app)
if app_root != "/":
app.wsgi_app = AppRootMiddleware(app.wsgi_app, app_root)
# Final WSGI wrap — must be outermost so it sees the raw inbound # PATH_INFO and 308s legacy `/superset/*` paths before any other # routing runs. Unconditional (independent of `app_root != "/"`) # because legacy bookmarks exist under root deployments too. # See the "Layering invariant" section of the module docstring # in `superset/middleware/legacy_prefix_redirect.py`. # mypy reads `app.wsgi_app` as `object` after the conditional # `AppRootMiddleware` rewrap above — the LUB of the two branches # widens it. The runtime type is always a WSGI callable; the # `# type: ignore` is intentional. app.wsgi_app = LegacyPrefixRedirectMiddleware(
app.wsgi_app, # type: ignore[arg-type]
app_root,
)
# Set up LOCAL_EXTENSIONS file watcher when in debug mode if app.debug:
start_local_extensions_watcher_thread(app)
return app
# Make sure that bootstrap errors ALWAYS get logged except Exception:
logger.exception("Failed to create app")
raise
Tornado
Provides a Python web framework and asynchronous networking library.
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.