What is Reqwest and why is it needed?
Reqwest is one of the most popular and convenient libraries for making HTTP requests in Rust. It provides an ergonomic, high-level API built on top of the asynchronous HTTP engine hyper and tokio. If you are writing a web scraper, REST API client, Telegram bot in Rust, or simply want to download a file — Reqwest will be your primary tool.
The library supports both asynchronous (default) and synchronous (blocking) requests, working with JSON, multipart/form-data, cookies, proxies, TLS/SSL, redirects, and much more. Reqwest is designed to be intuitive for developers familiar with the Python library requests or the JavaScript library fetch.
Key features:
- Asynchronous and synchronous HTTP/HTTPS requests (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
- Automatic JSON serialization and deserialization (via
serde) - Support for multipart/form-data for file uploads
- Cookie management (Cookie Store)
- Proxy support (HTTP, HTTPS, SOCKS5)
- Customization of timeouts, headers, User-Agent
- Streaming support for large responses
- Security by default (SSL certificate verification)
Installation
To use Reqwest, you need a Rust project with Cargo.toml. Add the dependency to the [dependencies] section:
[dependencies]reqwest = { version = "0.12", features = ["json", "multipart", "cookies", "socks"] }tokio = { version = "1", features = ["full"] }serde = { version = "1", features = ["derive"] }serde_json = "1"Explanation of features:
json— enables JSON serialization/deserialization support via serde.multipart— for sending multipart/form-data.cookies— for automatic cookie management.socks— for SOCKS5 proxy support.- If you only need a synchronous (blocking) client, add the
blockingfeature.
For synchronous use (without async), you can add it like this:
reqwest = { version = "0.12", features = ["blocking", "json"] }Quick start with code example
Let's make a simple GET request to a public API and print the result. Create a file main.rs:
use reqwest;use std::error::Error;
#[tokio::main]async fn main() -> Result<(), Box<dyn Error>> { // Execute GET request let response = reqwest::get("https://api.github.com/repos/rust-lang/rust") .await?;
// Check status if response.status().is_success() { // Parse response body as JSON (without strict typing) let body: serde_json::Value = response.json().await?; println!("Repository name: {}", body["full_name"]); println!("Description: {}", body["description"].as_str().unwrap_or("No description")); println!("Stars: {}", body["stargazers_count"]); } else { eprintln!("Error: {}", response.status()); }
Ok(())}Run it with the command cargo run. You should see information about the Rust repository.
Main methods and functions
1. reqwest::get()
What it does: Performs an HTTP GET request to the specified URL. This is the simplest way to retrieve data. Returns a Response.
Parameters:
url: impl IntoUrl— a string or URL to which the request is sent.
Example:
let resp = reqwest::get("https://httpbin.org/get" Also in library
Generating PDF Reports in C# (.NET) with iTextSharp and QuestPDF
Database Migrations in TypeScript: A Complete Guide to Tools and Approaches
HTTP Client for JavaScript (Node.js): Top Libraries 2025
Sending Email in JavaScript (Node.js): nodemailer, sendgrid, mailgun