Node.js SDK

Install

The Uni Node.js SDK is hosted by npm and is available from the public npm repository.

Add unisms to the project as a dependency:

npm i unisms

or use Yarn:

yarn add unisms

Usage

The following example shows how to use the Uni Node.js SDK to quickly invoke a service.

Send an SMS


import UniSMS from 'unisms'

// initialization
const client = new UniSMS({
  accessKeyId: 'your access key id',
  accessKeySecret: 'your access key secret',  // if you use the simple auth mode, just delete this line
  endpoint: 'https://api.unimtx.com' // set endpoint
})

// send the message
client.send({
  to: 'your phone number',
  signature: 'Unimatrix',
  templateId: 'pub_verif_basic',
  templateData: {
    code: 7777,
  },
})
  .then(ret => {
    console.info('Result:', ret)
  })
  .catch(e => {
    console.error(e)
  })