Skip to content

Repository files navigation

GetSMS

NPM versionNPM downloads

NPM

getSMS - This is Node.js module that allows you to interact with the SMS services api

Features

  • Promises
  • Supports SMSActivate, SMSHub
  • Using undici http client

Docs

You can find documentation here

Installation

Node.js 12.0.0 or newer is required

Yarn

yarn add getsms

NPM

npm i getsms

Errors caught

Errors that can be caught with catch():

  • MAIL_RULE - For buying this service number you must satisfied additional site rules (smshub, undocumented)
  • BAD_KEY - Invalid api key
  • ERROR_SQL - Server database error
  • BAD_ACTION - Bad request data
  • WRONG_SERVICE - Wrong service identifier
  • BAD_SERVICE - Wrong service name',
  • NO_ACTIVATION - Activation not found.
  • NO_BALANCE - No balance
  • NO_NUMBERS - No numbers
  • WRONG_ACTIVATION_ID - Wrong activation id
  • WRONG_EXCEPTION_PHONE - Wrong exception phone
  • NO_BALANCE_FORWARD - No balance for forward
  • NOT_AVAILABLE - Multiservice is not available for selected country
  • BAD_FORWARD - Incorrect forward
  • WRONG_ADDITIONAL_SERVICE - Wrong additional service
  • WRONG_SECURITY - WRONG_SECURITY error
  • REPEAT_ADDITIONAL_SERVICE - Repeat additional service error
  • BANNED:YYYY-m-d H-i-s - Account banned

if the ban code is BANNED:YYYY-m-d H-i-s then the error object contains the properties banTime, banDate, banTimestamp

  • banTime - YYYY-m-d H-i-s (for example 2020-12-31 23-59-59)
  • banTimestamp - Unixtime
  • banDate - JavaScript new Date() Object

Usage example

const{ GetSMS, ServiceApiError, TimeoutError, errors }=require('getsms')constsms=newGetSMS({key: 'bc103fa02b63f986cd102a6d2f5c',url: 'https://smshub.org/stubs/handler_api.php',service: 'smshub'});(async()=>{try{// eslint-disable-next-line camelcaseconst{ balance_number }=awaitsms.getBalance()// eslint-disable-next-line camelcaseif(balance_number>0){// Service - bd, operator - mts, country - russia (0)const{ id, number }=awaitsms.getNumber('bd','mts',0)console.log('Number ID:',id)console.log('Number:',number)// Set "message has been sent" statusawaitsms.setStatus(1,id)// Wait for codeconst{ code }=awaitsms.getCode(id)console.log('Code:',code)awaitsms.setStatus(6,id)// Accept, end}elseconsole.log('No money')}catch(error){if(errorinstanceofTimeoutError){console.log('Timeout reached')}if(errorinstanceofServiceApiError){if(error.code===errors.BANNED){console.log(`Banned! Time ${error.banTime}`)}else{console.error(error.code,error.message)}}elseconsole.error(error)}})()

License

FOSSA Status

Releases

Packages

Used by

Contributors

Languages