Overview

Reqwest is an HTTP client library for the Rust programming language, engineered to simplify the process of making web requests. It is a common choice for Rust developers building web clients, integrating with RESTful APIs, or performing any task that requires communicating over HTTP. The library supports both asynchronous operations using Rust's async/await syntax and traditional blocking requests, making it adaptable to various application architectures. Its design prioritizes ease of use while providing control over HTTP features such as custom headers, request bodies, and response handling.

The library integrates with Rust's asynchronous ecosystem, particularly with runtimes like Tokio, which is a widely used runtime for writing asynchronous applications in Rust. This integration allows reqwest to perform non-blocking I/O, which is crucial for high-performance network applications. Developers can send requests without blocking the main thread, enabling more efficient resource utilization and responsiveness in web servers, microservices, and other network-intensive applications. Reqwest also offers a blocking client for scenarios where asynchronous programming is not required or desired, providing flexibility for different project needs.

Reqwest handles common HTTP tasks such as sending GET, POST, PUT, DELETE, and other standard methods. It provides convenient methods for sending various body types, including JSON, form data, and raw bytes. Response handling is also streamlined, with methods to parse responses directly into Rust structs using serialization crates like serde, or to access the raw response body, headers, and status codes. Error handling is integrated, allowing developers to manage network issues, HTTP errors, and deserialization failures effectively. Its comprehensive feature set and idiomatic Rust API make it a foundational component for many Rust projects requiring HTTP communication.

The library is particularly well-suited for applications that frequently interact with external web services. This includes backend services that consume third-party APIs (e.g., payment gateways, data providers), command-line tools that fetch data from the internet, and web scrapers. Its robust error handling and support for complex request/response patterns contribute to building reliable and maintainable network-enabled Rust applications. The active development and community support around reqwest further enhance its reliability and feature set, ensuring it remains a relevant tool in the Rust ecosystem.

Key features

  • Asynchronous and Blocking Clients: Supports both async/await for non-blocking operations and a blocking client for simpler, synchronous use cases, catering to different application requirements and architectures.
  • JSON Support: Provides built-in capabilities to send and receive JSON data, automatically serializing Rust structs to JSON for requests and deserializing JSON responses back into structs using serde, simplifying API interactions.
  • Form Data Handling: Facilitates sending URL-encoded form data and multipart form data, essential for interacting with web forms and file uploads.
  • Custom Headers: Allows developers to easily add, modify, or remove HTTP headers for requests, enabling custom authentication, content negotiation, and other header-based functionalities.
  • Redirect Following: Automatically follows HTTP redirects (e.g., 301, 302), configurable to control redirect behavior or disable it entirely.
  • Cookies Management: Offers a cookie store to manage session cookies across multiple requests, useful for maintaining state with web services.
  • Proxy Support: Configurable to route requests through HTTP or SOCKS proxies, providing flexibility for network configurations and privacy requirements.
  • TLS/SSL Support: Handles secure communication over HTTPS with robust TLS/SSL capabilities, ensuring data encryption and integrity.
  • Timeout Configuration: Allows setting timeouts for various stages of a request (connection, response, overall), preventing requests from hanging indefinitely.
  • Error Handling: Provides a comprehensive error type that covers network issues, HTTP status errors, and deserialization failures, aiding in robust application development.

Pricing

Reqwest is an open-source library distributed under the MIT license and the Apache License (Version 2.0). It is free to use, modify, and distribute. There are no direct costs associated with its usage. Hosting and infrastructure costs for applications built with reqwest are dependent on the chosen cloud provider or self-hosting solution.

Feature Cost Details
Library Usage Free Open-source under MIT and Apache 2.0 licenses.
Commercial Projects Free Permitted for use in commercial applications without licensing fees.
Support Community-driven Support is available through community forums and GitHub issues.

Pricing as of 2026-05-06

Common integrations

  • Tokio: Reqwest integrates seamlessly with the Tokio asynchronous runtime, enabling non-blocking HTTP requests within Tokio-powered applications.
  • async-std: It also supports the async-std runtime, offering flexibility for developers preferring this alternative asynchronous ecosystem.
  • serde: Widely used with Serde for serialization and deserialization, allowing Rust structs to be easily converted to and from JSON or other formats for request bodies and responses.
  • tokio-rustls / native-tls: Reqwest can be configured to use different TLS backends, including tokio-rustls for a pure Rust TLS implementation or native-tls for system-native TLS libraries.

Alternatives

  • ureq: A simple, synchronous HTTP client for Rust, often preferred for its minimal dependencies and blocking-only API.
  • hyper: A low-level HTTP library for Rust, forming the foundation for many higher-level clients like reqwest, offering fine-grained control over HTTP.
  • actix-web: While primarily a web framework, Actix Web includes its own client capabilities for making HTTP requests, particularly useful within Actix applications.
  • isahc: An HTTP client that uses libcurl under the hood, providing a robust and feature-rich option with both synchronous and asynchronous APIs.

Getting started

To begin using reqwest in a Rust project, add it as a dependency in your Cargo.toml file. For asynchronous operations, ensure you also include an async runtime like Tokio. Here's an example demonstrating a simple asynchronous GET request:

# Cargo.toml
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }

Next, create a Rust source file (e.g., src/main.rs) and implement the request logic. This example fetches data from a public API and deserializes the JSON response into a custom Rust struct:

// src/main.rs

use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct Post {
    #[serde(rename = "userId")]
    user_id: u32,
    id: u32,
    title: String,
    body: String,
}

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    // Create an asynchronous reqwest client
    let client = reqwest::Client::new();

    // Make a GET request to a public API
    let res = client.get("https://jsonplaceholder.typicode.com/posts/1")
        .send()
        .await?;

    // Check if the request was successful
    if res.status().is_success() {
        // Deserialize the JSON response into our Post struct
        let post: Post = res.json().await?;
        println!("Successfully fetched post: {:#?}", post);
    } else {
        eprintln!("Request failed with status: {}", res.status());
        eprintln!("Response body: {}", res.text().await?);
    }

    Ok(())
}

This code defines a Post struct to match the structure of the JSON response. The #[tokio::main] macro marks the main function as an asynchronous entry point. Inside main, an asynchronous reqwest client is created, a GET request is sent, and the response is checked for success. If successful, the JSON body is deserialized into the Post struct and printed. This demonstrates the basic workflow for making asynchronous HTTP requests and handling JSON responses with reqwest.