Home / Cost tools / cURL converter / Rust
cURL to Rust converter
Paste a cURL command and get the same request in Rust, using reqwest (blocking client). It converts in your browser; nothing you paste is sent anywhere.
Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking"] }
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::blocking::Client::builder()
.build()?;
let response = client.request(reqwest::Method::from_bytes(b"GET")?, "https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us")
.header("Authorization", "Bearer YOUR_API_KEY")
.send()?;
println!("{}", response.status());
println!("{}", response.text()?);
Ok(())
} Install first: cargo add reqwest --features blocking
Running the code
Add reqwest with its blocking feature (and json when the body is JSON) to Cargo.toml, then cargo run. The blocking client keeps the example short; the async client takes the same builder calls with .await.
Where reqwest differs from curl
reqwest follows up to ten redirects by default. A non-2xx status is not an error unless you call error_for_status, so a blocked scrape returns normally with its status.
What calls like this one cost
The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $19.00 on BrowserCloud, the cheapest complete bills across 27 web scraping APIs this site prices from their own pages. What rendering adds on each API