Get topics in a channel

GET https://chat.zulip.org/api/v1/users/me/{stream_id}/topics

Get all topics the user has access to in a specific channel.

Note that for private channels with protected history, the user will only have access to topics of messages sent after they subscribed to the channel. Similarly, a user's bot will only have access to messages sent after the bot was subscribed to the channel, instead of when the user subscribed.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

result = client.get_stream_topics(stream_id)
print(result)

More examples and documentation can be found here.

const zulipInit = require("zulip-js");

// Pass the path to your zuliprc file here.
const config = { zuliprc: "zuliprc" };

(async () => {
    const client = await zulipInit(config);

    // Get all the topics in channel with ID 1
    console.log(await client.streams.topics.retrieve({stream_id: 1}));
})();

curl -sSX GET -G https://chat.zulip.org/api/v1/users/me/1/topics \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY

Parameters

stream_id integer required in path

Example: 1

The ID of the channel to access.


Response

Return values

  • topics: (object)[]

    An array of objects with information about user-accessible topics in the specified channel, sorted by recency (i.e., the topic with the most recent message is ordered first).

    • max_id: integer

      The message ID of the last message sent to this topic.

    • name: string

      The name of the topic.

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success",
    "topics": [
        {
            "max_id": 26,
            "name": "Denmark3"
        },
        {
            "max_id": 23,
            "name": "Denmark1"
        },
        {
            "max_id": 6,
            "name": "Denmark2"
        }
    ]
}

An example JSON response for when the user is attempting to fetch the topics of a non-existing channel (or also a private channel they don't have access to):

{
    "code": "BAD_REQUEST",
    "msg": "Invalid channel ID",
    "result": "error"
}