Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
sainofirst
Advanced tools
The Sainofirst SDK for javascript provides a javascript API for Sainofirst communication services.
The Sainofirst SDK for node js provides a node js API for Sainofirst services. You can use the node js API to build libraries or applications for node js.
Using the SDK for node js makes it possible to realize a number of compelling use cases. their are several things you can build by using the SDK for node js.
The preferred way to install the Sainofirst SDK for node js is to use the npm
package manager for node js.
Go to your node js project directory.
cd your_project_directory
Then simply type the following into a terminal window
npm install sainofirst
This will install the Sainofirst SDK into your node js project.
After you install the SDK, you can load the Sainofirst SDK in your node js application using require.
const Sainofirst = require("sainofirst")
You need to provide credentials to Sainofirst SDK so that only your account and its resources are accessed by the SDK. For more information about obtaining your account credentials, see Getting Your Credentials.
To hold this information, we recommend you create an environment variable with SAINOFIRST_API_KEY as it's key and it's value should hold your Sainofirst api key.
SAINOFIRST_API_KEY=your_sainofirst_api_key
Alternatively if you prefer you can set your credentials directly in code (NOT RECOMMENDED)
We do not recommend hard coding your Sainofirst credentials in your scripts. Hard coding credentials poses a risk of exposing your api key.
const sf = new Sainofirst("YOUR API KEY")
The Sainofirst SDK for node js provides access to services that it supports through a collection of service instances. Each supported Sainofirst service offer low-level APIs for using service features and resources.
The services exposed through the SDK for node js follow the request-response pattern to exchange messages with calling applications. In this pattern, the code invoking a service submits an HTTP/HTTPS request to an endpoint for the service. The request contains parameters needed to successfully invoke the specific feature being called. The service that is invoked generates a response that is sent back to the requestor. The response contains data if the operation was successful or error information if the operation was unsuccessful.
Not all services are immediately available in the SDK
Array of current services available under this version of SDK
When using the SDK for node js, you add the SDK package to your application using require, which provides support for all current services.
importing the SDK for node js as shown previously includes the entire SDK into your code.
const Sainofirst = require("sainofirst")
Begin by creating an instance of the Sainofirst SDK and assign it to a variable.
const sf = new Sainofirst()
To access service features through the Sainofirst class, you first access a service through which you access a set of features provided by the underlying service instance. Generally there is one service instance provided for each service.
Consider the following code used to access sms service
const sms = sf.sms
To access individual service begin by importing that service
const Sms = require("sainofirst/lib/services/sms")
creating an instance of the service and assign it to a variable.
const sms = new Sms()
Programmatically send high volumes of text messages globally. Your users can get OTP, alerts, stock prices, account balance, transaction statements, discounts, offers and much more all over a message.
Sainofirst sms service provides easy api for sending and scheduling text messages which you can easily integrate in your node js application.
option | type | description |
---|---|---|
senderid | String | The registered and approved Sender name. |
route | String | Type of connectivity ex Global, Promotional, Transactional, etc. |
Begin by loading Sainofirst SDK into your node js project.
const Sainofirst = require("sainofirst")
Create a new instance of Sainofirst SDK. Make sure you have configured your apikey in environment variable.
const sf = new Sainofirst()
Access sms service from the SDK.
const sms = sf.sms
Alternatively if you do not want to load whole sdk you can also access individual services. To access individual service begin by importing that service
const Sms = require("sainofirst/lib/services/sms")
Create an instance of the service and assign it to a variable. Make sure you have configured your apikey in environment variable.
const sms = new Sms()
Define a callback function which will get executed after recieving response from Sainofirst server.
function callback(success, error){
if (error) throw Error(error)
console.log(success)
}
You can easily send text message by setting your text message using message method, Array of numbers by using numbers method and setting required options using set method and then calling send method along with callback
sms.message("your text message here")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"senderid" : "SAIFST",
"route" : "Transactional"
}).send(callback)
Use schedule method to schedule your text message
sms.message("your text message here")
.numbers(["91888xxxxx", "918323xxxx"])
.schedule("2020-11-03 15:40:05")
.set({
"senderid" : "SAIFST",
"route" : "Transactional"
}).send(callback)
If you want to send text message in any language you will have to configure an additional option unicode
to 1
option | type | description |
---|---|---|
unicode | Number | Message can be send in any language ( Values 1 or 0 ) |
sms.message("your text message here")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"senderid" : "SAIFST",
"route" : "Transactional"
"unicode" : 1
}).send(callback)
If you want send a flash message set additional option flash
to 1
option | type | description |
---|---|---|
flash | Number | Send flash SMS( Values 1 or 0 ) |
sms.message("your text message here")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"senderid" : "SAIFST",
"route" : "Transactional"
"flash" : 1
}).send(callback)
You can send multiple message with same configuration options
sms.set({
"senderid" : "SAIFST",
"route" : "Transactional"
"unicode" : 0
"flash" : 0
})
sms.message("your text message 1")
.numbers(["91888xxxxx", "918323xxxx"])
.send(callback)
sms.message("your text message 2")
.numbers(["91888xxxxx", "918323xxxx"])
.send(( (success, error) => {
if (error) throw Error(error)
console.log(success)
})
sms.message("your text message 3")
.numbers(["91888xxxxx", "918323xxxx"])
.send(callback)
Get request object by using get method
requestDictionary = sms.message("your text message here")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"senderid" : "SAIFST",
"route" : "Transactional"
"unicode" : 0
"flash" : 0
}).get()
Additional options number
and message
are required while sending request object directly using send method
option | type | description |
---|---|---|
number | Array[String] | Array of number with country prefix. (multiple numbers can be separated by comma.) |
message | String | SMS text body. The actual message. |
You will need to set message
to your text body and number
to a Array containing numbers you want your message to get delivered to.
sms.send({
"senderid" : "SAIFST",
"route" : "Transactional"
"number": ["86983xxxxx", "728737xxxx"],
"message":"your text message"
}, callback)
Schedule a message by using additional configuration option time
option | type | description |
---|---|---|
time | String | Schedule time (in format i.e, yyyy-mm-dd hh:mm:ss) at which the SMS has to be sent |
sms.send({
"senderid" : "SAIFST",
"route" : "Transactional"
"number": ["86983xxxxx", "728737xxxx"],
"message":"your text message",
"time" : "2020-11-03 23:11:04"
}, callback)
If you want to send text message in any language you will have to configure an additional option unicode
to 1
option | type | description |
---|---|---|
unicode | Number | Message can be send in any language ( Values 1 or 0 ) |
sms.send({
"senderid" : "SAIFST",
"route" : "Transactional"
"number": ["86983xxxxx", "728737xxxx"],
"message":"your text message",
"unicode" : 1
}, callback)
If you want send a flash message set additional option flash
to 1
option | type | description |
---|---|---|
flash | Number | Send flash SMS( Values 1 or 0 ) |
sms.send({
"senderid" : "SAIFST",
"route" : "Transactional"
"number": ["86983xxxxx", "728737xxxx"],
"message":"your text message",
"flash" : 1
}, callback)
Programmatically send voice calls and build conversations anywhere and everywhere. Make calls around the world. Your users can get OTP, alerts and much more all over a call.
Sainofirst voice service provides easy api for making and scheduling phone calls which you can easily integrate in your node js applications.
option | type | description |
---|---|---|
subscription_id | Number | Pricing and Routes will be based on this ID. The value of this ID can be accessed from the SainoFirst's Application under connectivity. If subscription not assigned please contact your account manager. |
maxLengthOfCall | Number | Limits the call duration to this much seconds, the call will be disconnected after this much second automatically even if receiver is not cutting the call.(Value In Second) |
Begin by loading Sainofirst SDK into your node js project.
const Sainofirst = require("sainofirst")
Create a new instance of Sainofirst SDK. Make sure you have configured your apikey in environment variable.
const sf = new Sainofirst()
Access voice service from the SDK.
const voice = sf.voice
Alternatively if you do not want to load whole sdk you can also access individual services. To access individual service begin by importing that service
const Voice = require("sainofirst/lib/services/voice")
Create an instance of the service and assign it to a variable. Make sure you have configured your apikey in environment variable.
const voice = new Voice()
Define a callback function which will get executed after recieving response from Sainofirst server.
function callback(success, error){
if (error) throw Error(error)
console.log(success)
}
To make an audio call set url to the audio file by using audio
method and Array of numbers by using numbers
method. Configure required options using set
method and execute a send
method with a callback function
voice.audio("audio_file_url")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
}).send(callback)
If you want to make text synthesized voice call you will be required to configure two additional options speech_rate
and language_id
along with setting text using text
method
option | type | description |
---|---|---|
speech_rate | Number | minimum 0.5 - maximum 2 (Lower the value, Slower the speed of voice audio converted via text-to-speech synthesis ) |
language_id | Number | Language ID of the text to be converted via Text-to-Speech synthesis. |
voice.text("your message")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
}).send(callback)
Use schedule
method to schedule a call
voice.audio("audio_file_url")
.numbers(["91888xxxxx", "918323xxxx"])
.schedule("2020-11-03 15:40:05", "Asia/Kolkata (GMT +05:30)")
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
}).send(callback)
voice.text("your message")
.numbers(["91888xxxxx", "918323xxxx"])
.schedule("2020-11-03 15:40:05", "Asia/Kolkata (GMT +05:30)")
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
}).send(callback)
If you want to reschedule an already scheduled voice call use reschedule
method with following options.
option | type | description |
---|---|---|
voice_id | Number | Unique ID which was received in response while sending the voice call. |
new_send_at | String | Schedule time (in format i.e, yyyy-mm-dd hh:mm:ss) at which the SMS has to be sent |
timezone | String | timezone refers to the local time of a region or a country |
voice.reschedule({
"voice_id" : 7878,
"new_send_at" : "2020-11-03 15:40:05",
"timezone" : "Asia/Kolkata (GMT +05:30)"
}, callback)
You can cancel already scheduled call by providing voice id which was received in response while making a voice call.
voice.cancel(7878, callback)
Advanced voice call is the voice call where Listener (or Receiver) will be able to interact even with the simple pre-recorded or text-to-speech voice call.
Features in Advance voice call:
The config
option is used to make a advanced voice call. It further has two options
option | type | description |
---|---|---|
repeat | Number | Value must be a single digit number. On press of this number key, the call will be repeated. |
callTransfer | Dict | Use to configure call transfer |
callTransfer
is used to do a call transfer on press of a key. It has two option
option | type | description |
---|---|---|
transferKey | Number | On press of this key, call will be forwarded. |
transferNumber | Number | Number on which call to be forwarded. |
voice.audio("audio_file_url")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"config" : {
"repeat" : 0,
"callTransfer" : {
"transferKey" : 4,
"transferNumber" : 8798190000
}
}
}).send(callback)
voice.text("your message")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
"config" : {
"repeat" : 0,
"callTransfer" : {
"transferKey" : 4,
"transferNumber" : 8798190000
}
}
}).send(callback)
Use get
method to get request data
requestData = voice.audio("audio_file_url")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
}).get()
requestData = voice.text("your message")
.numbers(["91888xxxxx", "918323xxxx"])
.set({
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
}).get()
Additional options numbers
and is_text
are required while sending request object directly using send method
option | type | description |
---|---|---|
numbers | Array[String] | Array of String of numbers. |
is_text | Boolean | Set this to true for sending text-to-speech based voice call. |
Use audio_file_url
option to provide audio file url while making an audio call
option | type | description |
---|---|---|
audio_file_url | String | URL of audio file that will be played on voice call. |
voice.send({
"is_text" : false,
"numbers" : ["8699xxxxxx", "9435xxxxxx"],
"subscription_id" : 26236,
"maxLengthOfCall" : 14
"audio_file_url" : "your audio file url",
},callback)
To make a text synthesized voice call you will be required to provide following options along with required options.
option | type | description |
---|---|---|
text | String | The actual text that would be converted to voice by Text-to-Speech synthesis and will be played over Voice call. |
speech_rate | Number | minimum 0.5 - maximum 2 (Lower the value, Slower the speed of voice audio converted via text-to-speech synthesis ) |
language_id | Number | Language ID of the text to be converted via Text-to-Speech synthesis. |
voice.send({
"is_text" : true,
"numbers" : ["8699xxxxxx", "9435xxxxxx"]
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"text" : "your text message here",
"speech_rate" : 1,
"language_id" : 0
},callback)
If you want to schedule a voice call set send_at
to time at which you want to schedule a call and you will also be required to provide a timezone
option | type | description |
---|---|---|
send_at | String | Schedule time (in format i.e, yyyy-mm-dd hh:mm:ss) at which the SMS has to be sent |
timezone | String | timezone refers to the local time of a region or a country |
voice.send({
"is_text" : false,
"audio_file_url" : "your audio file url",
"numbers" : ["8699xxxxxx", "9435xxxxxx"],
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"send_at" : "2020-11-03 15:40:05",
"timezone" : "Asia/Kolkata (GMT +05:30)"
},callback)
voice.send({
"is_text" : true,
"text" : "your text message here",
"numbers" : ["8699xxxxxx", "9435xxxxxx"]
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
"send_at" : "2020-11-03 15:40:05",
"timezone" : "Asia/Kolkata (GMT +05:30)"
},callback)
The config
option is used to make a advanced voice call. It has two properties.
option | type | description |
---|---|---|
repeat | Number | Value must be a single digit number. On press of this number key, the call will be repeated. |
callTransfer | Object | Use to configure call transfer |
callTransfer
is used to do a call transfer on press of a key. It has two properties
option | type | description |
---|---|---|
transferKey | Number | On press of this key, call will be forwarded. |
transferNumber | Number | Number on which call to be forwarded. |
voice.send({
"is_text" : false,
"audio_file_url" : "your audio file url",
"numbers" : ["8699xxxxxx", "9435xxxxxx"],
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"config" : {
"repeat" : 0,
"callTransfer" : {
"transferKey" : 4,
"transferNumber" : 8798190000
}
}
},callback)
voice.send({
"is_text" : true,
"text" : "your text message here",
"numbers" : ["8699xxxxxx", "9435xxxxxx"]
"subscription_id" : 26236,
"maxLengthOfCall" : 14,
"speech_rate" : 1,
"language_id" : 0,
"config" : {
"repeat" : 0,
"callTransfer" : {
"transferKey" : 4,
"transferNumber" : 8798190000
}
}
},callback)
Saino First provides a service named Email API. An email API service allows you to send emails to large lists of multiple recipients by incorporating email into your applications.
Our email API allows you to send emails to users around the globe through simple RESTful APIs. You can send one email to many people, or a unique email to each person on your list with an email API service.
You can send marketing messages, newsletters, updates, coupons, and invitations through email API.
Begin by loading Sainofirst SDK into your node js project.
const Sainofirst = require("sainofirst")
Create a new instance of Sainofirst SDK. Make sure you have configured your apikey in environment variable.
const sf = new Sainofirst()
Access email service from the SDK.
const email = sf.email
Alternatively if you do not want to load whole sdk you can also access individual services. To access individual service begin by importing that service
const Email = require("sainofirst/lib/services/email")
Create an instance of the service and assign it to a variable. Make sure you have configured your apikey in environment variable.
const email = new Email()
Define a callback function which will get executed after recieving response from Sainofirst server.
function callback(success, error){
if (error) throw Error(error)
console.log(success)
}
option | Required/optional | type | description |
---|---|---|---|
to | REQUIRED | array | This is to contain email ids where you need to send emails. you can add multiple email ids where you need to send emails |
subject | REQUIRED | string | This contains email subject |
from | REQUIRED | string | This is a from email id. you can assigned only verified email id. you can verify from email id from sainofirst dashboard by below-specified section. dashboard -> bulk email -> settings-> domain |
fromName | REQUIRED | string | Display name for from email address |
bodyHtml | OPTIONAL | string | This field used to send html content in email either bodyHtml or bodyText is required |
bodyText | OPTIONAL | string | This field used to send normal text content in email either bodyHtml or bodyText is required |
trackClicks | OPTIONAL | boolean | Should the click be tracked? If no value has been provided, Account's default setting will be used. |
trackOpens | OPTIONAL | boolean | Should the opens be tracked? If no value has been provided, Account's default setting will be used |
replyToEmail | OPTIONAL | string | Email address to reply to |
replyToName | OPTIONAL | string | Name to replay to name |
attachments | OPTIONAL | array | An array of ID's of attachments. Note: you can get attachment id from uploading attachment by upload attachment API |
callbackUrl | OPTIONAL | string | Call back where you received notifications related to email. |
const sf = new Sainofirst("<sainofirst_api_token>");
sf.email.send({
to: ["test@test.com"],
subject: "email subject",
from: "name@domain.com",
bodyHtml: "<h1>Html Body</h1>",
fromName: "sahil",
}, (res, err) => {
console.log(res, err)
})
Purpose of API is whenever the user wants to send an attachment in the email. user need to upload attachment in sainofirst platform first. sainofirst will provide id represents to attachment. and the user can send this id in send email API's attachment field to send attachment along with the email.
option | Required/optional | type | description |
---|---|---|---|
file | REQUIRED | form-data | binary file data |
const sf = new Sainofirst("<sainofirst_api_token>");
const FormData = require('form-data');
const formData = new FormData();
formData.append('file', fs.createReadStream(/path-to-your-file/));
sf.email.upload(formData, (res, err) => {
console.log(res, err);
})
FAQs
The Sainofirst SDK for javascript provides a javascript API for Sainofirst communication services.
The npm package sainofirst receives a total of 1 weekly downloads. As such, sainofirst popularity was classified as not popular.
We found that sainofirst demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.