Giter Site home page Giter Site logo

skocimis / textlink-js Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 7 KB

Library for Node.js that helps you send SMS and verify users using the TextLink API

Home Page: https://textlinksms.com

License: ISC License

TypeScript 100.00%
api api-client bulk-sms simple-sms sms sms-api sms-gateway sms-verification text-message user-verification javascript nodejs typescript

textlink-js's Introduction

TextLink Node.js helper library

NPM

Supported Node.js Versions

  • Node.js 18
  • Node.js 20
  • Node.js 21
  • Node.js 22

Installation

npm install textlink-sms or yarn add textlink-sms

Sending an SMS

To send an SMS, you have to create an API key using the TextLink API Console. When you register an account, you automatically get an API key with 0.5$ of credits (for TextLink service) and 500 free messages (for Use your device service).

Just send a message

const textlink = require("textlink-sms");
textlink.useKey("YOUR_API_KEY"); //You can create one in the API Console at https://textlinksms.com/dashboard/api

textlink.sendSMS("+381611231234", "Dummy message text...");

Handle response

async function async_function() {
  let result = await textlink.sendSMS("+381611231234", "Dummy message text...");
  console.log(result);
}
async_function();

Example of the result of a successfully sent message

{
    "ok": true
}

Example of the result of an unsuccessfully sent message

{
    "ok": false,
    "message": "API key not found"
}

Verifying a phone number

You can also use our service to easily verify a phone number, without storing data about the phones that you are about to verify, because we can do it for you.

Example usage

//User has sent his phone number for verification
await textlink.sendVerificationSMS("+11234567890", verificationOptions);

//Show him the code submission form
//We will handle the verification code ourselves

//The user has submitted the code
const result = await textlink.verifyCode("+11234567890", "USER_ENTERED_CODE"); 
//if `result.ok` is true, then the phone number is verified. 

Verification options

VerificationOptions the optional argument for the sendVerificationSMS function. It contains the parameters of the verification code that should be sent:

service_name is what the user will see in the verification message, e. g. "Your verification code for Guest is: CODE"

expiration_time is how many miliseconds the code is valid. Default is 10 minutes.

source_country is the ISO-2 code of the sender's phone number country

{
  service_name: "Guest",
  expiration_time: 10 * 60 * 1000,
  source_country: "US"
}

Getting help

If you need help installing or using the library, please check the FAQ first, and contact us at [email protected] if you don't find an answer to your question.

If you've found a bug in the API, package or would like new features added, you are also free to contact us!

textlink-js's People

Contributors

skocimis avatar

Watchers

 avatar  avatar

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.