Coder Social home page Coder Social logo

viiprogrammer / getsms Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 2.0 1020 KB

API wrapper for sms activate services

Home Page: https://viiprogrammer.github.io/getSMS/

License: MIT License

JavaScript 100.00%
5sim sms-api sms-hub smsactivate smsapi smsgateway smshub fivesim smshub-api

getsms's Introduction

GetSMS

NPM version NPM 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')

const sms = new GetSMS({
  key: 'bc103fa02b63f986cd102a6d2f5c',
  url: 'https://smshub.org/stubs/handler_api.php',
  service: 'smshub'
});

(async () => {
  try {
    // eslint-disable-next-line camelcase
    const { balance_number } = await sms.getBalance()
    // eslint-disable-next-line camelcase
    if (balance_number > 0) {
      // Service - bd, operator - mts, country - russia (0)
      const { id, number } = await sms.getNumber('bd', 'mts', 0)
      console.log('Number ID:', id)
      console.log('Number:', number)

      // Set "message has been sent" status
      await sms.setStatus(1, id)

      // Wait for code
      const { code } = await sms.getCode(id)
      console.log('Code:', code)

      await sms.setStatus(6, id) // Accept, end
    } else console.log('No money')
  } catch (error) {
    if (error instanceof TimeoutError) {
      console.log('Timeout reached')
    } 
    
    if (error instanceof ServiceApiError) {
      if (error.code === errors.BANNED) {
        console.log(`Banned! Time ${error.banTime}`)
      } else {
        console.error(error.code, error.message)
      }
    } else console.error(error)
  }
})()

License

FOSSA Status

getsms's People

Contributors

thegp avatar viiprogrammer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fossabot thegp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.