6 releases (3 breaking)

new 0.4.1 Apr 29, 2025
0.4.0 Apr 29, 2025
0.3.0 Jan 9, 2025
0.2.0 May 4, 2024
0.1.1 Sep 28, 2023

#270 in HTTP client

Download history 1067/week @ 2025-01-13 904/week @ 2025-01-20 1113/week @ 2025-01-27 1283/week @ 2025-02-03 1222/week @ 2025-02-10 1943/week @ 2025-02-17 1802/week @ 2025-02-24 2100/week @ 2025-03-03 2136/week @ 2025-03-10 1694/week @ 2025-03-17 1779/week @ 2025-03-24 2149/week @ 2025-03-31 2275/week @ 2025-04-07 1931/week @ 2025-04-14 2316/week @ 2025-04-21 2109/week @ 2025-04-28

8,717 downloads per month
Used in 2 crates

MIT license

5KB

Middleware to rate-limit requests built on reqwest_middleware.

You're expected to provide your own RateLimiter implementation.

Example


reqwest-ratelimit

Rate-limit middleware implementation for reqwest-middleware.

This crate is glue code for implementing custom ratelimiters. For a batteries included example please refer to reqwest-leaky-bucket.

Crates.io Docs.rs

Usage

use std::future::Future;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};

struct RateLimiter;

impl reqwest_ratelimit::RateLimiter for RateLimiter {
    async fn acquire_permit(&self) {
        // noop
    }
}

async fn run() {
    let client = ClientBuilder::new(reqwest::Client::new())
        .with(reqwest_ratelimit::all(RateLimiter))
        .build();

    client.get("https://crates.io").send().await.unwrap();
}

Dependencies

~4–15MB
~189K SLoC