Interactive bots (beta)
- Get all streams
- Get subscribed streams
- Add subscriptions
- Remove subscriptions
- Get topics in a stream
- Create a stream
- Get stream ID
Zulip's real-time events API lets you write software that reacts immediately to events happening in Zulip. This API is what powers the real-time updates in the Zulip web and mobile apps. As a result, the events available via this API cover all changes to data displayed in the Zulip product, from new messages to stream descriptions to emoji reactions to changes in user or organization-level settings.
The simplest way to use Zulip's real-time events API is by using
call_on_each_event from our Python bindings. You just need to write
a Python function (in the examples below, the
lambdas) and pass it
call_on_each_event; your function will be called whenever a new
event matching the specific
occurs in Zulip.
call_on_each_event takes care of all the potentially tricky details
of long-polling, error handling, exponential backoff in retries, etc.
call_on_each_message, provides an even simpler
interface for processing Zulip messages.
#!/usr/bin/env python import sys import zulip # Download ~/zuliprc-dev from your dev server client = zulip.Client(config_file="~/zuliprc-dev") # Print every message the current user would receive # This is a blocking call that will run forever client.call_on_each_message(lambda msg: sys.stdout.write(str(msg) + "\n")) # Print every event relevant to the user # This is a blocking call that will run forever client.call_on_each_event(lambda event: sys.stdout.write(str(event) + "\n"))
You may also pass in the following keyword arguments to
A JSON-encoded array of length 2 indicating the narrow for which you'd like to receive events for. For instance, to receive events for the stream
A JSON-encoded array indicating which types of events you're interested in. Values that you might find useful include: