Node.js module to connect to servers using DDP protocol.

npm install ddp
436 downloads in the last day
2 445 downloads in the last week
11 234 downloads in the last month

Node DDP Client

A callback style DDP (Meteor's Distributed Data Protocol) node client.

Based heavily on alansikora's node-js_ddp-client, and meteor's python client. Uses a more callback style approach.

The client implements the pre1 version of DDP, with optional EJSON support. It is unfinished at this point, but should do most of what you want it to do.


  npm install ddp


Please see the example in examples/example.js. Or here for reference:

var DDPClient = require("ddp");

var ddpclient = new DDPClient({
  host: "localhost", 
  port: 3000,
  /* optional: */
  auto_reconnect: true,
  auto_reconnect_timer: 500,
  use_ejson: true,  // default is false
  use_ssl: false, //connect to SSL server,
  use_ssl_strict: true, //Set to false if you have root ca trouble.
  maintain_collections: true //Set to false to maintain your own collections.

ddpclient.connect(function(error) {
  if (error) {
    console.log('DDP connection error!');


  ddpclient.loginWithUsername("myusername","ddp-rocks",function(err) {
      //Do stuff after login

  ddpclient.call('test-function', ['foo', 'bar'], function(err, result) {
    console.log('called function, result: ' + result);

  ddpclient.subscribe('posts', [], function() {
    console.log('posts complete:');

 * Useful for debugging and learning the ddp protocol
ddpclient.on('message', function(msg) {
  console.log("ddp message: " + msg);

 * If you need to do something specific on close or errors.
 * (You can also disable auto_reconnect and call ddpclient.connect()
 * when you are ready to re-connect.)
ddpclient.on('socket-close', function(code, message) {
  console.log("Close: %s %s", code, message);

ddpclient.on('socket-error', function(error) {
  console.log("Error: %j", error);

Unimplemented Features

  • Server to Client messages
    • 'addedBefore'
    • 'movedBefore'
    • 'error'
    • 'updated'


Many thanks to Alan Sikora for the ddp-client which formed the inspiration for this code.


  • Tom Coleman (@tmeasday)
  • Thomas Sarlandie (@sarfata)
  • Mason Gravitt (@emgee3)
  • Mike Bannister (@possiblities)
  • Chris Mather (@eventedmind)
  • James Gill (@jagill)
npm loves you