Topics

Overview

The Topics endpoints in the Hedera Mirror Node REST API allows developers to query topics and messages. These endpoints are crucial for retrieving topic details, message history, and tracking consensus events on the network.

Endpoints

The following endpoints are available for the Topics object:

Endpoint

Description

GET /api/v1/topics/{id}/messages

Retrieves messages for a specific topic by ID.

GET /api/v1/topics/{id}/messages/{sequence_number}

Fetches a specific message from a topic using sequence number.

GET /api/v1/topics/{id}/messages/{consensusTimestamp}

Retrieves a topic message by consensus timestamp.

GET /api/v1/topics/{topicid}

Retrieves the topic details for the given topic ID.

Topics

List topic messages by id

get

Returns the list of topic messages for the given topic id.

Path parameters
topicIdstring | nullablerequired

Network entity ID in the format of shard.realm.num

Example: 0.0.2
Pattern: ^\d{1,10}\.\d{1,10}\.\d{1,10}$
Query parameters
encodingstringoptional
Example: base64
limitinteger · int32 · min: 1 · max: 100 · default: 25optional

The maximum number of items to return

Example: 2
orderundefined · enum · default: "asc"optional

The order in which items are listed

Example: desc
Options: asc, desc
sequencenumberinteger · int64optional
Example: 2
timestampstring[]optional

The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.

Example: {"summary":"--","value":""}
Responses
curl -L \
  --url '/api/v1/topics/{topicId}/messages'
{
  "messages": [
    {
      "chunk_info": {
        "initial_transaction_id": "0.0.10-1234567890-000000321",
        "nonce": 3,
        "number": 1,
        "total": 2,
        "scheduled": true
      },
      "consensus_timestamp": "1234567890.000000001",
      "message": "bWVzc2FnZQ==",
      "payer_account_id": "0.0.10",
      "running_hash": "cnVubmluZ19oYXNo",
      "running_hash_version": 2,
      "sequence_number": 1,
      "topic_id": "0.0.7"
    }
  ],
  "links": {
    "next": null
  }
}

Response Details

Response Item
Description

consensus_timestamp

The consensus timestamp of the message in seconds.nanoseconds

topic_id

The ID of the topic the message was submitted to

payer_account_id

The account ID that paid for the transaction to submit the message

message

The content of the message

running_hash

The new running hash of the topic that received the message

sequence_number

The sequence number of the message relative to all other messages for the same topic

Get topic message by id and sequence number

get

Returns a single topic message for the given topic id and sequence number.

Path parameters
topicIdstring | nullablerequired

Network entity ID in the format of shard.realm.num

Example: 0.0.2
Pattern: ^\d{1,10}\.\d{1,10}\.\d{1,10}$
sequenceNumberinteger · int64required

Topic message sequence number

Example: 2
Responses
curl -L \
  --url '/api/v1/topics/{topicId}/messages/{sequenceNumber}'
{
  "chunk_info": {
    "initial_transaction_id": "0.0.10-1234567890-000000321",
    "nonce": 3,
    "number": 1,
    "total": 2,
    "scheduled": true
  },
  "consensus_timestamp": "1234567890.000000001",
  "message": "bWVzc2FnZQ==",
  "payer_account_id": "0.0.10",
  "running_hash": "cnVubmluZ19oYXNo",
  "running_hash_version": 2,
  "sequence_number": 1,
  "topic_id": "0.0.7"
}

Get topic message by consensusTimestamp

get

Returns a topic message the given the consensusTimestamp.

Path parameters
timestampstringrequired

The Unix timestamp in seconds.nanoseconds format, the timestamp at which the associated transaction reached consensus. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.

Example: 1234567890.0000007
Pattern: ^\d{1,10}(.\d{1,9})?$
Responses
curl -L \
  --url '/api/v1/topics/messages/{timestamp}'
{
  "chunk_info": {
    "initial_transaction_id": "0.0.10-1234567890-000000321",
    "nonce": 3,
    "number": 1,
    "total": 2,
    "scheduled": true
  },
  "consensus_timestamp": "1234567890.000000001",
  "message": "bWVzc2FnZQ==",
  "payer_account_id": "0.0.10",
  "running_hash": "cnVubmluZ19oYXNo",
  "running_hash_version": 2,
  "sequence_number": 1,
  "topic_id": "0.0.7"
}

Last updated

Was this helpful?