---
title: "Rust SDK"
description: "Integrate uncaptcha.io with the official async Rust SDK."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.uncaptcha.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](https://github.com/uncaptchaio/uncaptcha-sdk-rust)

## Install

Add the SDK and Tokio runtime to your project:

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

## Solve Turnstile

```rust
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:

```rust
let task = TurnstileTask::builder()
.url("https://example.com/login")
.sitekey("0x4AAAAAAA...")
.action("login")
.proxy("http://user:pass@203.0.113.10: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 |

```rust title="Get balance"
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`.

Source: https://docs.uncaptcha.io/sdks/rust/index.mdx
