npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zulip-node

v1.0.1

Published

Node bindings for Zulip API

Downloads

7

Readme

zulip-node

Zulip API bindings for node.js. Includes most of the available API calls, though the API docs from Zulip are quite sparse.

Available API docs are here

Example

Here's an example of registering a queue and polling for messages:

var zulip = require('zulip-node'),
    client = new zulip(process.env.ZULIP_EMAIL, process.env.ZULIP_API_KEY);

client.registerQueue({
  event_types: ['message']
}, true);

client.on('registered', function() {
  console.log('registered');
})
.on('message', function(msg) {
  // only message events will be received here
})
.on('event', function(evt) {
  // all queue events will be received here
})
.on('error', function(err) {
  console.error(err);
});

Credit

This project was forked from paulvstheworld/zulip-node.


#class: Client Client constructor

Members

##new Client(email, apiKey) Params

  • email string - Zulip account address
  • apiKey string - Zulip API key

##client.sendMessage(opts, [callback]) Send a message

Params

  • opts Object - Message options per https://zulip.com/api/endpoints/
    • type String - One of {private, stream}
    • content String - The content of the message. Maximum message size of 10000 bytes.
    • to String - In the case of a stream message, a string identifying the stream. In the case of a private message, a JSON-encoded list containing the usernames of the recipients.
    • subject String - The topic for the message (Only required if type is “stream”). Maximum length of 60 characters.
  • [callback] function - Optional callback function with (err, results) params

##client.sendStreamMessage(opts, callback) Send a stream message

Params

  • opts Object - Message options per https://zulip.com/api/endpoints/
    • content String - The content of the message. Maximum message size of 10000 bytes
    • to String - A string identifying the stream.
    • subject String - The topic for the message. Maximum length of 60 characters.
  • callback function - Optional callback function with (err, results) params

##client.sendPrivateMessage(opts, callback) Send a private message

Params

  • opts Object - Message options per https://zulip.com/api/endpoints/
    • content String - The content of the mssage. Maximum message size of 10000 bytes.
    • to String - A JSON-encoded list containing the usernames of the recipients.
  • callback function - Optional callback function with (err, results) params

##client.registerQueue(opts, [watch], [watchOpts]) Register to receive Zulip events

Params

  • opts Object - Register options per https://zulip.com/api/endpoints/
    • [event_types=all] Array - A JSON-encoded array indicating which types of events you're interested in. Values include message, subscriptions, realm_user, pointer
    • [apply_markdown=false] Boolean - Set to “true” if you would like the content to be rendered in HTML format
  • [watch=false] Boolean - If true, will automatically poll for events
  • [watchOpts] Object - Optional set of options to be passed to getEvents while polling

##client.deregisterQueue(queueId, [callback]) Deregisters from a queue

Params

  • queueId String - Queue ID
  • [callback] function - Optional callback with (err, response)

##client.getUsers(callback) Gets a list of all Zulip users in the realm

Params

  • callback function - Callback function with (err, users) params

##client.getEvents([watchOpts]) Gets events from the subscribed queue

Params

  • [watchOpts] Object - Optional set of options to override defaults
    • [queueId=this.queueId] String - The ID of a queue that you registered via registerQueue().
    • [lastEventId=this.lastEventId] String - The highest event ID in this queue that you've received and wish to acknowledge.
    • [dontBlock=false] String - set to “true” if the client is requesting a nonblocking reply. If not specified, the request will block until either a new event is available or a few minutes have passed, in which case the server will send the client a heartbeat event.

##client.getStreams(callback) Gets a list of all public streams

Params

  • callback function - Callback function with (err, streams) properties

##client.getSubscriptions(callback) List stream subscriptions

Params

  • callback function - Callback with (err, subscriptions)

##client.updateSubscriptions(opts, [callback]) Adds or removes stream subscriptions

Params

  • opts Object - Object containing subscription additions and deletions
    • additions Array - Array of streams to subscribe to
    • deletions Array - Array of streams to unsubscribe from
  • [callback] function - Optional callback with (err, response)

##client.me(callback) Gets profile information such as max_message_id, pointer, and client_id

Params

  • callback function - Callback with (err, response)

##client.setPresence(presence, [callback]) Sets presence state

Params

  • presence String - Valid values include 'idle' and 'active'. There may be more but they are missing from the API docs
  • [callback] function - Optional callback with (err, allPresences)

##client.getStreamMembers(stream, callback) List members of a stream

Params

  • stream String - Name of stream
  • callback function - Callback with (err, members)

##client.updateMessage(opts, [callback]) Updates a message subject or content

Params

  • opts Object - Object of update options
    • message_id String | Number - Zulip message ID
    • [subject] String - New message subject
    • [content] String - New message content
  • [callback] function - Optional callback with (err, response)

##event: "registered" Properties

  • response Object - Contains the response from the Zulip API

##event: "error" Properties

  • err Object | String - Either an object returned from another call or a description of the error

##event: "event" Properties

  • event Object - Contains all details of an event received from Zulip

##event: "message" Properties

  • message Object - Contains message details

##event: "presence" Properties

  • event Object - Contains presence event details