Node.js CAPTCHA API Integration with Fetch
Use built-in fetch with request deadlines, stable idempotency and bounded polling. Resume from an existing taskId after a timeout.
For authorized QA automation and browser integration. Use only on websites and workflows you have permission to test.
Prerequisites
Use Node.js 22+ on a server or test runner. No third-party HTTP library is needed. You need an active Key with tasks permission, sufficient balance and a site you are authorized to test. Register and verify your email, then activate self-service if offered or bind an issued Key. Check live prices.
Download and run
Download nodejs-client.mjs using the link below. Create task.json using your own authorized site parameters:
{"type":"turnstile","task":{"websiteURL":"https://example.com/login","websiteKey":"REPLACE_WITH_SITE_KEY"}}
Set secrets in the test environment rather than source control. Choose and persist a key for this logical task before its first request:
export SOLVEHUB_API_KEY='sh_REPLACE_ME'
export SOLVEHUB_IDEMPOTENCY_KEY='persisted-authorized-test-0001'
export SOLVEHUB_TASK_FILE='task.json'
node nodejs-client.mjs
The client writes taskId to stderr as soon as it is known and outputs only the completed solution to stdout. Persist taskId in your job record. This example can create a paid task; placeholders alone are not a usable test environment.
Resume an existing task
After a local deadline or uncertain outcome, do not create a replacement. Run with the saved taskId:
export SOLVEHUB_TASK_ID='SAVED_TASK_ID'
node nodejs-client.mjs
If no ID was received, retain the original key and exact payload and retry within the documented replay window. Do not reuse an old key for a different task.
Failure behavior
Each request has a 20-second timeout. The overall budget is 240 seconds and polling waits 3 seconds. Retryable failures have at most 3 attempts and respect Retry-After, including HTTP dates. If a requested delay exceeds the remaining budget, the client stops. These limits are client choices, not a processing-time guarantee.
The client stops on failed/cancelled and keeps querying uncertain. It rejects HTTP redirects to avoid forwarding the Key to a different origin. It does not automatically log task payloads or credentials. Read idempotency, errors and the full API reference before adapting it for production.
Developer downloads
python-client.py v1.0.0 — standard library only; behaviour and error codes are documented on this page.
Related documentation
Last updated: