89 releases

new 0.11.26 Mar 12, 2024
0.11.24 Jan 31, 2024
0.11.23 Dec 18, 2023
0.11.22 Oct 3, 2023
0.1.0 Nov 10, 2016

#2 in HTTP client

Download history 898518/week @ 2023-11-27 901176/week @ 2023-12-04 866692/week @ 2023-12-11 836876/week @ 2023-12-18 485410/week @ 2023-12-25 743590/week @ 2024-01-01 922509/week @ 2024-01-08 987165/week @ 2024-01-15 1044185/week @ 2024-01-22 1149331/week @ 2024-01-29 1133547/week @ 2024-02-05 1131881/week @ 2024-02-12 1088925/week @ 2024-02-19 1165409/week @ 2024-02-26 1162072/week @ 2024-03-04 487403/week @ 2024-03-11

3,976,262 downloads per month
Used in 11,558 crates (8,221 directly)

MIT/Apache

565KB
11K SLoC

reqwest

crates.io Documentation MIT/Apache-2 licensed CI

An ergonomic, batteries-included HTTP Client for Rust.

  • Plain bodies, JSON, urlencoded, multipart
  • Customizable redirect policy
  • HTTP Proxies
  • HTTPS via system-native TLS (or optionally, rustls)
  • Cookie Store
  • WASM
  • Changelog

Example

This asynchronous example uses Tokio and enables some optional features, so your Cargo.toml could look like this:

[dependencies]
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }

And then the code:

use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let resp = reqwest::get("https://httpbin.org/ip")
        .await?
        .json::<HashMap<String, String>>()
        .await?;
    println!("{resp:#?}");
    Ok(())
}

Blocking Client

There is an optional "blocking" client API that can be enabled:

[dependencies]
reqwest = { version = "0.11", features = ["blocking", "json"] }
use std::collections::HashMap;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let resp = reqwest::blocking::get("https://httpbin.org/ip")?
        .json::<HashMap<String, String>>()?;
    println!("{resp:#?}");
    Ok(())
}

Requirements

On Linux:

  • OpenSSL with headers. See https://docs.rs/openssl for supported versions and more details. Alternatively you can enable the native-tls-vendored feature to compile a copy of OpenSSL.

On Windows and macOS:

  • Nothing.

Reqwest uses rust-native-tls, which will use the operating system TLS framework if available, meaning Windows and macOS. On Linux, it will use the available OpenSSL or fail to build if not found.

License

Licensed under either of

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.

Dependencies

~3–24MB
~429K SLoC