npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uni-sdk

v0.3.0

Published

The official Unimatrix SDK for Node.js.

Downloads

891

Readme

Unimatrix Node.js SDK

Version Release GitHub license

The Unimatrix Node.js SDK provides convenient access to integrate communication capabilities into your Node.js applications using the Unimatrix HTTP API. The SDK provides support for sending SMS, 2FA verification, and phone number lookup.

Getting started

Before you begin, you need an Unimatrix account. If you don't have one yet, you can sign up for an Unimatrix account and get free credits to get you started.

Documentation

Check out the documentation at unimtx.com/docs for a quick overview.

Installation

The recommended way to install the Unimatrix SDK for Node.js is to use the npm package manager, which is available on npm.

Run the following command to add uni-sdk as a dependency to your project:

npm i uni-sdk

or use Yarn:

yarn add uni-sdk

Usage

The following example shows how to use the Unimatrix Node.js SDK to interact with Unimatrix services.

Initialize a client

const { UniClient } = require('uni-sdk')

const client = new UniClient({
  accessKeyId: 'your access key id',
  accessKeySecret: 'your access key secret'
})

or you can configure your credentials by environment variables:

export UNIMTX_ACCESS_KEY_ID=your_access_key_id
export UNIMTX_ACCESS_KEY_SECRET=your_access_key_secret

Send SMS

Send a text message to a single recipient.

const { UniClient } = require('uni-sdk')
const client = new UniClient()

client.messages.send({
  to: '+1206880xxxx', // in E.164 format
  text: 'Your verification code is 2048.'
})
  .then(ret => {
    console.log('Result:', ret)
  })
  .catch(e => {
    console.error(e)
  })

or use async/await keyword:

try {
  const ret = await client.messages.send({
    // ...
  })
  console.log('Result:', ret)
} catch (e) {
  console.error(e)
}

Send verification code

Send a one-time passcode (OTP) to a recipient. The following example will automatically generate a verification code.

const { UniClient } = require('uni-sdk')
const client = new UniClient()

client.otp.send({
  to: '+1206880xxxx'
})
  .then(ret => {
    console.log('Result:', ret)
  })

Check verification code

Verify the one-time passcode (OTP) that a user provided. The following example will check whether the user-provided verification code is correct.

const { UniClient } = require('uni-sdk')
const client = new UniClient()

client.otp.verify({
  to: '+1206880xxxx',
  code: '123456' // the code user provided
})
  .then(ret => {
    console.log('Valid:', ret.valid)
  })

Reference

Other Unimatrix SDKs

To find Unimatrix SDKs in other programming languages, check out the list below:

License

This library is released under the MIT License.