From 6bbfe8e47a113ca916e81ddfac5fd4fd19d63e54 Mon Sep 17 00:00:00 2001 From: djaga <83035465+djaga-ru@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:04:47 +0300 Subject: [PATCH 1/4] Document optional minScore in the supported types table RecaptchaV2EnterpriseRequest, RecaptchaV3ProxylessRequest and RecaptchaV3EnterpriseRequest accept an optional min_score (0.1-0.9, serde name minScore, builder with_min_score, validated by check_min_score) but the table did not mention it. - Note optional min_score (0.1-0.9) on the three reCAPTCHA rows --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 87c6595..58f9311 100644 --- a/README.md +++ b/README.md @@ -205,9 +205,9 @@ All task types follow the official [CapMonster Cloud API documentation](https:// | :--- | :--- | :---: | | **Cloudflare Turnstile / Challenge / Waiting Room** | `TurnstileRequest` (`TurnstileStandard`, `TurnstileChallengeToken`, `TurnstileChallengeCookie`, `TurnstileWaitRoom`) | Optional / Required for cookie modes | | **reCAPTCHA v2** | `RecaptchaV2Request` | Optional | -| **reCAPTCHA v2 Enterprise** | `RecaptchaV2EnterpriseRequest` | Optional | -| **reCAPTCHA v3** | `RecaptchaV3ProxylessRequest` | — | -| **reCAPTCHA v3 Enterprise** | `RecaptchaV3EnterpriseRequest` | — | +| **reCAPTCHA v2 Enterprise** | `RecaptchaV2EnterpriseRequest` (optional `min_score` 0.1–0.9, builder `with_min_score`) | Optional | +| **reCAPTCHA v3** | `RecaptchaV3ProxylessRequest` (optional `min_score` 0.1–0.9) | — | +| **reCAPTCHA v3 Enterprise** | `RecaptchaV3EnterpriseRequest` (optional `min_score` 0.1–0.9) | — | | **GeeTest (v3, v4)** | `GeetestRequest` (`GeetestVersion::V3` / `V4`) | Optional | | **Amazon WAF** | `AmazonWafRequest` (`AmazonVisibleCaptcha`, `AmazonChallengeAndCaptcha`, `AmazonChallengeOnly`) | Optional | | **FunCaptcha (Arkose Labs)** | `FuncaptchaRequest` | 🌐 Required | From bfbf201c51b62cbb62272afdc7cdae2f9c912342 Mon Sep 17 00:00:00 2001 From: djaga <83035465+djaga-ru@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:18:08 +0300 Subject: [PATCH 2/4] Document client options in README The builder methods accepted by ClientOptions were not described in the README. - Add a Client Configuration section: ClientOptions::new(api_key) with with_service_url, with_soft_id (DEFAULT_SOFT_ID 152 sent with every createTask), with_client_timeout (20 s per HTTP request), with_client_proxy (ClientProxy with ProxyType and optional with_auth), and with_timeouts_override, with a builder example --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 58f9311..5ce85a8 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,32 @@ Errors are a single `capmonstercloud_client::Error` enum (`Validation`, `Http`, --- +## 🔧 Client Configuration + +`ClientOptions` can be tuned with builder methods before passing it to `CapMonsterClient::new`: + +| Method | Default | Description | +| :--- | :--- | :--- | +| `ClientOptions::new(api_key)` | — | **Required.** Your CapMonster Cloud API key from the [Dashboard](https://dash.capmonster.cloud/Account/SignUp?utm_source=github&utm_medium=referral&utm_campaign=rust_repo_readme). | +| `.with_service_url(url)` | `https://api.capmonster.cloud` | CapMonster Cloud API endpoint. | +| `.with_soft_id(id)` | `152` (`DEFAULT_SOFT_ID`) | `softId` sent with every created task; identifies your software in the Dashboard. | +| `.with_client_timeout(duration)` | 20 seconds | Timeout of one HTTP request to the API (not of the whole solving). | +| `.with_client_proxy(client_proxy)` | none | `ClientProxy` — proxy for the connection to the CapMonster Cloud API itself (`ProxyType`: `Http`, `Https`, `Socks4`, `Socks5`; optional `.with_auth(login, password)`). To route a solved task through a proxy, set `ProxyInfo` on the request instead. | +| `.with_timeouts_override(timeouts)` | per-captcha-type | Replaces the polling schedule of `solve_captcha` (see Error Handling). | + +```rust +use capmonstercloud_client::{CapMonsterClient, ClientOptions}; +use std::time::Duration; + +let client = CapMonsterClient::new( + ClientOptions::new("YOUR_CAPMONSTER_API_KEY") + .with_soft_id(12345) + .with_client_timeout(Duration::from_secs(30)), +)?; +``` + +--- + ## 🔄 Migrating from 2Captcha or Capsolver Already use 2Captcha or Capsolver in your Rust scraper or bot? If your code calls their HTTP APIs with `reqwest` or a community crate, replace only the solver part with the CapMonster Cloud SDK and keep the rest of your code unchanged: you still send the website URL and sitekey and receive the token. From f44fdfed51a4cb3bc25554a505082fac43421348 Mon Sep 17 00:00:00 2001 From: djaga <83035465+djaga-ru@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:19:18 +0300 Subject: [PATCH 3/4] Document error handling and polling timeouts in README The Error enum and the polling behaviour were not described in detail in the README. - Add an Error Handling section: every variant of the capmonstercloud_client::Error enum (CreateTask, GetResult, GetBalance with code/description, Timeout(Duration), Validation, Status, Http, Json, MalformedResponse, UnsupportedProxyType) with a match example - Describe automatic getTaskResult polling: the per-type GetResultTimeouts schedule, GetResultTimeouts::new and with_timeouts_override, and cancellation by dropping the future or wrapping the call in tokio::time::timeout - Note that unsolved tasks are not charged --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 5ce85a8..41dadfe 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,36 @@ One source file per type lives in [`src/requests/`](./src/requests). --- +## 🐞 Error Handling + +All failures surface as the single `capmonstercloud_client::Error` enum (`capmonstercloud_client::Result` is the matching `Result` alias): + +| Variant | Meaning | +| :--- | :--- | +| `CreateTask { code, description }` | `createTask` was rejected by the API (e.g. `code = "ERROR_ZERO_BALANCE"`). | +| `GetResult { code, description }` | `getTaskResult` returned an API error while polling. | +| `GetBalance { code, description }` | `getBalance` was rejected by the API. | +| `Timeout(Duration)` | The captcha type's maximum waiting time passed before a solution arrived. | +| `Validation(String)` | The request failed validation. | +| `Status { method, status }` | The API answered with an unexpected HTTP status. | +| `Http(...)`, `Json(...)` | Transport (`reqwest`) or JSON (`serde_json`) errors. | +| `MalformedResponse(String)` | The API response could not be interpreted. | +| `UnsupportedProxyType(String)` | A `ClientProxy` with an unsupported proxy type. | + +```rust +match client.solve_captcha(&request).await { + Ok(solution) => println!("Token: {}", solution["gRecaptchaResponse"]), + Err(capmonstercloud_client::Error::Timeout(waited)) => { + eprintln!("no solution within {waited:?}"); + } + Err(e) => eprintln!("solve failed: {e}"), +} +``` + +**Polling and timeouts.** The client polls `getTaskResult` automatically. Each request type provides its own schedule as `GetResultTimeouts` (`first_request_delay`, `first_request_no_cache_delay`, `requests_interval`, `timeout`); replace it with `.with_timeouts_override(GetResultTimeouts::new(1.0, 10.0, 3.0, 240.0))`. To cancel a running solve early, drop the returned future or wrap the call in `tokio::time::timeout`. Unsolved tasks are not charged. + +--- + ## ⚙️ Best Practices - **Use tokens promptly:** CAPTCHA tokens expire quickly (a reCAPTCHA v2 token is valid for 60 seconds after solving), so submit or inject the solution immediately after receiving the response. From c2bd98e7534bb26c09c5d8f7d4b8c933fdb2fa75 Mon Sep 17 00:00:00 2001 From: djaga <83035465+djaga-ru@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:43:28 +0300 Subject: [PATCH 4/4] Document solution cost in README solve_captcha returns SolvedTask { solution, cost }; the quick start examples already read SolvedTask.solution but the error handling match still indexed the old shape. - Show solved.cost in the Quick Start example and fix the match example to read SolvedTask.solution - Note the USD price of a solution in the polling and timeouts section --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41dadfe..cbda613 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ All failures surface as the single `capmonstercloud_client::Error` enum (`capmon ```rust match client.solve_captcha(&request).await { - Ok(solution) => println!("Token: {}", solution["gRecaptchaResponse"]), + Ok(solved) => println!("Token: {}", solved.solution["gRecaptchaResponse"]), Err(capmonstercloud_client::Error::Timeout(waited)) => { eprintln!("no solution within {waited:?}"); } @@ -299,7 +299,7 @@ match client.solve_captcha(&request).await { } ``` -**Polling and timeouts.** The client polls `getTaskResult` automatically. Each request type provides its own schedule as `GetResultTimeouts` (`first_request_delay`, `first_request_no_cache_delay`, `requests_interval`, `timeout`); replace it with `.with_timeouts_override(GetResultTimeouts::new(1.0, 10.0, 3.0, 240.0))`. To cancel a running solve early, drop the returned future or wrap the call in `tokio::time::timeout`. Unsolved tasks are not charged. +**Polling and timeouts.** The client polls `getTaskResult` automatically. Each request type provides its own schedule as `GetResultTimeouts` (`first_request_delay`, `first_request_no_cache_delay`, `requests_interval`, `timeout`); replace it with `.with_timeouts_override(GetResultTimeouts::new(1.0, 10.0, 3.0, 240.0))`. To cancel a running solve early, drop the returned future or wrap the call in `tokio::time::timeout`. `SolvedTask` also carries `cost: Option` — the price of the solution in USD (`None` if the API did not return it). Unsolved tasks are not charged. ---