All Projects → DripEmail → drip-nodejs

DripEmail / drip-nodejs

Licence: MIT license
The complete Nodejs wrapper for the Drip REST API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to drip-nodejs

caffeinate
A Rails engine for drip campaigns/scheduled email sequences and periodic emails.
Stars: ✭ 216 (+1100%)
Mutual labels:  marketing-automation, drip
Mailtrain
Self hosted newsletter app
Stars: ✭ 4,931 (+27294.44%)
Mutual labels:  marketing-automation, email-marketing
Moonmail
Email marketing platform for bulk emailing via Amazon SES (Google Cloud Platform and Azure coming soon)
Stars: ✭ 1,766 (+9711.11%)
Mutual labels:  marketing-automation, email-marketing
jeeshop
No description or website provided.
Stars: ✭ 39 (+116.67%)
Mutual labels:  e-commerce
codizer-core
Laravel CMS, CRM, E-Commerce
Stars: ✭ 43 (+138.89%)
Mutual labels:  e-commerce
LinkedIn-Scraper
A LinkedIn Scraper to scrape up to 10k LinkedIn profiles from company profile links and save their e-mail addresses if available!
Stars: ✭ 62 (+244.44%)
Mutual labels:  email-marketing
An-PHP-Based-Affiliate-marketing-website
University project involving Javascript, PHP, HTML, CSS and database’s queries management.
Stars: ✭ 51 (+183.33%)
Mutual labels:  e-commerce
framework
[READ-ONLY] Core of Shopsys Framework - open source framework for building large, scalable, fast-growing e-commerce projects based on Symfony
Stars: ✭ 21 (+16.67%)
Mutual labels:  e-commerce
grav-skeleton-gravcart
The Grav Shopping Cart skeleton
Stars: ✭ 11 (-38.89%)
Mutual labels:  e-commerce
x
Commerce Search & Discovery frontend web components
Stars: ✭ 54 (+200%)
Mutual labels:  e-commerce
L-Shop
Modern e-commerce system for Minecraft.
Stars: ✭ 121 (+572.22%)
Mutual labels:  e-commerce
rudder-sdk-js
JavaScript SDK for RudderStack - the Customer Data Platform for Developers.
Stars: ✭ 92 (+411.11%)
Mutual labels:  marketing-automation
laravel-shopping-cart
e-commerce shopping cart for laravel application.
Stars: ✭ 38 (+111.11%)
Mutual labels:  e-commerce
kasir
Cashier Management & Inventory Management System
Stars: ✭ 28 (+55.56%)
Mutual labels:  e-commerce
email-template-generator
Simple and useful web app to generate e-mails for any reason you want!
Stars: ✭ 51 (+183.33%)
Mutual labels:  email-marketing
mytek
Django e-commerce web application with advanced features
Stars: ✭ 27 (+50%)
Mutual labels:  e-commerce
awesome-medusajs
A curated list of awesome resources related to MedusaJS 😎
Stars: ✭ 113 (+527.78%)
Mutual labels:  e-commerce
enhavo
Modern CMS with shop features based on fullstack symfony and sylius components
Stars: ✭ 80 (+344.44%)
Mutual labels:  e-commerce
7cart
7cart is a php7 project for building online shops, catalogs or service platforms. 7cart built with simple code and database schema. It is easy to support and fast.
Stars: ✭ 27 (+50%)
Mutual labels:  e-commerce
acorn
A responsive email framework based on a golden ratio typography grid.
Stars: ✭ 90 (+400%)
Mutual labels:  email-marketing

Build Status

Drip Rest API Wrapper for Node.js

A complete Nodejs wrapper for the Drip REST API.

How to install

npm install drip-nodejs --save

NOTE: Potential Breaking Changes for Version 3.0.0

