getSMS - This is Node.js module that allows you to interact with the SMS services api
- Promises
- Supports
SMSActivate,SMSHub - Using undici http client
You can find documentation here
Node.js 12.0.0 or newer is required
yarn add getsmsnpm i getsmsErrors 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 keyERROR_SQL- Server database errorBAD_ACTION- Bad request dataWRONG_SERVICE- Wrong service identifierBAD_SERVICE- Wrong service name',NO_ACTIVATION- Activation not found.NO_BALANCE- No balanceNO_NUMBERS- No numbersWRONG_ACTIVATION_ID- Wrong activation idWRONG_EXCEPTION_PHONE- Wrong exception phoneNO_BALANCE_FORWARD- No balance for forwardNOT_AVAILABLE- Multiservice is not available for selected countryBAD_FORWARD- Incorrect forwardWRONG_ADDITIONAL_SERVICE- Wrong additional serviceWRONG_SECURITY- WRONG_SECURITY errorREPEAT_ADDITIONAL_SERVICE- Repeat additional service errorBANNED: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 example2020-12-31 23-59-59)banTimestamp- UnixtimebanDate- JavaScriptnew Date()Object
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)}})()