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

wotp-client

v1.0.9

Published

Official TypeScript SDK for Wotp — WhatsApp OTP, self-hosted, one command.

Readme

wotp-client

Official TypeScript SDK for Wotp — WhatsApp OTP, self-hosted, one command.

npm License: MIT

Installation

npm install wotp-client

Quick Start

import { createClient } from 'wotp-client'

const wotp = createClient('http://localhost:54321', 'wotp_anon_xxx')

// Send an OTP
const { token, expiresAt } = await wotp.sendOTP('+212600000000')

// Verify the code entered by the user
const { verified } = await wotp.verifyOTP(token, '483920')

API Reference

createClient(url, apiKey, options?)

Creates a new Wotp client instance.

| Parameter | Type | Description | |-----------|------|-------------| | url | string | Base URL of your Wotp instance | | apiKey | string | Your anon or service API key | | options.maxRetries | number | Max retries on transient errors (default: 3) | | options.retryDelay | number | Base delay in ms between retries (default: 500) | | options.timeout | number | Request timeout in ms (default: 10000) |

wotp.sendOTP(phone)

Send an OTP to the given phone number.

  • Parameters: phone — E.164 formatted phone number (e.g. +212600000000)
  • Returns: Promise<{ token: string; expiresAt: string }>
  • Throws: RateLimitError if the rate limit is exceeded

wotp.verifyOTP(token, code)

Verify an OTP code against a previously issued token.

  • Parameters: token — from sendOTP, code — the user-entered code
  • Returns: Promise<{ verified: boolean; phone?: string; attemptsRemaining?: number }>
  • Throws: ExpiredTokenError, InvalidCodeError

wotp.health()

Check the health of the Wotp instance.

  • Returns: Promise<{ status: string; phone: string; uptimeSeconds: number }>

Error Handling

The SDK throws typed errors for business failures — no need to parse HTTP status codes:

import { createClient, RateLimitError, ExpiredTokenError, InvalidCodeError } from '@wotp/client'

const wotp = createClient('http://localhost:54321', 'wotp_anon_xxx')

try {
  const { verified } = await wotp.verifyOTP(token, code)
} catch (error) {
  if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter}s`)
  } else if (error instanceof ExpiredTokenError) {
    console.log('Token expired — request a new OTP')
  } else if (error instanceof InvalidCodeError) {
    console.log(`Wrong code. ${error.attemptsRemaining} attempts left`)
  }
}

| Error Class | When | |-------------|------| | RateLimitError | Phone/IP exceeded rate limit (HTTP 429) | | ExpiredTokenError | Token has expired (HTTP 410 or expired_token) | | InvalidCodeError | Wrong OTP code (HTTP 400 + invalid_code) | | WotpError | Base class for all SDK errors |

Auto-Retry

Transient network errors (502, 503, 504, timeouts) are automatically retried with exponential backoff. Business errors (rate limit, expired token, invalid code) are never retried.

Requirements

  • Node.js ≥ 18 (uses native fetch)
  • A running Wotp instance

License

MIT — see LICENSE for details.