Drip's documentation doesn't explicitly describe the required schema for each endpoint. In versions prior to 3 you would need to explicitly pass payloads with the required schema, which aren't obvious. In version 3 and later, I've attempted to make this a bit simpler. For example, batch endpoints will now only need you to pass an array of objects as:

payload = [
  {
    email: '[email protected]',
    action: 'Purchased'
  },
  {
    email: '[email protected]',
    action: 'Purchased'
  }
]
// client.recordBatchEvents(payload, ...)

Prior to v3 changes you would need to do something like the following where the entire payload structure is defined:

payload = {
  batches: [
    {
      events: [
        {
          email: '[email protected]',
          action: 'Purchased'
        },
        {
          email: '[email protected]',
          action: 'Purchased'
        }
      ]
    }
  ]
}
// client.recordBatchEvents(payload, ...)

This should help to get up and running simpler without much knowledge of the required schema. However, existing users will need to take special note of these changes.

Authentication

For private use and integrations, use your API Token found here. Create a new instance of the client library with:

const client = require('drip-nodejs')({ token: YOUR_API_KEY, accountId: YOUR_ACCOUNT_ID });

For public integrations with an OAuth2 application registered with Drip, you'll need to specify the type of token you're passing (e.g. "Bearer"):

const client = require('drip-nodejs')({ token: YOUR_ACCESS_TOKEN, tokenType: TOKEN_TYPE, accountId: YOUR_ACCOUNT_ID });

You'll need your Drip Account ID when requiring the client which can be found here in your Drip account.

Usage

The following methods are currently available on the client instance. You can find a detailed explanation of all methods and their effect on resources in your Drip account here.

Note: All methods except updateBatchSubscribers return promises and support an optional asynchronous callback. The batch subscribers method only supports callbacks for now.

Accounts

Action Method
List all accounts client.listAccounts(callback)
Fetch an account client.fetchAccount(accountId, callback)

Broadcasts

Action Method
List broadcasts client.listBroadcasts(options = {}, callback)
Fetch a broadcast client.fetchBroadcast(broadcastId, callback)

Campaigns

Action Method
List all campaigns client.listCampaigns(options = {}, callback)
Fetch a campaign client.fetchCampaign(campaignId, callback)
Activate a campaign client.activateCampaign(campaignId, callback)
Pause a campaign client.pauseCampaign(campaignId, callback)
List specific campaign's subscribers client.listAllSubscribesToCampaign(campaignId, options = {}, callback)
Subscribe to a campaign client.subscribeToCampaign(campaignId, payload, callback)

Campaign subscriptions

Action Method
List campaign subscriptions client.subscriberCampaignSubscriptions(subscriberId, callback)

Conversions

Action Method
List all conversions client.listConversions(options = {}, callback)
Fetch a conversion client.fetchConversion(conversionId, callback)

Custom fields

Action Method
List all custom fields client.listAllCustomFields(callback)

Events

Action Method
Record an event client.recordEvent(payload, callback)
Record a batch of events client.recordBatchEvents(payload, callback)
List all events in account client.listEventActions(options = {}, callback)

Forms

Action Method
List all forms client.listForms(callback)
Fetch a form client.fetchForm(formId, callback)

Note: The beta purchases endpoint has been deprecated and its methods have been removed from the package except createPurchase, which now sends requests to the Order creation endpoint here.

Orders

Action Method
Record an order for a subscriber client.createUpdateOrder(payload, callback)
Record a batch of orders client.createUpdateBatchOrders(payload, callback)
Record a refund for an order client.createUpdateRefund(payload, callback)

Shopper Activity

Action Method
Create or update a cart for a customer client.createUpdateCartActivity(payload, callback)
Create or update an order for a customer client.createUpdateOrderActivity(payload, callback)
Create or update a product client.createUpdateProductActivity(payload, callback)

Subscribers

