Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.77 KB

File metadata and controls

47 lines (37 loc) · 1.77 KB

sendbird-nodejs

Thin wrapper around SendBird Server REST API

PLEASE NOTE THIS WORKS ON TOP OF SENDBIRD V2.0 API - V3.0 WILL COME SOON

Installation

npm install sendbird-nodejs --save

Usage

See SendBird Documentation for payload and response details.
You don't need to pass the auth field on the payload, you provide it when creating a new instance of SendBird and it is attached to all requests.

var SendBird = require('sendbird-nodejs');
var sb = new SendBird(config.sendBird.appToken);

The sb instance we just created has a field for each endpoint in the SendBird Server API that is an object with the endpoints methods.
sb.user
sb.channel
sb.messaging
sb.admin
sb.migration

So, to create a user you would simply need to have something like this:

var payload = {
    "id": string,                 // User ID
    "nickname": string,           // User nickname
    "image_url": string,          // User profile image URL
    "issue_access_token": boolean // Default is false. Use only if you want to create an access token for this user
};
sb.user.create(payload)
    .then(function (response) {
        // do something with SendBird response    
    });

Contributing

  1. Fork it!
  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. Submit a pull request :D