faucet-stream
A declarative, config-driven REST API client for Rust with pluggable authentication, pagination, and JSONPath extraction.
Inspired by Meltano's RESTStream — but for Rust, and as a reusable library.
Features
- Authentication — Bearer, Basic, API Key, OAuth2 (client credentials), or custom headers
- Pagination — cursor/token (JSONPath), page number, offset/limit, Link header
- JSONPath extraction — point at where records live in any JSON response
- Retries with backoff — exponential backoff with configurable limits
- Typed deserialization — get
Vec<Value>or deserialize directly into your structs - Async-first — built on
reqwest+tokio
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
Cursor-based pagination with Bearer auth
use ;
async
Page-number pagination with API key
use ;
let stream = new?;
Offset pagination with Basic auth
use ;
use Duration;
let stream = new?;
OAuth2 client credentials
use ;
let token = fetch_oauth2_token.await?;
let config = new
.auth;
Typed deserialization
use Deserialize;
use ;
let stream = new?;
let users: = stream..await?;
Pagination Styles
| Style | Use When |
|---|---|
Cursor |
API returns a next-page token in the response body |
PageNumber |
API uses ?page=1&per_page=100 style |
Offset |
API uses ?offset=0&limit=50 style |
LinkHeader |
API returns pagination in Link HTTP header (GitHub-style) |
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.