CaptchaSharp 1.0.11

.NET Standard 2.0
dotnet add package CaptchaSharp --version 1.0.11
NuGet\Install-Package CaptchaSharp -Version 1.0.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CaptchaSharp" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CaptchaSharp --version 1.0.11
#r "nuget: CaptchaSharp, 1.0.11"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CaptchaSharp as a Cake Addin
#addin nuget:?package=CaptchaSharp&version=1.0.11

// Install CaptchaSharp as a Cake Tool
#tool nuget:?package=CaptchaSharp&version=1.0.11

CaptchaSharp

A .NET Standard 2.0 library that implements the APIs of the most used captcha solving services out there. The library is fully documented, asynchronous and very easy to use. All services derive from the same CaptchaService class so you can allow users to use their favourite service without the need of a separate library for each one of them!

Supported Captchas

This library supports the following captcha types

  • Text (with language options)
  • Image (with options like phrase, case sensitivity, calculations)
  • FunCaptcha
  • ReCaptcha V2 (incl. invisible, enterprise)
  • ReCaptcha V3 (incl. enterprise)
  • HCaptcha
  • KeyCaptcha
  • GeeTest
  • Capy

Although this sounds very exciting, sadly not all captcha types are supported by the services. You can find a table of the supported captcha types for each major service below.

Supported Captcha Types

Adding CaptchaSharp to your project

Simply install the nuget package via

Install-Package CaptchaSharp

If you need more solvers you can install additional solvers (mostly ones that implement the 2captcha API) like this

Install-Package CaptchaSharp.Services.More

Usage

First of all, initialize your solver of choice by providing your credentials, for example

CaptchaService service = new TwoCaptchaService("MY_API_KEY");

You can get your remaining balance like this

decimal balance = await service.GetBalanceAsync();

If the provided credentials are wrong, the method above will return a BadAuthenticationException that you can catch and process in order to let the user know he needs to check his credentials.

If the credentials are correct and the balance is greater than the minimum required for solving a captcha, we can proceed to solve a ReCaptchaV2 task (you will need to provide the required parameters found in the webpage source code).

StringResponse solution = await service.SolveRecaptchaV2Async("site key", "site url");

The method above can throw the following exceptions:

  • TaskCreationException when the task could not be created for example due to zero balance or incorrect parameters.
  • TaskSolutionException when the task could not be completed, for example when an image captcha cannot be decoded.
  • TimeoutException when the captcha solution took too long to complete.

You can configure a custom timeout like this

service.Timeout = TimeSpan.FromMinutes(3);

The returned StringResponse will contain two fields:

An Id which you can use for reporting a bad solution (if the service supports it) like this

await service.ReportSolution(solution.Id, CaptchaType.ReCaptchaV2);

if the report failed, the method above will throw a TaskReportException.

And finally your solution as plaintext

Console.WriteLine($"The solution is {solution.Response}");

In addition, mind that not every service supports every type of captcha! If a method or specific parameters are not supported, a NotSupportedException will be thrown.

Unit Tests

Unit tests for the major services are included in the CaptchaSharp.Tests project. In order to test, you need to:

  1. Run any test once and let it fail. It will create a file called config.json in your bin/Debug folder.
  2. Add your credentials to the config.json file. You can also add a proxy to test proxied endpoints.
  3. Run the tests (one at a time, to avoid overloading the service and overspending).
  4. If you need to test a captcha on a specific website, you can edit the ServiceTests class and change the parameters as you need.

What needs to be improved

  • Use C# anonymous types or JObject for the AntiCaptchaSolver instead of a million classes!
  • Implement better exception handling, for example when there is zero balance or when a solver method returns a bad authentication, they will currently fall in the generic TaskCreationException type.
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CaptchaSharp:

Package Downloads
CaptchaSharp.Services.More

Adds additional services to CaptchaSharp.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on CaptchaSharp:

Repository Stars
openbullet/openbullet
The OpenBullet web testing application.
openbullet/OpenBullet2
OpenBullet reinvented
mohamm4dx/SilverBullet
Silver Bullet
Version Downloads Last updated
1.0.11 184 11/28/2022
1.0.10 4,043 1/10/2022
1.0.9 4,755 1/2/2022
1.0.8 1,390 9/20/2021
1.0.7 1,227 7/2/2021
1.0.6 3,015 3/28/2021
1.0.5 741 3/2/2021
1.0.4 7,636 6/11/2020
1.0.3 1,036 5/15/2020
1.0.2 367 5/14/2020
1.0.1 624 4/15/2020
1.0.0 488 4/15/2020

Added capsolver.com and datadome captcha