reqwest-sse

A lightweight Rust library that adds Server-Sent Events support to the reqwest HTTP client.

Library
Cargo
v0.2.0
5stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
15/100Needs Attention
Development Activity16
Maintenance0
Community8
Maturity36
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality80
Innovation80
Learning Curve88

reqwest-sse is a small Rust library that extends the popular reqwest HTTP client with native support for Server-Sent Events (SSE). It introduces an EventSource trait that adds an ergonomic .events() method to reqwest’s Response, turning the response body into an asynchronous stream of parsed SSE Events.

Because it plugs directly into the familiar reqwest and StreamExt APIs, it lets you consume real-time event streams (LLM token streams, live notifications, log tails) without pulling in a separate client or writing your own SSE parser.

What You Get

  • An EventSource trait that adds a .events() method to reqwest’s Response
  • An async Stream of parsed SSE Events consumable with StreamExt
  • A structured Event type exposing event_type, data, last_event_id, and retry fields
  • Up-front validation of HTTP status and text/event-stream content type with typed errors
  • Seamless integration with the existing reqwest client and Tokio async runtime

Common Use Cases

  • Consuming streaming LLM/chat completion responses delivered as SSE
  • Subscribing to real-time notifications or live updates from an HTTP endpoint
  • Tailing server logs or progress events pushed over an event stream
  • Adding real-time features to an existing reqwest-based client without a new dependency stack

Under The Hood

Architecture - The crate is two small files: lib.rs defines the Event struct, the EventSource trait and its impl for reqwest’s Response, and the parsing that splits the byte stream into field: value lines and assembles them into events; error.rs holds the EventSourceError/EventError types. .events() first checks the status is 200 OK and the Content-Type is text/event-stream, then wraps the response body in an async_stream generator that yields parsed events. Tech Stack - Rust edition 2024 (MSRV 1.85) built on reqwest 0.13 (http2 + stream), async-stream, and Tokio’s stream/util crates for the async plumbing. Code Quality - Despite being under 300 lines, it includes unit tests for the SSE line-parsing logic and returns descriptive, typed errors rather than panicking. API Design - The extension-trait pattern makes adoption a single .events() call on an existing reqwest response, and the returned stream uses the standard StreamExt interface Rust async developers already know.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search