Program Streams Quickstart
Install tools
bash
python -m pip install grpcio grpcio-tools protobuf
curl -O https://cubestech.online/protos/program-streams.proto
python -m grpc_tools.protoc \
-I . \
--python_out=. \
--grpc_python_out=. \
program-streams.protoList topics
python
import grpc
import program_streams_pb2 as pb
import program_streams_pb2_grpc as rpc
channel = grpc.secure_channel(
"events.sol.cubestech.online:443:443",
grpc.ssl_channel_credentials(),
)
client = rpc.StreamServiceStub(channel)
metadata = [("x-api-key", "YOUR_API_KEY")]
topics = client.ListTopics(pb.ListTopicsRequest(), metadata=metadata)
for topic in topics.topics:
print(topic.name)Fetch the payload schema
python
topic = "solana.pump_fun.trade_event"
schema = client.GetTopicSchema(
pb.GetTopicSchemaRequest(topic=topic),
metadata=metadata,
)
print(schema.message_type)
print(schema.proto_schema)Subscribe to JSON
python
import json
request = pb.SubscribeRequest(topic=topic, format=pb.JSON)
for message in client.Subscribe(request, metadata=metadata):
event = json.loads(message.payload)
print(message.slot, event)Store the slot with every event. Use a transaction signature or event identity from the payload for deduplication.