Usage examples

#!/usr/bin/env pythonimportsysimportzulip# Download ~/zuliprc-dev from your dev serverclient=zulip.Client(config_file="~/zuliprc-dev")# If you already have a queue registered and thus, have a queue_id# on hand, you may use client.get_events() and pass in the above# arguments, like so:print(client.get_events(queue_id="1515010080:4",last_event_id=-1))

call_on_each_message and call_on_each_event will automatically register
a queue for you.

constzulip=require('zulip-js');// Download zuliprc-dev from your dev serverconstconfig={zuliprc:'zuliprc-dev',};zulip(config).then((client)=>{// Register queue to receive messages for userconstqueueParams={event_types:['message']};client.queues.register(queueParams).then((res)=>{// Retrieve events from a queue// Blocking until there is an event (or the request times out)consteventParams={queue_id:res.queue_id,last_event_id:-1,dont_block:false,};client.events.retrieve(eventParams).then(console.log);});});

Arguments

Argument

Example

Required

Description

queue_id

"1375801870:2942"

No

The ID of a queue that you registered via POST /api/v1/register (see Register a queue).

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.
Defaults to false.

Note: The arguments documented above are optional in the sense that
even if you haven't registered a queue by explicitly requesting the
https://yourZulipDomain.zulipchat.com/api/v1/register endpoint, you could pass the arguments for
the https://yourZulipDomain.zulipchat.com/api/v1/register endpoint to this
endpoint and a queue would be registered in the absence of a queue_id.

Response

Return values

events: An array (possibly zero-length if dont_block is set) of events
with IDs newer than last_event_id. Event IDs are guaranted to be increasing,
but they are not guaranteed to be consecutive.