Action Method
List all subscribers client.listSubscribers(options = {}, callback)
Update a subscriber client.createUpdateSubscriber(payload, callback)
Fetch a subscriber client.fetchSubscriber(idOrEmail, callback)
Unsubscribe from a campaign client.unsubscribeFromCampaign(idOrEmail, campaignId, callback)
Unsubscribe from all mailings client.unsubscribeFromAllMailings(idOrEmail, callback)
Delete a subscriber client.deleteSubscriber(idOrEmail, callback)
Update a batch of subscribers client.updateBatchSubscribers(payload, callback)
Unsubscribe a batch of subscribers client.unsubscribeBatchSubscribers(payload, callback)

Tags

Action Method
List all tags client.listAllTags(callback)
Tag a subscriber client.tagSubscriber(payload, callback)
Remove tag from subscriber client.removeSubscriberTag(email, tag, callback)

User

Action Method
Fetch authenticated user client.fetchUser(callback)

Webhooks

Action Method
List all webhooks client.listWebhooks(callback)
Fetch a webhook client.fetchWebhook(webhookId, callback)
Create a webhook client.createWebhook(payload, callback)
Destroy a webhook client.destroyWebhook(webhookId, callback)

Workflows

Action Method
List all workflows client.listAllWorkflows(options = {}, callback)
Fetch a workflow client.fetchWorkflow(workflowId, callback)
Activate a workflow client.activateWorkflow(workflowId, callback)
Pause a workflow client.pauseWorkflow(workflowId, callback)
Start a subscriber on a workflow client.startOnWorkflow(workflowId, payload, callback)
Remove a subscriber from a workflow client.removeFromWorkflow(workflowId, idOrEmail, callback)

Workflow triggers

Action Method
List all workflow triggers client.listTriggers(workflowId, callback)
Create a workflow trigger client.createTrigger(workflowId, payload, callback)
Update a trigger client.updateTrigger(workflowId, triggerId, payload, callback)

See the official REST API docs for a complete API reference.

Examples

Listing subscribers

The listSubscribers accepts an optional object of filter arguments. Refer to Drip's API docs for all the available filters.

/**
 * Using a promise
 */

const options = {
  status: "unsubscribed",
  page: 2
  // or with more options
};

client.listSubscribers(options)
  .then((response) => {
    // do something with the raw response object or with `response.body`
  })
  .catch((error) => {
    // do something with the error
  });

/**
 * Using a callback
 */

client.listSubscribers(options, (error, response, body) => {
  // do someting with the response or handle errors
});

Updating a batch of subscribers

The updateBatchSubscribers method takes a batch object for the payload and is most suitable for sending thousands of subscriber updates.

Because Drip's batch APIs support a maximum of 1000 records, this method breaks the payload into N "batches" and calls the API N times. The callback is invoked only after all batches' API calls have returned, and receives N-sized arrays for values (i.e. errors, responses, and bodies).

It is the responsibility of the caller to interpret these values and handle any errors.

var batch = {
  "batches": [{
    "subscribers": [
      {
        "email": "[email protected]",
        "tags": "Dog Person"
      },
      {
        "email": "[email protected]",
        "tags": "Cat Person"
      }
      // Lots more subscribers...
    ]
  }]
}

client.updateBatchSubscribers(batch, function (errors, responses, bodies) {
  // Do stuff
  }
)

Sending a batch of events

The recordBatchEvents methods takes a batch object for the payload and is most suitable for sending thousands of events. Note that the batch events method will not break up the payload into nice chunks like the subscribers batch method. This will be handled in a future update.

var batch = {
  "batches": [{
    "events": [
      {
        "email": "[email protected]",
        "action": "Opened a door"
      },
      {
        "email": "[email protected]",
        "action": "Closed a door"
      }
      // Lots more events...
    ]
  }]
}

client.recordBatchEvents(batch, function (error, response, body) {
  // Do stuff
  }
)

Contributing

  1. Fork it ( https://github.com/samudary/drip-nodejs/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Note: Jasmine is used for testing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].