pub struct Client { /* private fields */ }Expand description
Talks to the Anti-Captcha API.
The client holds no per-task state, so one instance can solve any number of captchas concurrently. Cloning is cheap: the underlying connection pool is shared.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Creates a client for the given key from https://anti-captcha.com/clients/settings/apisetup.
Sourcepub fn with_http_client(self, http: Client) -> Self
pub fn with_http_client(self, http: Client) -> Self
Reuses an existing reqwest client, so the connection pool, proxy and
TLS settings are shared with the rest of your program.
pub fn set_api_key(&mut self, api_key: impl Into<String>)
Sourcepub fn with_soft_id(self, soft_id: i64) -> Self
pub fn with_soft_id(self, soft_id: i64) -> Self
Specify a soft id to earn 10% commission with your app. Get yours at https://anti-captcha.com/clients/tools/devcenter.
Sourcepub fn with_verbose(self, verbose: bool) -> Self
pub fn with_verbose(self, verbose: bool) -> Self
Debug output goes to stderr. On by default.
Sourcepub fn with_connection_timeout(self, timeout: Duration) -> Self
pub fn with_connection_timeout(self, timeout: Duration) -> Self
Timeout of a single HTTP call to the API. Default 30 seconds.
Sourcepub fn with_polling_intervals(self, first: Duration, normal: Duration) -> Self
pub fn with_polling_intervals(self, first: Duration, normal: Duration) -> Self
How long to wait before the first status request, and between the following ones. Default 5 seconds each.
Sourcepub fn with_max_waiting_time(self, timeout: Duration) -> Self
pub fn with_max_waiting_time(self, timeout: Duration) -> Self
How long to keep polling before giving up. Default 300 seconds.
Sourcepub async fn get_balance(&self) -> Result<f64>
pub async fn get_balance(&self) -> Result<f64>
Account balance in US dollars.
Sourcepub async fn get_credits_balance(&self) -> Result<f64>
pub async fn get_credits_balance(&self) -> Result<f64>
Number of prepaid captcha credits on the account.
Sourcepub async fn json_request(&self, method: &str, payload: Value) -> Result<Value>
pub async fn json_request(&self, method: &str, payload: Value) -> Result<Value>
Calls any API method with your own payload. The client key is added for you.
Sourcepub async fn create_task(&self, task: Value) -> Result<i64>
pub async fn create_task(&self, task: Value) -> Result<i64>
Submits a task and returns its id.
Sourcepub async fn wait_for_result(&self, task_id: i64) -> Result<Solution>
pub async fn wait_for_result(&self, task_id: i64) -> Result<Solution>
Polls until the task is solved or the waiting limit runs out.
Sourcepub async fn solve_task(&self, task: Value) -> Result<Solution>
pub async fn solve_task(&self, task: Value) -> Result<Solution>
Sends a task type this library does not wrap yet, and waits for the result.
See https://anti-captcha.com/apidoc/task-types for the task object shape.
pub async fn solve_image( &self, base64_body: &str, settings: &ImageSettings, ) -> Result<Solution>
pub async fn solve_image_file( &self, path: impl AsRef<Path>, settings: &ImageSettings, ) -> Result<Solution>
pub async fn solve_image_to_coordinates( &self, base64_body: &str, settings: &ImageToCoordinates, ) -> Result<Solution>
pub async fn solve_image_to_coordinates_file( &self, path: impl AsRef<Path>, settings: &ImageToCoordinates, ) -> Result<Solution>
pub async fn solve_recaptcha_v2( &self, settings: &RecaptchaV2, ) -> Result<Solution>
pub async fn solve_recaptcha_v2_proxy_on( &self, settings: &RecaptchaV2, ) -> Result<Solution>
pub async fn solve_recaptcha_v3( &self, settings: &RecaptchaV3, ) -> Result<Solution>
pub async fn solve_hcaptcha(&self, settings: &HCaptcha) -> Result<Solution>
pub async fn solve_hcaptcha_proxy_on( &self, settings: &HCaptcha, ) -> Result<Solution>
pub async fn solve_funcaptcha(&self, settings: &FunCaptcha) -> Result<Solution>
pub async fn solve_funcaptcha_proxy_on( &self, settings: &FunCaptcha, ) -> Result<Solution>
pub async fn solve_geetest(&self, settings: &GeeTest) -> Result<Solution>
pub async fn solve_geetest_proxy_on( &self, settings: &GeeTest, ) -> Result<Solution>
pub async fn solve_turnstile(&self, settings: &Turnstile) -> Result<Solution>
pub async fn solve_turnstile_proxy_on( &self, settings: &Turnstile, ) -> Result<Solution>
pub async fn solve_prosopo(&self, settings: &Prosopo) -> Result<Solution>
pub async fn solve_prosopo_proxy_on( &self, settings: &Prosopo, ) -> Result<Solution>
pub async fn solve_friendly_captcha( &self, settings: &FriendlyCaptcha, ) -> Result<Solution>
pub async fn solve_friendly_captcha_proxy_on( &self, settings: &FriendlyCaptcha, ) -> Result<Solution>
pub async fn solve_altcha(&self, settings: &Altcha) -> Result<Solution>
pub async fn solve_altcha_proxy_on(&self, settings: &Altcha) -> Result<Solution>
pub async fn solve_amazon(&self, settings: &Amazon) -> Result<Solution>
pub async fn solve_amazon_proxy_on(&self, settings: &Amazon) -> Result<Solution>
pub async fn solve_antigate(&self, settings: &AntiGate) -> Result<Solution>
Sourcepub async fn report_incorrect_image_captcha(&self, task_id: i64) -> Result<()>
pub async fn report_incorrect_image_captcha(&self, task_id: i64) -> Result<()>
Reports an image captcha as answered incorrectly.