Cogs and Levers A blog full of technical stuff

reqwest

Making HTTP requests manually with hyper is powerful. But often unnecessary.

reqwest is the ergonomic HTTP client most Rust applications use. It’s built on top of hyper and integrates with Tokio.

What Problem Does reqwest Solve?

Simple, ergonomic HTTP client API with:

  • JSON support
  • TLS
  • Async support
  • Redirect handling

Without wiring everything manually.

Minimal Example (Async)

Cargo.toml

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

main.rs

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Ip {
    origin: String,
}

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let res = reqwest::get("https://httpbin.org/ip")
        .await?
        .json::<Ip>()
        .await?;

    println!("{res:?}");

    Ok(())
}

What’s Actually Happening?

reqwest:

  • Builds on hyper
  • Uses Tokio for async I/O
  • Integrates with serde for JSON

You get a high-level API without losing performance.

Where It Fits

Use reqwest when:

  • Calling APIs
  • Writing CLI tools that hit HTTP endpoints
  • Integrating with cloud services

Trade-offs

Pros

  • Ergonomic
  • Async + blocking versions
  • Tight serde integration

Cons

  • Pulls in Tokio
  • Heavier dependency tree

Should You Use It?

If you need HTTP in Rust:

Almost certainly yes.

Writing your own HTTP client is rarely the right decision.