Code Monkey home page Code Monkey logo

rocketchat-node's Introduction

JavaScript RocketChat API for node.js

A node.js module, which provides an object oriented wrapper for the RocketChat REST API.

RocketChat official website address can be found here . RocketChat REST API document can be found here.

This Lib library package the following functions:

Installation

Install with the node package manager npm:

$ npm install rocketchat

or

Install via git clone:

$ git clone https://github.com/qeesung/rocketchat-node.git
$ cd rocketchat-node
$ npm install

Examples

Create the rocket-chat client

var RocketChatApi = require('rocketchat').RocketChatApi;
// alpha-api versions
var rocketChatApi = new RocketChatApi('http', config.host, config.port, config.user, config.password);
// v1-api versions
var rocketChatApi = new RocketChatApi('http', config.host, config.port, config.user, config.password, "v1");

Obtaining the running rocket-chat version

rocketChatApi.version(function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Login rocket-chat

rocketChatApi.login(function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

You don't have to log in every time, and automatically log on when you call the other interface.

Logoff rocket-chat

rocketChatApi.logout(function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Get list of public rooms

rocketChatApi.getPublicRooms(function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Join a room

rocketChatApi.joinRoom(roomID ,function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Leave a room

rocketChatApi.leaveRoom(roomID ,function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Create a room

rocketChatApi.createRoom(roomName ,function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Set a rooms topic

rocketChatApi.setTopic(roomID, topicName, function(err, body){
    if(err)
         console.log(err);
    else
        console.log(body);
})

Get all unread messages in a room

rocketChatApi.getUnreadMsg(roomID ,function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

Sending a message

rocketChatApi.sendMsg(roomID, message, function(err,body){
	if(err)
		console.log(err);
	else
		console.log(body);
})

More information can be found by checking RocektChat REST API

Options

RocketChatApi Options:

  • protocol<string>: Typically 'http:' or 'https:'
  • host<string>: The hostname for your jira server
  • port<int>: The port your jira server is listening on (probably 80 or 443)
  • username<string>: The username to log in with
  • password<string>: Keep it secret, keep it safe

Implemented APIs

  • Authentication
  • HTTP
  • OAuth(comming soon)
  • Room
  • get public rooms
  • join a room
  • leave a room
  • Messages
  • get unread messages from a room
  • send messages to a room
  • Set Topic for Room

TODO

  • achieved OAuth authentication mode
  • Add SSL security mode

rocketchat-node's People

Contributors

chunlin-li avatar happyunclemeng avatar jack-collins avatar leathersole avatar matthiaskainer avatar qeesung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.