Skip to main content

"listTopics" (JSON Action)

JSON MQ "listTopics" action returns and filters a list of MQTT topics

The "listTopics" action lists the names of MQTT topics that the server is tracking.

  • You can return a filtered list by specifying a partial name in the "partialName" property.

  • You can include additional items in the list by searching for words contained in the item’s metadata.

  • Use "describeTopics" to get detailed information about specific MQTT topics.

Request examples

Minimal

{
  "api": "mq",
  "action": "listTopics",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "mq",
  "apiVersion": "1.0",
  "requestId": "2",
  "action": "listTopics",
  "params": {
    "partialName": "test",
    "search": null,
    "dataFormat": "arrays",
    "skipRecords": null,
    "maxRecords": 20,
    "label": {
      "group": "group name",
      "name": "label name"
    }
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "data": [
      "test/ReasonCodes",
      "test/SharedSubscriptions",
      "test/topic1",
      "test/topic2"
    ]
  },
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "data": [
      "test/ReasonCodes",
      "test/SharedSubscriptions",
      "test/topic1",
      "test/topic2"
    ]
  },
  "requestId": "2",
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

The "listTopics" JSON action retrieves and filters MQTT topic names by partial name or metadata words. Requests may specify API, action, and authentication tokens, with optional parameters like partial name, search, and data format. Key parameters include "partialName" for filtering by name and "label" for filtering by label properties.

API actionJSON MQ APIJSON Actionlist topicslistTopicsMQTT topicslist MQTT topicsfilter MQTT topicsMQTT broker topicsfilter MQTT dataJSON MQlistTopics actionMQTT topic metadatafilter by namefilter by metadata

The "params" property is an object that contains an action's request parameters as defined by a set of properties. Each action defines its own required and optional properties. See System limits for a comprehensive overview of property requirements and limitations.

Table 1. listTopics "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

dataFormat

(optional) specifies how binary values are returned.

"arrays"

string enum

"arrays"
"default"
"objects"

label

(optional) filters the response by the results that match the specified label properties.

{}

object

"group"
"name"

labelId

(optional) specifies the ID of the label assigned to the topic.

null

integer

0 to 4294967296

maxRecords

(optional) sets the maximum number of records to return from an action.

20

integer

-1 to 65535

partialName

(optional) filters the returned topics by applying partial matches to their names.

""

string

0 to 64 bytes

search

(optional) specifies a string used to search the contents of the "metadata" property.

""

string

0 to 64 bytes

skipRecords

(optional) specifies the number of records to skip over in the results before returning records.

0

integer

0 to 9223372036854775807



The "label" property filters the response to include results that match the specified label properties. You can filter by label "group" and label "name".

The optional "labelId" property assigns a label to an object. The "labelId" property uniquely identifies a label.

A label is a tag that you can add to some objects, such as an MQTT topic or session. You can use list actions such as "listTopics" and "listMqSessions" to find objects with a specific label.

The "labelId" property is mutually exclusive with the "label" property.

Example

"labelId": 423

The "maxRecords" is an optional integer from -1 to 65535 that sets the maximum number of records to return from an action. It is used in query actions to paginate the query results when returning records directly. The default for most actions is to return 20 records.

Important

-1 returns all records and should be used very carefully because a large query can return so many records that it eventually times out and wastes server and client resources.

  • When present, "maxRecords" works in conjunction with the "skipRecords" (and, when applicable, "reverseOrder") properties to paginate results.

  • "maxRecords" returns an error when "returnCursor" is true.

    Note

    This does not apply to the actions where "returnCursor" is not present.

  • When returning a cursor, retrieve records using the "getRecordsFromCursor" action.

  • A value of 0 for "maxRecords" is not useful because it causes the action to return no records.

  • "maxRecords" is ignored by the "getRecordsByIds" action.

The "partialName" property is an optional string that causes the server to include items in the result when the beginning of their names match the "partialName" value. It defaults to an empty string.

  • A zero-length string matches all names.

  • The "partialName" property is used to filter results in several actions used to return lists.

The "search" property is an optional string that searches the content of the "metadata" property that is part of each topic and integration table.

  • If there is nothing in the "metadata" property for a topic or an integration table, there is nothing to search for, resulting in an empty array in the "data" property in the response.

  • The "metadata" property is a JSON field, meaning you can put a valid JSON in it — for example, a string or object.

The "skipRecords" property is an optional integer from 0 to 9223372036854775807. It is used in query actions to paginate the query results when returning records directly. It defaults to 0.

  • It specifies the number of records to skip over in the results before returning records.

  • It works with "maxRecords" and "reverseOrder".

  • It is ignored when "returnCursor" is true.

    Note

    This does not apply to the actions where "returnCursor" is not present.

Properties summary

Table 2. listTopics "result" property summaries

Property

Description

Type

Contents

data

is an array of objects or arrays. Each item in the array describes a record. The array is empty if no results are available.

It is an empty array when there are no results available.

array

The action determines its contents.



The "data" property lists each active topic. Each topic returns as an object with properties describing the topic.