LibraryActive

FastAPI WebSockets

FastAPI's WebSocket support, provided by Starlette and importable from fastapi.

Open source page

Product features

Product features

accept and close

Async accept and close methods to manage the connection.

fastapi.Body ¶

fastapi.Cookie ¶

fastapi.File ¶

fastapi.Form ¶

fastapi.Header ¶

fastapi.Path ¶

fastapi.Query ¶

fastapi.WebSocket

WebSocket class with scope, app, url, base_url, headers, query_params, path_params, cookies, client, state attributes.

Iter message helpers

iter_text, iter_bytes, iter_json for iterating incoming messages.

receive and send

Async receive and send methods for raw messages.

Request Parameters ¶

Typed message helpers

receive_text, receive_bytes, receive_json, send_text, send_bytes, send_json.

url_for

url_for method on the WebSocket.

WebSocketDisconnect

Additional class with code and reason attributes.

WebSocketState

States CONNECTING, CONNECTED, DISCONNECTED, RESPONSE.