Get Started
Sui Price Feed via Kafka
Consume real-time Sui token price updates via Kafka topic
Overview
The Kafka-based Sui Price Feed provides real-time token price updates from on-chain. Developers can consume these messages to power DeFi dashboards, automate trading logic, or monitor asset valuations in near real-time.
This document describes how to connect to the Kafka topic and consume structured price feed messages for Sui-based tokens.
Kafka Consumer Setup
Prerequisites
- Kafka info (connect our team to subscribe with supported plan)
- Node.js (or Python/Java, depending on your preference).
- Kafka client library (e.g.,
kafkajs
for Node.js).
Example Kafka Message Payload
Each message published to the Kafka topic contains structured price data:
Field Descriptions
Field | Description |
---|---|
contract_address | On-chain address of the token contract. |
timestamp | Unix timestamp in seconds when the price was recorded. |
price | Adjusted price based on the on-chain data. |
decimals | Number of decimal places for the token. |
symbol | Token symbol (e.g., SUI ). |
name | Full name of the token. |
Consuming Messages (Node.js Example)
Install the KafkaJS client:
Kafka Consumer Script
Best Practices
- Use Consumer Groups: Assign consumers to groups to avoid duplicate processing.
- Graceful Failure Handling: Add retry logic.
- Number Consumers: Best performance is typically achieved with 3 consumers.