node package manager

messagebird

A node.js wrapper for the MessageBird REST API

MessageBird REST API for Node.js

This repository contains the open source Node.js client for MessageBird's REST API. Documentation can be found at: https://www.messagebird.com/developers/nodejs

  • Sign up for a free MessageBird account
  • Create a new access_key in the developers section
  • MessageBird REST API for Node.js requires Node.js >= 0.10 or io.js

npm install messagebird

We have put some self-explanatory examples in the examples directory, but here is a quick breakdown on how it works. Let's go ahead and initialize the library first. Don't forget to replace <YOUR_ACCESS_KEY> with your actual access key.

var messagebird = require('messagebird')('<YOUR_ACCESS_KEY>');

Nice! Now we can send API requests through node. Let's use getting your balance overview as an example:

// Get your balance 
messagebird.balance.read(function (err, data) {
  if (err) {
    return console.log(err);
  }
  console.log(data);
});
 
// Result object: 
{
  payment: 'prepaid',
  type: 'credits',
  amount: 42.5
}

Or in case of an error:

{ [Error: api error]
  errors: [
    {
      code: 2,
      description: 'Request not allowed (incorrect access_key)',
      parameter: 'access_key'
    }
  ]
}

Complete documentation, instructions, and examples are available at: https://www.messagebird.com/developers/nodejs

The MessageBird REST API for Node.js is licensed under The BSD 2-Clause License. Copyright (c) 2014, MessageBird