Skip to content

Streaming responses

Async streaming responses for endpoints that produce large or open-ended payloads. See the Responses guide for buffering, encoder customisation, and SSE reconnection notes.

StreamingJSONListResponse

StreamingJSONListResponse(
    async_iterable, *, encoder=None, **kwargs
)

Bases: StreamingHttpResponse

Streams a JSON array one element at a time from an async iterable. Useful for endpoints that return a long list without buffering the whole response in memory.

NDJSONResponse

NDJSONResponse(async_iterable, *, encoder=None, **kwargs)

Bases: StreamingHttpResponse

Streams newline-delimited JSON, one object per line, from an async iterable. Useful for log-style endpoints and clients that consume incremental updates.

SSEResponse

SSEResponse(async_iterable, **kwargs)

Bases: StreamingHttpResponse

Streams Server-Sent Events from an async iterable. Items may be strings or dicts.