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

onlinesim-client

v0.2.0

Published

TypeScript client for the OnlineSIM virtual numbers and SMS verification API

Readme

onlinesim-client

npm version License: ISC Node.js Version

Modern, fully typed TypeScript / Node.js client library for the OnlineSIM virtual number and SMS activation API.

Official API documentation: https://onlinesim.io/docs/api/en


Features

  • 📱 One-Time SMS Verification — Rent disposable virtual phone numbers across 90+ countries for Telegram, WhatsApp, Google, and hundreds of other services.
  • ⏳ Long-Term Rentals — Full support for long-term number rental (getRentNum, getRentState, closeRentNum).
  • 📊 Tariffs & Availability — Inspect real-time tariffs, service lists, and supported countries.
  • 🛡️ Fully Typed — Written in TypeScript with complete type definitions and dedicated OnlineSimError exceptions.

Installation

npm install onlinesim-client

Requires Node.js 18 or higher.


Quick Start (Safe Check)

The quick check only inspects your account balance. It does not order numbers or consume funds:

import { OnlineSim } from "onlinesim-client";

const client = new OnlineSim({
  apiKey: process.env.ONLINESIM_API_KEY!,
});

const balance = await client.getBalance();
console.log(`Current OnlineSIM balance: $${balance.toFixed(2)} USD`);

Usage Guide

1. Renting a Number and Receiving an SMS Code

Full activation lifecycle: order a number, poll for the verification code, and mark the order complete:

import { OnlineSim, OnlineSimError } from "onlinesim-client";

const client = new OnlineSim({ apiKey: process.env.ONLINESIM_API_KEY! });

// 1. Order a number for Telegram in United States (country 1)
const order = await client.getNum({
  service: "telegram",
  country: 1,
});
console.log(`Order created with TZID: ${order.tzid}`);

// 2. Poll for incoming SMS code
let code: string | null = null;
let phoneNumber: string | null = null;

for (let attempt = 0; attempt < 30; attempt++) {
  await new Promise((resolve) => setTimeout(resolve, 3000));
  const states = await client.getState({ tzid: order.tzid });
  const current = states[0];

  if (current) {
    phoneNumber = current.number;
    console.log(`Assigned Number: ${current.number}, Status: ${current.response}`);

    if (current.msg) {
      code = current.msg;
      break;
    }
  }
}

if (code) {
  console.log(`Received SMS code: ${code}`);
  // 3. Mark operation complete
  await client.setOperationOk(order.tzid);
} else {
  console.log("No SMS received. Requesting refund / revision...");
  await client.setOperationRevise(order.tzid);
}

2. Inspecting Tariffs and Available Countries

Check available numbers and prices before ordering:

// Get list of supported countries
const countries = await client.getCountries();
console.log("Countries:", countries);

// Inspect tariffs for a specific country
const tariffs = await client.getTariffs(1); // 1 = USA
console.log("USA Tariffs:", tariffs);

3. Long-Term Number Rental

Rent a dedicated number for multiple days:

// Get rental tariffs
const rentTariffs = await client.getRentTariffs();
console.log("Rent Tariffs:", rentTariffs);

// Rent a number for 1 day
const rentOrder = await client.getRentNum({
  country: 1,
  days: 1,
});
console.log("Rent Order:", rentOrder);

API Reference

OnlineSim Class

Constructor

new OnlineSim(apiKey: string)
// or
new OnlineSim(options: OnlineSimOptions)

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | apiKey | string | Required | Your OnlineSIM API key. | | baseUrl | string | "https://onlinesim.io" | Custom API base URL. | | timeout | number | 30000 | HTTP request timeout in milliseconds. |

Methods

  • getBalance(): Promise<number> — Retrieves current balance in USD.
  • getCountries(): Promise<unknown> — Returns list of supported countries.
  • getTariffs(country?): Promise<unknown> — Returns tariffs for services.
  • getServiceList(country?): Promise<unknown> — Returns list of services and available numbers.
  • getNum(options: GetNumOptions): Promise<OrderResult> — Orders a virtual number for a service (tzid).
  • getState(options?): Promise<ActivationState[]> — Retrieves status and incoming messages for an order.
  • setOperationOk(tzid): Promise<boolean> — Confirms code received and completes activation.
  • setOperationRevise(tzid): Promise<boolean> — Cancels activation and requests refund.
  • getRentTariffs(): Promise<unknown> — Retrieves tariffs for long-term rentals.
  • getRentNum(options): Promise<unknown> — Orders a long-term rental number.
  • getRentState(tzid?): Promise<unknown> — Checks status of rented numbers.
  • closeRentNum(tzid): Promise<boolean> — Closes/cancels long-term rental.

Error Handling

When the API returns an error response, OnlineSimError is thrown:

import { OnlineSim, OnlineSimError } from "onlinesim-client";

try {
  const client = new OnlineSim({ apiKey: "invalid_key" });
  await client.getBalance();
} catch (error) {
  if (error instanceof OnlineSimError) {
    console.error(`OnlineSIM Error: ${error.message} (Code: ${error.code})`);
  }
}

Common error codes:

  • ACCOUNT_BLOCKED — Account has been blocked.
  • NO_NUMBER — No numbers currently available for this service.
  • NO_BALANCE — Insufficient funds.
  • WRONG_SERVICE — Unsupported or incorrect service identifier.
  • EXCEED_CONCURRENT_OPERATIONS — Maximum simultaneous orders limit reached.

License

ISC