1.0.3 • Published 2 years ago
maildrip v1.0.3
maildrip
Interact with Maildrip's apis using this simple Nodejs module. Create, edit and delete campaigns, add and modify recipients to your recipients' list and more from your Node.js environment.
Installation
# using npm
npm install maildrip
# using yarn
yarn add maildrip
Usage
const Maildrip = require('maildrip');
const maildrip = Maildrip({
api_key: XXXXXXXXXXXXXXX,
access_secret: XXXXXXXXXXXXXXX
})
Note: You can get your keys from your Maildrip dashboard. For more information, read our api documentation.
Examples
Get User
profile details
Using Promises
maildrip.user.getAccountData()
.then((userdata) => console.log(userdata));
Using async/await
const getUserData = async function () {
const userData = maildrip.user.getAccountData()
console.log(userData);
};
getUserData()
Create a Campaign
Using Promises
maildrip.campaign.create("My amazing campaign", {
interval: "10",
unit: "minutes"
})
.then((campaign) => console.log(campaign));
Using async/await
const createCampaign = async function () {
const campaign = maildrip.campaign.create("My amazing campaign", {
interval: "10",
unit: "minutes"
})
console.log(campaign);
}
createCampaign()
Note: The second parameter can either be an object or a number. In cases where number is specified, the unit default will be minutes
Add a Recipient
to a Campaign
Using Promises
maildrip.recipient.add(campaignId, {
name: "My recipient",
email: "myrecipient@mail.com"
})
.then((recipient) => console.log(recipient));
Using async/await
const addRecipient = async function () {
const recipient = await maildrip.recipient.add(campaignId, {
name: "My recipient",
email: "myrecipient@mail.com"
})
console.log(recipient);
}
addRecipient()
Note: You can find your campaignId in the campaign settings tab on your Maildrip dashboard.
More APIs?
Can't get enough? Read more of our api documentation.