Capture full-page screenshots of any URL from Rust with reqwest and serde. No headless browser, no C++ dependencies — just a POST request over HTTPS. Works with Tokio, Actix Web, Axum, and any async runtime.
Start Free — 200 captures/month
Rust's reqwest crate provides an ergonomic async HTTP client that integrates naturally with Tokio. Combined with serde_json for request/response serialization, calling SnapAPI from Rust requires minimal boilerplate. The strong type system ensures your API parameters are correct at compile time.
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.post("https://api.snapapi.pics/v1/screenshot")
.header("X-Api-Key", "YOUR_API_KEY")
.json(&json!({
"url": "https://example.com",
"full_page": true,
"format": "png",
"width": 1280
}))
.send()
.await?;
let body: serde_json::Value = res.json().await?;
println!("{}", body["screenshot_url"]);
Ok(())
}
Add reqwest with the json feature and serde_json to your Cargo.toml. The tokio runtime with the full feature flag provides the async executor.
Store your API key in an environment variable and retrieve it with std::env::var("SNAPAPI_KEY"). For production deployments, use dotenvy to load environment files or inject keys via your container orchestrator.
For production Rust applications, define typed structs for the API request and response rather than using raw serde_json::Value. This catches parameter errors at compile time and provides IDE autocompletion for all fields.
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
struct ScreenshotRequest {
url: String,
full_page: bool,
format: String,
width: u32,
#[serde(skip_serializing_if = "Option::is_none")]
delay: Option<u32>,
}
#[derive(Deserialize)]
struct ScreenshotResponse {
screenshot_url: String,
page_title: Option<String>,
render_ms: Option<u64>,
}
The skip_serializing_if attribute omits optional fields from the JSON payload when they are None, keeping requests minimal. Extend the struct with additional SnapAPI parameters as needed — device emulation, custom CSS injection, ad blocking, and cookie banner dismissal are all supported.
Rust's async model makes batch screenshot capture extremely efficient. Use tokio::task::JoinSet or futures::stream::FuturesUnordered to fire concurrent API calls and collect results as they complete. A semaphore limits concurrency to respect SnapAPI's rate limits.
For web applications built with Axum or Actix Web, expose a screenshot endpoint that accepts a URL, calls SnapAPI, and returns the image URL or streams the binary data directly to the client. The non-blocking nature of the reqwest call means your server handles other requests while waiting for the screenshot to render.
Error handling in Rust is explicit. Match on the reqwest::Error variants to distinguish network errors from HTTP status errors. For 429 rate limit responses, implement exponential backoff using tokio::time::sleep. For 5xx server errors, retry up to three times before propagating the error to the caller.
Axum is the most popular Rust web framework for building API services. Wrapping SnapAPI in an Axum handler lets you expose a screenshot endpoint to your users while managing authentication, rate limiting, and caching in Rust. Create a shared reqwest::Client in Axum's application state — connection pooling across requests significantly reduces latency compared to creating a new client per call.
For PDF generation from Rust, switch the endpoint to /v1/pdf and pass parameters like page_format, margin, and print_background. The response handling is identical — decode the JSON, extract the URL or base64 data, and stream it to the client or write it to storage.
Stealth mode is activated by adding "stealth": true to the request body. This suppresses browser automation signals that anti-bot systems detect, allowing screenshots of pages protected by Cloudflare, Imperva, or DataDome without triggering CAPTCHA challenges.
Device emulation uses the device parameter with over 30 presets: iPhone 15, Samsung Galaxy S23, iPad Pro, and more. Each preset configures the correct viewport dimensions, pixel density, and user agent string automatically.
Rust's type system makes error handling explicit. Use the ? operator to propagate errors through your call stack, and match on specific error variants for targeted recovery. Network timeouts, rate limit responses (429), and server errors (5xx) should be retried with exponential backoff. Client errors (4xx other than 429) indicate invalid parameters and should not be retried.
The reqwest-retry crate provides a middleware layer that handles retries automatically. Configure it with a maximum retry count, backoff strategy, and retryable status codes. This keeps your application code clean while handling transient failures robustly.
The Rust headless-chrome crate provides Chromium DevTools Protocol bindings, but running a browser process alongside your Rust application introduces memory overhead, crash recovery complexity, and a C++ dependency chain that complicates cross-compilation and container builds.
SnapAPI eliminates this complexity. Your Rust binary stays lean — no Chromium dependency, no browser process management, no memory spikes from rendering heavy pages. The API call is a standard HTTPS request that fits naturally into Rust's async model.
The same HTTP client you use for screenshots works with every SnapAPI endpoint. The /v1/scrape endpoint returns page content as HTML, plain text, or markdown. The /v1/extract endpoint pulls structured data using CSS selectors. The /v1/analyze endpoint sends page content to an LLM and returns AI-generated insights. All endpoints accept the same authentication and return JSON.
For Rust applications that need web data — price monitoring, competitive intelligence, content aggregation — SnapAPI provides browser rendering and data extraction without adding browser dependencies to your Cargo build. Your Rust service stays focused on business logic while SnapAPI handles the browser infrastructure.
Pricing starts free: 200 captures per month with no credit card required. Starter at $19/month provides 5,000 captures across all endpoints. Pro at $79/month gives 50,000. Business at $299/month supports 500,000. All plans include stealth mode, ad blocking, cookie banner dismissal, and device emulation.
Sign up at snapapi.pics, generate your API key, and add a SnapAPI call to your Rust project in under five minutes. The API is fully documented at snapapi.pics/docs.html with request and response examples for every endpoint.
Rust's scraper and select crates parse static HTML, but they cannot execute JavaScript or render single-page applications. For pages built with React, Vue, Angular, or Next.js, you need a real browser. SnapAPI's /v1/scrape endpoint renders the page fully and returns the content as HTML, plain text, or markdown — ready for processing in Rust without any browser dependency.
The /v1/extract endpoint goes further: pass CSS selectors and receive structured JSON with the extracted values. This eliminates the need to parse HTML in Rust entirely. Define your selectors in the API request, and the response contains clean data ready for deserialization into Rust structs.
For AI-powered extraction, the /v1/analyze endpoint sends page content to a large language model with your custom prompt. Describe what you want in natural language rather than writing CSS selectors. The BYOK mode routes the LLM call through your own API key, keeping costs and data under your control.
Rust is widely used for CLI tools and background processing workers where performance and resource efficiency matter. A competitive intelligence tool built in Rust can monitor competitor websites by calling SnapAPI for screenshots and content extraction on a schedule, comparing results against previous captures, and alerting on changes. The entire pipeline runs as a single Rust binary with minimal resource overhead.
For WebAssembly (WASM) deployments, SnapAPI's HTTP API works from any environment that supports outbound HTTPS requests. WASM modules running in Cloudflare Workers or Deno Deploy can call SnapAPI to generate screenshots or extract data at the edge without carrying browser infrastructure.
Do I need a Rust SDK? No. SnapAPI is a standard REST API — reqwest with serde_json is all you need. Define typed request and response structs for compile-time safety and IDE autocompletion across all API parameters.
Does it work with async runtimes other than Tokio? Yes. The reqwest crate supports Tokio by default but also works with async-std via feature flags. Any runtime that implements the standard Future trait is compatible.
What about rate limiting? SnapAPI returns X-RateLimit-Remaining and X-RateLimit-Reset headers with every response. Read these in your Rust code to pause requests before hitting limits. The reqwest-retry crate automates backoff for 429 responses.
Can I capture pages behind Cloudflare? Yes. Enable stealth mode with "stealth": true in your request body. Combined with residential proxy routing on Pro and Business plans, SnapAPI handles Cloudflare-protected, Imperva-protected, and DataDome-protected pages without CAPTCHA challenges.