🚀 New v3 API is now live! Faster, more secure, and robust. ⚡
Node.js SDK

Node.js SDK

TypeScript-first SDK with Promise-based API. Compatible with Node.js 16+.

Node.js 16+ npm / yarn TypeScript

Installation

npm
npm install directsms
yarn
yarn add directsms

Basic Usage (TypeScript)

Initialize Client
import { DirectSMS } from 'directsms';

    // Initialize client
    const client = new DirectSMS('YOUR_API_TOKEN');

    // Get user info
    const user = await client.user.me();
    console.log(user.balance);

SMS Activation

Create & Wait for SMS
// Create activation
    const activation = await client.sms.create({
      categoryId: 15,
      country: 'US'
    });

    console.log(activation.phone); // +1234567890

    // Wait for code
    try {
      const sms = await client.sms.waitForCode(activation.id, {
        timeout: 120000 // 2 minutes
      });
      console.log(sms.code); // 123456
    } catch (error) {
      console.error('SMS timeout');
    }

Resources