Skip to content

Repository files navigation

httpsms-node

VersionBuildGitHub contributorsGitHub licenseDownloads

This library provides a server side client for the httpSMS API to help you send and receive SMS messages from your Node.js applications in TypeScript or JavaScript.

Install

pnpm install httpsms
# or
yarn install httpsms

Implemented

  • Messages
    • POST /v1/messages/send: Send a new SMS
  • Cipher
    • Encrypt: Encrypt the content of a message to cipher text
    • Decrypt: Decrypt an encrypted message content to plain text

Usage

Initializing the Client

An instance of the client can be created using httpsms.New().

importHttpSmsfrom"httpsms"constclient=newHttpSms(""/* Get API Key from https://httpsms.com/settings */);

Error handling

All API calls return a Promise<T> as the return object. You can handle the response in the then and catch methods.

Messages

POST /v1/messages/send: Send an SMS Message

awaitclient.messages.postSend({content: 'This is a sample text message',from: '+18005550199',to: '+18005550100',}).then((message)=>{console.log(message.id);}).catch((err)=>{console.error(err);});

Encrypt an SMS message before sending

constencryptionKey="Password123";constencryptedContent=awaitclient.cipher.encrypt("This is a sample text message",encryptionKey);awaitclient.messages.postSend({content: encryptedContent,from: '+18005550199',encrypted: true,to: '+18005550100',}).then((message)=>{console.log(message.id);}).catch((err)=>{console.error(err);});

Testing

You can run the unit tests for this client from the root directory using the command below:

pnpm run test

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Node client for the httpSMS API https://httpsms.com

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages