Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spryng

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spryng

NodeJS SDK for the Spryng SMS API

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Spryng NodeJS SDK

npm version

This is a NodeJS SDK for the Spryng SMS platform. The SDK makes it easy to implement the Spryng messaging system in your Node environment.

Installation

The package can be installed from NPM using

yarn add spryng

or

npm i spryng

Configuration

All the SDK needs is an API key. You can create an API key in your Spryng account settings:

  • Log in to your account in the Spryng dashboard
  • Under 'My data', click on 'Profile'
  • Scroll down to 'REST API keys' and generate a new API key

You can now initialize the SDK as follows:

import { Spryng } from 'spryng'

const API_KEY = 'YourApiKey'

const spryng = new Spryng(API_KEY)

Sending messages

Use the following code to send a message:

import { Spryng } from 'spryng'

const API_KEY = 'YourApiKey'

const spryng = new Spryng(API_KEY)

const message = await spryng.message.send({
  encoding: 'auto',
  body: 'Test message',
  route: 'business',
  originator: 'Example Company',
  recipients: ['31612345678', '31687654321'],
  reference: 'ABC123'
})

Listing Messages

It is possible to list messages that have been sent through the API:

import { Spryng } from 'spryng'

const API_KEY = 'YourApiKey'

const spryng = new Spryng(API_KEY)

const message = await spryng.message.list({
  recipient_number: '31612345678'
}, ['recipients'])
List message response

The response object for listing messages mimics the API as follows:

total: Total number of results

per_page: Number of results per page

current_page: The current page that is fetched

last_page: The number of pages

next_page_url: Full URL of the next page GET endpoint

prev_page_url: Full URL of the previous page GET endpoint

from: From index in the total results

to: To index in the total results

data: Array of Message objects, the actual result data

List message filters

The first argument of the list method is an object of filters that can be specified to limit the results:

originator: String used as the originator property when sending the messages

recipient_number: The phone number of the recipient

reference: A reference that has optionally been specified when creating the message

created_from: Date range for when the message has been created

created_until: Date range for when the message has been created

scheduled_from: Date range when the message has been scheduled to be send

scheduled_toDate range when the messsage has been scheduled to be send

status: Send status of the message

Fetching single message

Instead of listing, a single message can be fetched as well by its ID:

import { Spryng } from 'spryng'

const API_KEY = 'YourApiKey'

const spryng = new Spryng(API_KEY)

const message = await spryng.message.show('91d95b85-b32f-42bd-a9fb-4cde0a56424x')

Cancel a message

Scheduled messages can be canceled from being send:

import { Spryng } from 'spryng'

const API_KEY = 'YourApiKey'

const spryng = new Spryng(API_KEY)

const message = await spryng.message.cancel('91d95b85-b32f-42bd-a9fb-4cde0a56424x')

FAQs

Package last updated on 25 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc