npm

Need private packages and team management tools?Check out npm Orgs. »

rc-api

2.0.0 • Public • Published

A Library to access the Rocket.Chat API via functions.

Installation

npm i -S rc-api

Usage

If you, for example, want to assign the pin-message permission to the user role, you can do the following:

const RCApi = require('rc-api');
const api = new RCApi({logger: console, dryRun: false});

api.permissions.addPermission({
    client: {
        url: 'https://my-chat.example.com',
        username: 'admin-user',
        passw: 'my-secret-password'
    },
    permission: 'pin-message',
    role: 'user'
});

The client object, which is given to the API functions, will be modified to contain the access token after the first call which is used in later calls as well. So it is a good idea to re-use the same object, if you do more than one API call.

Options to rc-api constructor

  • logger - the logger you want to use. Defaults to console
  • dryRun - if set true, all API calls are replaced by GET methods

Which API paths are supported?

Currently only those Rocket.Chat API paths are covered, that we needed for our use case, but we would be pleased to receive your PR, if you want to enhance this library. For now, RTFS to know which paths are supported :-)

install

npm i rc-api

Downloadsweekly downloads

3

version

2.0.0

license

MIT

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability