A .NET 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 and have the same code API, so it's very easy to switch between services!
This library supports the following captcha solving services
- 2captcha.com
- anti-captcha.com
- deathbycaptcha.com
- imagetyperz.com
- capmonster.cloud
- capsolver.com
- captchacoder.com
- humancoder.com
- azcaptcha.com
- captchas.io
- 9kw.eu
- truecaptcha.com
- rucaptcha.com
- nopecha.com
- nocaptchaai.com
- metabypass.tech
- captchaai.com
- nextcaptcha.com
- ez-captcha.com
- endcaptcha.com
- bestcaptchasolver.com
- solvecaptcha.net
- cap.guru
This library supports the following captcha types
- Text (with language options)
- Image (with options like phrase, case sensitivity, calculations)
- ReCaptcha V2 (incl. invisible, enterprise)
- ReCaptcha V3 (incl. enterprise)
- ArkoseLabs FunCaptcha
- HCaptcha
- KeyCaptcha
- GeeTest
- Capy
- DataDome
- Cloudflare Turnstile
- Lemin Cropped
- Amazon WAF
- Cyber SiARA
- MT Captcha
- CutCaptcha
- Friendly Captcha
- atb Captcha
- Tencent Captcha
- Audio Captcha (with language options)
- ReCaptcha Mobile
Proxies are supported for services that accept them.
Not every captcha type is supported by each service! You can find a spreadsheet with a breakdown of the supported captcha types for each implemented service at the link below
CaptchaSharp Services Availability
Simply install the nuget package via
Install-Package CaptchaSharp
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
.
If the credentials are correct and the balance is greater than the minimum required for solving a captcha, you can proceed to solve a captcha (e.g., a ReCaptchaV2 task) like this.
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 solution will contain two fields:
-
an
Id
which you can use for reporting a bad solution (if the service supports it) like thisawait service.ReportSolution(solution.Id, CaptchaType.ReCaptchaV2);
if the report failed, the method above will throw a
TaskReportException
. -
your solution as plaintext
Console.WriteLine($"The solution is {solution.Response}");
If a method or some of its parameters are not supported, a NotSupportedException
or ArgumentException
will be thrown.
If the service you want to use is not implemented, you can easily implement it yourself by deriving from the CaptchaService
class and implementing the abstract methods, or you can open an issue, and we will try to implement it as soon as possible.
Unit tests are included in the CaptchaSharp.Tests
project. In order to test, you need to:
- Run any test once and let it fail. It will create a file called
config.json
in yourbin/Debug/net8.0
folder. - Add your credentials to the
config.json
file. You can also add a proxy to test proxied endpoints. - Run the tests (one at a time, to avoid overloading the service and overspending).
- If you need to test a captcha on a specific website, you can edit the
ServiceTests
class and change the parameters as you need.
- Drop
Newtonsoft.Json
forSystem.Text.Json
StringPairCollection.Add()
should also take null values, and by default ignore the key-value pair if the value is null.- Implement better exception handling for specific error codes. 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. - Add support for recognition APIs (right now only token-based APIs are supported).