npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@onecaptcha/sdk

v0.4.0

Published

Official Node.js SDK for the OneCaptcha unified captcha-solving gateway.

Readme

@onecaptcha/sdk

npm version License: MIT

Official Node.js SDK for the OneCaptcha unified captcha-solving gateway.

Website | Docs | SDKs | Error Codes

  • Zero dependencies. Built-in fetch (Node 18+).
  • Works with both ESM (import) and CommonJS (require).
  • Per-type sync and async helper methods with full JSDoc.

Install

npm install @onecaptcha/sdk

Quick start

import { OneCaptchaClient } from '@onecaptcha/sdk';

const client = new OneCaptchaClient({
  apiKey: process.env.ONECAPTCHA_API_KEY,
});

// Solve a reCAPTCHA v2
const result = await client.solveRecaptchaV2({
  url:     'https://example.com/login',
  sitekey: '6Lc...',
});
console.log(result.token);
await result.reportGood(); // tell the gateway it worked

// Solve an image captcha — just pass the base64 string
const img = await client.solveImageToText(base64);
console.log(img.text);
await img.reportGood();

Constructor options

| Option | Default | Description | | -------------- | -------------------------------- | ---------------------------------------------------- | | apiKey | required | Your gateway API key (sent as X-API-Key) | | baseUrl | https://api.one-captcha.com | Gateway origin, no trailing slash | | timeout | 30000 | ms timeout for non-solve calls | | solveTimeout | 120 (seconds) | Default X-Timeout for sync solve(). Min 10, max 180. | | pollInterval | 5000 | ms between polls in waitForTask | | pollTimeout | 180000 | Total ms waitForTask waits before giving up | | fetch | globalThis.fetch | Custom fetch implementation (test injection) |

Sync solve

One call — the gateway holds the connection open until the solution is ready. Best for most use cases.

// Per-type helper (recommended)
const result = await client.solveRecaptchaV2({ url, sitekey });

// Generic form
const result = await client.solve({
  type: 'recaptcha_v2',
  params: { url, sitekey },
});

Per-type sync helpers

client.solveImageToText(base64)                     // or { body, caseSensitive, ... }
client.solveImageToCoordinates(base64)               // or { body, comment, mode }
client.solveRecaptchaV2({ url, sitekey })
client.solveRecaptchaV2Enterprise({ url, sitekey })
client.solveRecaptchaV3({ url, sitekey, action, minScore })
client.solveRecaptchaV3Enterprise({ url, sitekey, action, minScore })
client.solveFunCaptcha({ url, publicKey, subdomain, data })
client.solveGeeTestV3({ url, gt, challenge })
client.solveGeeTestV4({ url, captchaId })
client.solveTurnstile({ url, sitekey })
client.solveAmazonWaf({ url, key })
client.solveMtCaptcha({ url, sitekey })
client.solveProsopo({ url, sitekey })
client.solveFriendlyCaptcha({ url, sitekey })

Async solve

Submit the task and poll until ready. Use when you need non-blocking submission or want to control the polling loop. Every sync helper has a matching ...Async variant.

// Per-type async helper — submits + polls automatically
const result = await client.solveRecaptchaV2Async({
  url: 'https://example.com',
  sitekey: '6Lc...',
}, { pollInterval: 3000, pollTimeout: 120000 });

console.log(result.token);

// Image OCR async
const img = await client.solveImageToTextAsync(base64);
console.log(img.text);

Per-type async helpers

client.solveImageToTextAsync(base64, waitOpts?)
client.solveImageToCoordinatesAsync(base64, waitOpts?)
client.solveRecaptchaV2Async(params, waitOpts?)
client.solveRecaptchaV2EnterpriseAsync(params, waitOpts?)
client.solveRecaptchaV3Async(params, waitOpts?)
client.solveRecaptchaV3EnterpriseAsync(params, waitOpts?)
client.solveFunCaptchaAsync(params, waitOpts?)
client.solveGeeTestV3Async(params, waitOpts?)
client.solveGeeTestV4Async(params, waitOpts?)
client.solveTurnstileAsync(params, waitOpts?)
client.solveAmazonWafAsync(params, waitOpts?)
client.solveMtCaptchaAsync(params, waitOpts?)
client.solveProsopoAsync(params, waitOpts?)
client.solveFriendlyCaptchaAsync(params, waitOpts?)

waitOpts is optional: { pollInterval?: number, pollTimeout?: number }.

Result

Both sync and async helpers return the same shape:

{
  type: 'recaptcha_v2',
  status: 'ready',
  taskRef: '550e8400-e29b-41d4-a716-446655440000',  // UUID for reporting
  token: '03AGdBq24...',          // token-based captchas
  text: 'K4ADHP',                 // image_to_text
  coordinates: [...],             // image_to_coordinates
  cost: 0.002990,                 // USD charged
  balanceRemaining: 9.997,        // balance after charge
  rateLimit: { limit, remaining, reset },
  reportGood: () => Promise,      // shortcut for reportTask(taskRef, true)
  reportBad:  () => Promise,      // shortcut for reportTask(taskRef, false)
}

Fields present depend on the captcha type (token for site-based, text for OCR, coordinates for click-based).

Reporting

Tell the gateway whether the solution worked on the target site. This helps providers flag bad workers, may trigger refunds, and for image captchas promotes the result into the cache so future identical images resolve instantly.

const result = await client.solveRecaptchaV2({ url, sitekey });

// Use the token on the target site, then report back:
await result.reportGood();   // solution worked
await result.reportBad();    // solution was rejected

// Equivalent long form:
await client.reportTask(result.taskRef, true);
await client.reportTask(result.taskRef, false);

Every result object from solve(), solveAsync(), createTask(), getTask(), and waitForTask() carries .reportGood() and .reportBad() when a taskRef is present.

Balance

const { balance, currency } = await client.getBalance();

Errors

Every method throws OneCaptchaError on failure.

import { OneCaptchaError, ERROR_CODES } from '@onecaptcha/sdk';

try {
  await client.solveRecaptchaV2({ url, sitekey });
} catch (err) {
  if (err instanceof OneCaptchaError) {
    err.code              // 'BALANCE_EMPTY' | 'PROVIDER_SITEKEY' | 'UNSOLVABLE' | ...
    err.message           // human-readable
    err.status            // HTTP status
    err.retryable         // boolean — check this before retrying
    err.retryAfter        // seconds to wait (null if not retryable)
    err.balanceRemaining  // null or number
    err.rateLimit         // null or { limit, remaining, reset }
  }
}

ERROR_CODES enumerates all codes, plus two SDK-only codes (SDK_TIMEOUT, SDK_NETWORK) for local failures.

Billing

Per-solve pricing. Each solve request deducts the type's base price from your API key balance. Check current pricing at one-captcha.com.

The post-operation balance is on every response as result.balanceRemaining.

License

MIT