Skip to content

mboukhlouf/CapMonsterCloud

Repository files navigation

CapMonsterCloud

AppVeyor GitHub release (latest by date) Nuget GitHub

This is a C# wrapper for CapMonster Cloud API and provides methods to create a task and get the result of the task.

Installation

Via Nuget:

Install-Package CapMonsterCloud

Usage

Creating a client

// Create a client with your client key
var clientKey = "YOUR_CLIENT_KEY";
var client = new CapMonsterClient(clientKey);

Get balance

var balance = await client.GetBalanceAsync();

Create a task

Task types:

  • FunCaptchaTaskProxyless
  • ImageToTextTask
  • NoCaptchaTask
  • NoCaptchaTaskProxyless
  • RecaptchaV3TaskProxyless
  • HCaptchaTask
  • HCaptchaTaskProxyless
// Creating a NoCaptchaTaskProxyless task object
var captchaTask = new NoCaptchaTaskProxyless
{
    WebsiteUrl = "WEBSITE_URL",
    WebsiteKey = "WEBSITE_KEY",
    UserAgent = "USER_AGENT"
};
// Create the task and get the task id
int taskId = await client.CreateTaskAsync(captchaTask);

Get task result

Task result types:

  • FunCaptchaTaskProxylessResult
  • ImageToTextTaskResult
  • NoCaptchaTaskProxylessResult
  • NoCaptchaTaskResult
  • RecaptchaV3TaskProxylessResult
  • HCaptchaTaskProxylessResult
  • HCaptchaTaskResult
// Get the task result
var solution = await client.GetTaskResultAsync<NoCaptchaTaskProxylessResult>(taskId);
// Recaptcha response to be used in the form
var recaptchaResponse = solution.GRecaptchaResponse;

Error handling

try 
{
    int taskId = await client.CreateTaskAsync(captchaTask);
}
catch (CapMonsterException e)
{
    Console.WriteLine($"{e.ErrorCode}: {e.ErrorDescription}");
}