Aweber API Connection Library for Node.js Applications
aweber, which is designed to be a wrapper of aweber REST API in Node.js, enables aweber application development in event-driven style. It capsulates the access to REST API end point in asynchronous JavaScript promise call.
If you are using aweber as an API library in your Node.js project :
$ npm install aweber
If you want to get the latest from GitHub :
$ git clone git://github.com/venturepact/aweber.git $ cd aweber $ npm link
The first part is to get authorization url and oauth_token_secret
var aweber = require('aweber');
var configuration = {
appId : '<your aweber app id>',
consumer_key : '<your aweber consumer_key>',
consumer_secret : '<your aweber consumer_secret>',
oauth_callback : '<your aweber oauth_callback>',
}
aweber.configure(configuration);
aweber.oauth.authorizeUrl().then((result)=>{
console.log(result);
},(error) => {
console.log(error);
});
aweber.oauth.accessToken({
oauth_token : '<oauth_token that you get after visiting authorize url>',
oauth_verifier : '<oauth_verifier that you get after visiting authorize url>',
oauth_token_secret : '<oauth_token_secret that you get from authorizeUrl() function>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
The ouptut of this function will be newly generated oauth_token and oauth_token_secret which will be used in configuration to call all aweber rest endpoints. The final configuration object will be like this
var configuration = {
appId : '<your aweber app id>',
consumer_key : '<your aweber consumer_key>',
consumer_secret : '<your aweber consumer_secret>',
oauth_token : '<newly generated oauth_token from oauth.accessToken() function >',
oauth_token_secret : '< newly generated in oauth_token_secret from oauth.accessToken() function >'
}
aweber.configure(configuration);
aweber.account.show()
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.account.showById({
accountId : '<accountId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
findSubscribers : returns a Collection of all Subscribers on any List in the Account that matches the search parameters
aweber.account.findSubscribers({
accountId : '<accountId>'
},{
ad_tracking : '<ad_tracking>',
area_code : '<area_code>',
city : '<city>',
country : '<country>',
custom_fields : '<custom_fields>', // json object of CustomField ,
name : '<name>',
email : '<email>'
// ... for more fields refer https://labs.aweber.com/docs/reference/1.0#account_entry
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.account.getWebForms({
accountId : '<accountId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
getWebFormSplitTests : returns a list of all active WebForm Split Tests for all Lists on this Account
aweber.account.getWebFormSplitTests({
accountId : '<accountId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcast.show({
accountId : '< accountId >',
listId : '< listId >'
},{
status : '<status>' // ENUM : "draft", "scheduled", "sent" (required Param)
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
You can create broadcast message by adding all the neccessary properties in second arguments
aweber.broadcast.create({
accountId : '< accountId >', listId : '< listId >'},{
body_html : '<body_html>',
body_text : '<body_text>',
click_tracking_enabled : '<click_tracking_enabled>',
exclude_lists : '< List Of List Uris >',
....
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcast.showById({
accountId : '< accountId >',
listId : '< listId >',
broadcastId : '<broadcastId>'
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcast.delete({
accountId : '< accountId >',
listId : '< listId >',
broadcastId : '<broadcastId>'
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcast.update({
accountId : '< accountId >',
listId : '< listId >',
broadcastId : '<broadcastId>'
},{
body_html : '<body_html>',
body_text : '<body_text>',
subject : '<subject>',
notify_on_send : '<notify_on_send>',
facebook_integration : '<facebook_integration>'
// for more parameters refer https://labs.aweber.com/docs/reference/1.0#broadcast_entry
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcastCampaign.showById({
accountId : '< accountId >',
listId : '< listId >',
broadcastId : '<broadcastId>'
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.broadcastScheduler.schedule({
accountId : '< accountId >',
listId : '< listId >',
broadcastId : '<broadcastId>'
},{
scheduled_for : '<scheduled_for>' // DateTime ISO 8601 format (Scheduled time for sending broadcast message.)
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.campaign.show({
accountId : '<accountId>',
listId : '<listId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.campaign.find({
accountId : '<accountId>',
listId : '<listId>'
},{
campaign_type : '<campaign_type>' // Enum "b", "f"
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.campaign.showById({
accountId : '<accountId>',
listId : '<listId>',
broadcastId : '<broadcastId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.cancelBroadcast.cancel({
accountId : '<accountId>',
listId : '<listId>',
broadcastId : '<broadcastId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.click.show({
accountId : '<accountId >',
listId : '<listId>',
campaignId : '<campaignId>',
linkId : '<linkId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.click.showById({
accountId : '<accountId >',
listId : '<listId>',
campaignId : '<campaignId>',
linkId : '<linkId>',
clickId : '<clickId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.component.show({
accountId : '<accountId >',
listId : '<listId>',
campaignId : '<campaignId>',
linkId : '<linkId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.component.showById({
accountId : '<accountId >',
listId : '<listId>',
campaignId : '<campaignId>',
linkId : '<linkId>',
componentId : '<componentId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.customField.show({
accountId : '<accountId>',
listId : '<listId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.customField.showById({
accountId : '<accountId>',
listId : '<listId>',
customFieldId : '<customFieldId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.customField.create({
accountId : '<accountId>',
listId : '<listId>'
},{
name : '<name>' //Name of CustomField
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
Warning: Modifing/Deleting CustomFields has side effects, find out more here: https://help.aweber.com/entries/21749682-why-could-changing-my-custom-field-names-cause-problems
aweber.customField.update({
accountId : '<accountId>',
listId : '<listId>',
customFieldId : 'customFieldId'
},{
name : '<name>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
Warning: Modifing/Deleting CustomFields has side effects, find out more here: https://help.aweber.com/entries/21749682-why-could-changing-my-custom-field-names-cause-problems
aweber.customField.delete({
accountId : '<accountId>',
listId : '<listId>',
customFieldId : 'customFieldId'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.doc.show({})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.doc.showById({
docId : '<docId>'
})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.integration.show({accountId : '<accountId>'})
.then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.integration.showById({
accountId : '<accountId>',
integrationId : '<integrationId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.link.show({
accountId : '<accountId>',
listId : '<linkId>',
campaignId : '<campaignId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.link.showById({
accountId : '<accountId>',
listId : '<linkId>',
campaignId : '<campaignId>',
linkId : '<linkId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.list.show({
accountId : '<accountId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.list.showById({
accountId : '<accountId>',
listId : '<listId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.list.find({
accountId : '<accountId>'
},{
name : '<name of list>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.message.show({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.message.showById({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
messageId : '<messageId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.message.getSubscribers({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.open.show({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
messageId : '<messageId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.open.showById({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
messageId : '<messageId>',
openId : '<openId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.stat.show({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.stat.showById({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
statId : '<statId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.show({
accountId : '<accountId>',
listId : '<listId>',
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.find({
accountId : '<accountId>',
listId : '<listId>',
},{
ad_tracking : '<ad_tracking>',
area_code : '<area_code>',
city : '<city>',
country : '<country>',
custom_fields : '<custom_fields>' // in json object Custom Field Data,
status : '<status>',
name : '<name>',
// ... and other Subscriber collection field please refer https://labs.aweber.com/docs/reference/1.0#subscriber_collection
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.create({
accountId : '<accountId>',
listId : '<listId>',
},{
custom_fields : '<custom_fields>' // in json object Custom Field Data,
tags : '<tags>',
name : '<name>'
// ... and other Subscriber collection field please refer https://labs.aweber.com/docs/reference/1.0#subscriber_collection
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.showById({
accountId : '<accountId>',
listId : '<listId>',
subscriberId : '<subscriberId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.showById({
accountId : '<accountId>',
listId : '<listId>',
subscriberId : '<subscriberId>'
},{
// fields that you want to update
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.getActivity({
accountId : '<accountId>',
listId : '<listId>',
subscriberId : '<subscriberId>'
},{
// fields that you want to update
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.subscriber.archive({
accountId : '<accountId>',
listId : '<listId>',
subscriberId : '<subscriberId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.trackedEvent.show({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
messageId : '<messageId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.trackedEvent.show({
accountId : '<accountId>',
listId : '<listId>',
campaignId : '<campaignId>',
messageId : '<messageId>',
trackEventId : '<trackEventId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.webFormSplitTest.show({
accountId : '<accountId>',
listId : '<listId>',
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.webFormSplitTest.show({
accountId : '<accountId>',
listId : '<listId>',
webFormSplitTestId : '<webFormSplitTestId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.webForm.show({
accountId : '<accountId>',
listId : '<listId>',
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})
aweber.webForm.showById({
accountId : '<accountId>',
listId : '<listId>',
webFormId : '<webFormId>'
}).then((result)=>{
console.log(result);
}).catch((error)=> {
console.log(error);
})