Skip to content

Rust SDK

Integrate uncaptcha.io with the official async Rust SDK.

The official Rust SDK provides an async client, typed task builders, and typed solutions for uncaptcha.io.

View the Rust SDK on GitHub

Install

Add the SDK and Tokio runtime to your project:

Cargo.tomltoml
[dependencies]
uncaptcha = { git = "https://github.com/uncaptchaio/uncaptcha-sdk-rust" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Solve Turnstile

use uncaptcha::{task::TurnstileTask, UncaptchaAPI};

#[tokio::main]
async fn main() -> uncaptcha::Result<()> {
    let api_key =
        std::env::var("UNCAPTCHA_API_KEY").expect("UNCAPTCHA_API_KEY is required");
    let api = UncaptchaAPI::new(api_key);

    let solution = api
        .execute_task(
            TurnstileTask::builder()
                .url("https://example.com/login")
                .sitekey("0x4AAAAAAA...")
                .build(),
        )
        .await?;

    println!("token: {}", solution.token);
    Ok(())
}

Optional Turnstile fields are available through the builder:

let task = TurnstileTask::builder()
    .url("https://example.com/login")
    .sitekey("0x4AAAAAAA...")
    .action("login")
    .proxy("http://user:[email protected]:8080")
    .build();

Supported operations

Operation SDK method or type Result
Solve Turnstile TurnstileTask with execute_task TurnstileSolution
Solve Cloudflare WAF WAFTask with execute_task WAFSolution
Get balance get_balance Account balance
Get balancerust
let balance = api.get_balance().await?;
println!("balance: ${balance}");

Errors

Every SDK call returns uncaptcha::Result<T>. Transport failures use Error::Request; errors returned by the uncaptcha.io API use Error::API.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close