yournotify-node-sdk
v1.0.3
Published
NPM SDK for Yournotify API. Send email and sms marketing campaigns with ease.
Maintainers
Readme
Yournotify Node SDK
Installation
Install the Yournotify Node.js SDK using npm:
npm install yournotify-node-sdkUsage
First, import the Yournotify class and initialize it with your API key.
import Yournotify from "yournotify-node-sdk";
const apiKey = "your_api_key_here";
const yournotify = new Yournotify(apiKey);Sending an Email
yournotify
.sendEmail(
"Awesome Campaign", // name
"[email protected]", // from
"Subject", // subject
"<h1>Hello</h1>", // html
"Hello", // text
"running", // status
["[email protected]"] // to
)
.then((response) => {
console.log(response.status); // success or failed
console.log(response.data.id); // Campaign ID
});Sending an SMS
yournotify
.sendSMS(
"Awesome Campaign", // name
"sender_id", // from
"Hello world!", // text
"running", // status
["+2348100000000"] // to
)
.then((response) => {
console.log(response.status); // success or failed
console.log(response.data.id); // Campaign ID
});Adding a Contact
yournotify
.addContact(
"[email protected]",
"+2348100000000",
"list_id",
"Contact Name",
{ key: "value" }
)
.then((response) => {
console.log(response.status);
console.log(response.data.id); // Contact ID
});Getting All Contacts
yournotify.getContacts().then((response) => {
console.log(response.status);
console.log(response.data); // List of contacts
});Deleting a Contact
yournotify.deleteContact(123).then((response) => {
console.log(response.status); // success or failed
});Adding a List
yournotify.addList("List Title", "type", "optin").then((response) => {
console.log(response.status);
console.log(response.data.id); // List ID
});Getting All Lists
yournotify.getLists().then((response) => {
console.log(response.status);
console.log(response.data); // List of lists
});Deleting a List
yournotify.deleteList(456).then((response) => {
console.log(response.status); // success or failed
});Deleting a Campaign
yournotify.deleteCampaign(789).then((response) => {
console.log(response.status); // success or failed
});Getting Campaign Stats
yournotify.getCampaignStats(123, "email").then((response) => {
console.log(response.status);
console.log(response.data); // Campaign stats
});Getting Campaign Reports
yournotify.getCampaignReports(123, "sms").then((response) => {
console.log(response.status);
console.log(response.data); // Campaign reports
});Getting Your Profile
yournotify.getProfile().then((response) => {
console.log(response.status);
console.log(response.data); // Profile information
});API Methods Reference
API Methods
sendEmail(name, from, subject, html, text, status, to)
Sends an email campaign.to: Accepts either:- An array of email strings
Example:["[email protected]", "[email protected]"]; - An array of objects
Example:[ { email: "[email protected]", name: "Recipient One", attribs: { key: "value" }, // optional }, { email: "[email protected]", name: "Recipient Two", attribs: { key: "value2" }, // optional }, ];
- An array of email strings
SMS
sendSMS(name, from, text, status, to)
Sends an SMS campaign.to: Accepts either:- An array of phone number strings
Example:["+2348100000000", "+2348100000001"]; - An array of objects
Example:[ { telephone: "+2348100000000", name: "Recipient One", attribs: { key: "value" }, // optional }, { telephone: "+2348100000001", name: "Recipient Two", attribs: { key: "value2" }, // optional }, ];
- An array of phone number strings
Contacts
addContact(email, telephone, list, name, attribs)
Adds a contact to a list.getContact(id)
Retrieves a contact by ID.getContacts()
Retrieves all contacts.deleteContact(id)
Deletes a contact by ID.
Lists
addList(title, type, optin)
Creates a new list.getList(id)
Retrieves a list by ID.getLists()
Retrieves all lists.deleteList(id)
Deletes a list by ID.
Campaigns
deleteCampaign(id)
Deletes a campaign by ID.getCampaignStats(ids, channel)
Retrieves campaign statistics for one or more campaign IDs.channel:"email"or"sms"
getCampaignReports(ids, channel)
Retrieves campaign reports for one or more campaign IDs.channel:"email"or"sms"
Profile
getProfile()
Retrieves your profile information, including account credits and related data.
More Information
For full API reference, visit the Yournotify API Documentation.
License
This SDK is open-source and available under the MIT License.
