README.md
1# reqwest
2
3[![crates.io](https://img.shields.io/crates/v/reqwest.svg)](https://crates.io/crates/reqwest)
4[![Documentation](https://docs.rs/reqwest/badge.svg)](https://docs.rs/reqwest)
5[![MIT/Apache-2 licensed](https://img.shields.io/crates/l/reqwest.svg)](./LICENSE-APACHE)
6[![CI](https://github.com/seanmonstar/reqwest/workflows/CI/badge.svg)](https://github.com/seanmonstar/reqwest/actions?query=workflow%3ACI)
7
8An ergonomic, batteries-included HTTP Client for Rust.
9
10- Plain bodies, JSON, urlencoded, multipart
11- Customizable redirect policy
12- HTTP Proxies
13- HTTPS via system-native TLS (or optionally, rustls)
14- Cookie Store
15- WASM
16- [Changelog](CHANGELOG.md)
17
18
19## Example
20
21This asynchronous example uses [Tokio](https://tokio.rs) and enables some
22optional features, so your `Cargo.toml` could look like this:
23
24```toml
25[dependencies]
26reqwest = { version = "0.10", features = ["json"] }
27tokio = { version = "0.2", features = ["full"] }
28```
29
30And then the code:
31
32```rust,no_run
33use std::collections::HashMap;
34
35#[tokio::main]
36async fn main() -> Result<(), Box<dyn std::error::Error>> {
37 let resp = reqwest::get("https://httpbin.org/ip")
38 .await?
39 .json::<HashMap<String, String>>()
40 .await?;
41 println!("{:#?}", resp);
42 Ok(())
43}
44```
45
46## Blocking Client
47
48There is an optional "blocking" client API that can be enabled:
49
50```toml
51[dependencies]
52reqwest = { version = "0.10", features = ["blocking", "json"] }
53```
54
55```rust,no_run
56use std::collections::HashMap;
57
58fn main() -> Result<(), Box<dyn std::error::Error>> {
59 let resp = reqwest::blocking::get("https://httpbin.org/ip")?
60 .json::<HashMap<String, String>>()?;
61 println!("{:#?}", resp);
62 Ok(())
63}
64```
65
66## Requirements
67
68On Linux:
69
70- OpenSSL 1.0.1, 1.0.2, 1.1.0, or 1.1.1 with headers (see https://github.com/sfackler/rust-openssl)
71
72On Windows and macOS:
73
74- Nothing.
75
76Reqwest uses [rust-native-tls](https://github.com/sfackler/rust-native-tls),
77which will use the operating system TLS framework if available, meaning Windows
78and macOS. On Linux, it will use OpenSSL 1.1.
79
80
81## License
82
83Licensed under either of
84
85- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://apache.org/licenses/LICENSE-2.0)
86- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
87
88### Contribution
89
90Unless you explicitly state otherwise, any contribution intentionally submitted
91for inclusion in the work by you, as defined in the Apache-2.0 license, shall
92be dual licensed as above, without any additional terms or conditions.
93