aweber

1.0.1 • Public • Published

aweber

Aweber API Connection Library for Node.js Applications

Abstract

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.

Install

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

API Usage

Authorization

Authorization Url

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);
});

Access_token

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);

Collections Endpoints

Accounts

show : returns all account resources

 
aweber.account.show()
    .then((result)=>{
        console.log(result);
    }).catch((error)=> {
        console.log(error);
    })
 

showById : returns integrations_collection_link and lists_collection_link associated to account Id

 
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);
})
 

getWebForms : returns a list of all active WebForms for all Lists on this Account.

 
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);
})
 

Broadcasts

show : returns list of broadcast messages

 
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);
    })
 

create : create a broadcast message

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);
})
 

showById : returns Broadcast message details by it's id

aweber.broadcast.showById({
        accountId : '< accountId >',
        listId : '< listId >',
        broadcastId : '<broadcastId>'
    })
    .then((result)=>{
        console.log(result);
    }).catch((error)=> {
        console.log(error);
    })
 

delete : delete a broadcast message

aweber.broadcast.delete({
        accountId : '< accountId >',
        listId : '< listId >',
        broadcastId : '<broadcastId>'
    })
    .then((result)=>{
        console.log(result);
    }).catch((error)=> {
        console.log(error);
    })
 

update : Update Broadcast message

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);
    })
 

Broadcast Campaign

showById : Represents a Broadcast Campaign

aweber.broadcastCampaign.showById({
        accountId : '< accountId >',
        listId : '< listId >',
        broadcastId : '< broadcastId >'
    })
    .then((result)=>{
        console.log(result);
    }).catch((error)=> {
        console.log(error);
    })
 

Broadcast Scheduler

schedule : allows the scheduling of broadcast messages

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);
    })
 

Campaign

show : returns collection of Followup or Broadcast Campaigns

 
aweber.campaign.show({
    accountId : '<accountId>',
    listId : '<listId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

find : returns collection of Campaign according campaign_type

 
aweber.campaign.find({
    accountId : '<accountId>',
    listId : '<listId>'
},{
    campaign_type : '<campaign_type>' // Enum "b", "f"
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : a followup or Broadcast Campaign

 
aweber.campaign.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Cancel Broadcast

cancel : canceling of broadcast messages

 
aweber.cancelBroadcast.cancel({
    accountId : '<accountId>',
    listId : '<listId>',
    broadcastId : '<broadcastId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Click

show : returns collection of Click events

aweber.click.show({
    accountId : '<accountId >',
    listId : '<listId>',
    campaignId : '<campaignId>',
    linkId : '<linkId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : returns event where a Subscriber clicks a Link in a Message.

aweber.click.showById({
    accountId : '<accountId >',
    listId : '<listId>',
    campaignId : '<campaignId>',
    linkId : '<linkId>',
    clickId : '<clickId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Component

show : returns collection of WebFormSplitTest Components

 
aweber.component.show({
    accountId : '<accountId >',
    listId : '<listId>',
    campaignId : '<campaignId>',
    linkId : '<linkId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return a Component of a WebFormSplitTest

 
aweber.component.showById({
    accountId : '<accountId >',
    listId : '<listId>',
    campaignId : '<campaignId>',
    linkId : '<linkId>',
    componentId : '<componentId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Custom Field

show : returns collection of CustomFields for a List

aweber.customField.show({
    accountId : '<accountId>',
    listId : '<listId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : returns collection of CustomFields for a List

aweber.customField.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    customFieldId : '<customFieldId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

create : create a custom field for a list

 
aweber.customField.create({
    accountId : '<accountId>',
    listId : '<listId>'
},{
    name : '<name>'  //Name of CustomField
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

update : update custom Field

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);
})
 

delete : delete a custom Field

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);
})
 

Doc

show : return all docs

 
aweber.doc.show({})
.then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return doc by its Id

 
aweber.doc.showById({
    docId : '<docId>'
})
.then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Integration

show : returns collection of 3rd Party Service Integrations

 
aweber.integration.show({accountId : '<accountId>'})
.then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return 3rd Party Service Integrations

 
aweber.integration.showById({
    accountId : '<accountId>',
    integrationId : '<integrationId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Link

show : return collection of Links appearing in a Campaign

 
aweber.link.show({
    accountId : '<accountId>',
    listId : '<linkId>',
    campaignId : '<campaignId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return a Link appearing in a Campaign

 
aweber.link.showById({
    accountId : '<accountId>',
    listId : '<linkId>',
    campaignId : '<campaignId>',
    linkId : '<linkId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

List

show : returns collection of Subscriber Lists

 
aweber.list.show({
    accountId : '<accountId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return Subscriber List

 
aweber.list.showById({
    accountId : '<accountId>',
    listId : '<listId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

find : returns collection of Lists matching the given search parameters present in second argument

 
aweber.list.find({
    accountId : '<accountId>'
},{
    name : '<name of list>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Message

show : returns collection of sent message events

 
aweber.message.show({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : returns a sent message event

 
aweber.message.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    messageId : '<messageId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

getSubscribers : returns a collection of Subscribers that were sent this Campaign

 
aweber.message.getSubscribers({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Open

show : returns collection of Open events

 
aweber.open.show({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    messageId : '<messageId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

show : returns an Open event

 
aweber.open.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    messageId : '<messageId>',
    openId : '<openId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Stat

show : returns collection of Broadcast Campaign Stats

 
aweber.stat.show({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return a Broadcast Campaign Stat

 
aweber.stat.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    statId : '<statId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Subscriber

show : return collection of subscribers

 
aweber.subscriber.show({
    accountId : '<accountId>',
    listId : '<listId>',
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

find : returns a collection of Subscribers that matches the given search parameters

 
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);
})
 

create : add a subscriber to a list

 
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);
})
 

showById : return subscriber

 
aweber.subscriber.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    subscriberId : '<subscriberId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

update : update subscriber

 
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);
})
 

getActivity : return analytics activity for this Subscriber.

 
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);
})
 

archive : delete a subscriber and all their data

 
aweber.subscriber.archive({
    accountId : '<accountId>',
    listId : '<listId>',
    subscriberId : '<subscriberId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Tracked Event

show : returns A collection of TrackedEvents

 
aweber.trackedEvent.show({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    messageId : '<messageId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

show : return TrackedEvent

 
aweber.trackedEvent.show({
    accountId : '<accountId>',
    listId : '<listId>',
    campaignId : '<campaignId>',
    messageId : '<messageId>',
    trackEventId : '<trackEventId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

WebFormSplitTests

show : returns collection of WebFormSplitTests

 
aweber.webFormSplitTest.show({
    accountId : '<accountId>',
    listId : '<listId>',
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return WebFormSplitTest

 
aweber.webFormSplitTest.show({
    accountId : '<accountId>',
    listId : '<listId>',
    webFormSplitTestId : '<webFormSplitTestId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

WebForm Collection

show : returns collection of WebForms

 
aweber.webForm.show({
    accountId : '<accountId>',
    listId : '<listId>',
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

showById : return WebForm

 
aweber.webForm.showById({
    accountId : '<accountId>',
    listId : '<listId>',
    webFormId : '<webFormId>'
}).then((result)=>{
    console.log(result);
}).catch((error)=> {
    console.log(error);
})
 

Readme

Keywords

Package Sidebar

Install

npm i aweber

Weekly Downloads

23

Version

1.0.1

License

ISC

Last publish

Collaborators

  • gtarun
  • thevikash