SurSolver
Docs menu

Docs / Guides

Examples

Use createTask and getTaskResult with PowerShell, Python and Node.js examples. Follow per-service Playwright scripts to apply solutions and check responses.

There is no official SDK: the API is three POST endpoints with a JSON body, and every snippet on this site is plain HTTP or a standard library. The examples on this page are generated from the same source as the ones in the API reference, so they never describe a different request than the reference does.

The variants

  • PowerShell — the two calls with Invoke-RestMethod; the reply hands you the taskId you continue with.
  • Python — requests, a small call() helper that raises on errorId: 1, then a solve() function that polls.
  • Node.js — fetch and node:timers/promises, no dependencies.
  • Playwright — shown for the services that have an integration script. It takes its settings from the constants listed at the top, finds the site key and script URLs on the live page, solves the task, applies the result in a fresh browser context and checks that the site accepted it.

Replace the example API key, the websiteURL, the site key and any proxy placeholders in the first three with your own values before running one. The Playwright script needs one edit: paste your key into the constant at the top and run it.

Applying the solution

Tokens are single-use and short-lived: read them from solution and put them into the request that the page makes immediately. Cookie-producing types are different — the cookie is bound to the IP and user agent that earned it, so replay it from the same proxy session. Proxies lists the modes per type.

Where the per-type examples live

Open POST /createTask in the API reference: its right-hand panel carries a request example for every task type, each with the exact fields that type takes. The same data is available as JSON — GET /v1/task-types (public, no key) lists every accepted name with its proxy mode, its required and optional fields and the keys the solution returns. The guides explain the flow around them.

A complete example

Every tab is generated from the same source as the examples in theAPI reference. The PowerShell, Python and Node.js tabs run against https://api.sursolver.com once your key and the fields for your site are in place (GET /v1/task-types lists them); the Playwright tab, where there is one, declares every setting as a constant at the top of the script.

solve.ps1
$api = 'https://api.sursolver.com'
$key = 'sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# 1/2 Create the task. API errors are HTTP 200 with errorId 1; a thrown request is a transport failure.
$task = @{
  type = 'ReCaptchaV3TokenProxyLess'
  websiteURL = 'https://example.com/login'
  websiteKey = '6Le...'
  userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36'
}
$request = @{ clientKey = $key; task = $task } | ConvertTo-Json -Depth 10
$created = Invoke-RestMethod -Method Post -Uri "$api/createTask" -ContentType 'application/json' -Body $request
if ($created.errorId -ne 0) { Write-Error $created.errorDescription; exit 1 }

# 2/2 Poll getTaskResult until the task is ready (60 tries, 3 s apart).
for ($attempt = 0; $attempt -lt 60; $attempt += 1) {
  $poll = @{ clientKey = $key; taskId = $created.taskId } | ConvertTo-Json -Depth 10
  $result = Invoke-RestMethod -Method Post -Uri "$api/getTaskResult" -ContentType 'application/json' -Body $poll
  if ($result.errorId -ne 0) { Write-Error $result.errorDescription; exit 1 }
  if ($result.status -eq 'ready') { $result.solution; exit 0 }
  Start-Sleep -Seconds 3
}
Write-Error "task $($created.taskId) was not ready after 60 polls"
exit 1