Developers / SDKs
C# SDK.
.NET 6+, no dependencies. One file. Give it a page address, get the token.
1. Add the client
Add Captora.cs to your project. The example uses top-level statements (.NET 6+) with implicit usings enabled.
Captora.cs
// Captora.cs: zero-dependency Captora client for .NET 6+ (HttpClient + System.Text.Json).using System.Net.Http.Headers;using System.Text;using System.Text.Json;public class Captora{ private readonly HttpClient _http; private readonly TimeSpan _poll; private readonly TimeSpan _timeout; public Captora(string apiKey, string baseUrl = "https://api.captora.me", int pollSeconds = 3, int timeoutSeconds = 180) { _http = new HttpClient { BaseAddress = new Uri(baseUrl), Timeout = TimeSpan.FromSeconds(60) }; _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); _http.DefaultRequestHeaders.UserAgent.ParseAdd("captora-dotnet/1.0"); _poll = TimeSpan.FromSeconds(pollSeconds); _timeout = TimeSpan.FromSeconds(timeoutSeconds); } private async Task<JsonElement> RequestAsync(HttpMethod method, string path, object? body = null) { using var req = new HttpRequestMessage(method, path); if (body != null) req.Content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json"); using var res = await _http.SendAsync(req); var text = await res.Content.ReadAsStringAsync(); if (!res.IsSuccessStatusCode) throw new HttpRequestException($"Captora error {(int)res.StatusCode}: {text}"); return JsonDocument.Parse(text).RootElement.Clone(); } /// <summary>Returns { "balance_paise": ... } (100 paise = Rs 1).</summary> public Task<JsonElement> BalanceAsync() => RequestAsync(HttpMethod.Get, "/v1/balance"); /// <summary> /// The simple way: give the address of a page with a captcha. Captora recognises the captcha, solves it, and /// returns its "result" (usually the token). Pass "html" in extra for pages that add the captcha with /// JavaScript or need a login. Throws if it can't be solved (you are not charged). /// </summary> public Task<JsonElement> SolveUrlAsync(string websiteUrl, Dictionary<string, object>? extra = null) { var body = new Dictionary<string, object>(extra ?? new()) { ["websiteURL"] = websiteUrl }; return WaitAsync("/v1/solve", body); } /// <summary>Advanced: you already know the captcha type. Waits for the task and returns its "result".</summary> public Task<JsonElement> SolveAsync(string type, Dictionary<string, object> parameters) { var body = new Dictionary<string, object>(parameters) { ["type"] = type }; return WaitAsync("/v1/tasks", body); } private async Task<JsonElement> WaitAsync(string path, Dictionary<string, object> body) { var task = await RequestAsync(HttpMethod.Post, path, body); var deadline = DateTime.UtcNow + _timeout; while (task.GetProperty("status").GetString() == "processing" && DateTime.UtcNow < deadline) { await Task.Delay(_poll); task = await RequestAsync(HttpMethod.Get, "/v1/tasks/" + task.GetProperty("taskId").GetString()); } return task.GetProperty("status").GetString() switch { "completed" => task.GetProperty("result"), "failed" => throw new InvalidOperationException("Could not be solved (refunded)"), _ => throw new TimeoutException("Timed out"), }; }}2. Solve a captcha with one call
Put your API key in the CAPTORA_API_KEY environment variable (create one in your dashboard).
Example.cs
var captora = new Captora(Environment.GetEnvironmentVariable("CAPTORA_API_KEY")!);// Give it the page with the captcha. Captora finds the captcha and solves it.var result = await captora.SolveUrlAsync("https://example.com/login");Console.WriteLine(result.GetProperty("token").GetString()); // submit this token with your form3. That's it. No captcha type to pick
Captora recognises the captcha on the page. For pages that add it with JavaScript or sit behind a login, pass the page's HTML as well (see the docs). If you already know the type, the client has a second method for that. Every captcha we support, and its price, is on the captchas page.
Keep in mind
- Keep your API key on your server. Never ship it in a browser or mobile app.
- Solving can take from a few seconds to a minute or more, so run it in the background of your app.
- Unsolved tasks raise an error and are refunded automatically.