Skip to content

twizoapi/lib-api-nodejs

Repository files navigation

Twizo

Twizo Node.js API

Connect to the Twizo API using the Node.js library. This API includes functions to send verifications (2FA), SMS and Number Lookup.

Requirements

Get application secret and api host

To use the Twizo API client, the following things are required:

Installation

npm < 5.x.x

$ npm install --save twizo

npm => 5.x.x

$ npm install twizo

yarn

$ yarn add twizo

Getting started

Initialize the Twizo API with your api host and api secret

const twizo = require("twizo");

twizo.config(<yourTwizoHost>, <YourApiKey>);

Or you could set TWIZO_HOST and TWIZO_API_KEY in your environmental variables (through dotenv or on your server).

Create a new verification

let verification;
twizo.verification.submit({
    recipient: "60123456789"
})
.then(response => verification = response);

Verify token

twizo.verification.verify(response.messageId, "012345");

Send sms

twizo.sms.submit({
    recipients: ["60123456789"],
    sender: "Bob",
    body: "Hey Alice, how are you doing?"
});

Examples

In the examples directory you can find some examples of how to use the api.

License

The MIT License. Copyright (c) 2016-2017 Twizo

Support

Contact: www.twizo.comsupport@twizo.com