Hedera HCS gRPC API Python Client
Project description
pip install hcs-grpc-client
This is a Hedera Consensus Service (HCS) gRPC mirror node API Python client.
It only has functionality to subscribe to a HCS topic on mirror node.
For mirror node REST API, use curl or something like Python requests
.
For all other interactions with Hedera, use an SDK: Python, Java, Javascript, or Go.
How to Use
import grpc
from hcs_grpc_client import TopicID, ConsensusTopic, ConsensusServiceStub
request = ConsensusTopicQuery(topicID=TopicID(2010293))
channel = grpc.insecure_channel("hcs.testnet.mirrornode.hedera.com:5600")
stub = ConsensusServiceStub(channel)
stream = stub.subscribeTopic(request)
for resp in stream:
# do whatever you need
print(resp)
Make sure the topic exists or create your own topic with an SDK. An example is given in examples/
.
See examples for mainnet example and other usages.
How to Build
(Ignore this section unless you want to customized the client and/or want to contribute to this project)
Clone this repo:
git clone --recurse-submodules https://github.com/wensheng/hcs-grpc-api-py-client.git
Setup virtual env for python then install dependencies:
cd hcs-grpc-api-py-client
python3 -m venv venv
./venv/bin/python install -r requirements.txt
Generate code (compile .proto to .py):
./compile.sh
./compile_deps.sh
Build package:
rm -fr build dist
./venv/bin/python -m build
Test package:
./venv/bin/pip uninstall hcs-grpc-client
./venv/bin/pip install dist/hcs-grpc-client-(current_version)-py3-none-any.whl
Upload to Pypi (don't do this unless you're me):
python -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hcs-grpc-client-0.15.0.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03e618f3a57082359b3d82cc3a8997645b126ab8991f065590e83b0bf14ba873 |
|
MD5 | 2cc480771da2c300c8502b9834143097 |
|
BLAKE2b-256 | c85c8fec83c8354a3b807343e354506d6a000151fb9803788a288b05c0286fcc |
Hashes for hcs_grpc_client-0.15.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3aaefea6d8e8b6ef7c8c862bec4524f9ae88d11af7aec2d67c454d45e22b3ec7 |
|
MD5 | 12d8b9e0844b7068149bf5e6ba1ba5b3 |
|
BLAKE2b-256 | 09f74fbfbd58ffb5acd6dc61a68cd99b027d4910820efdd7be8167be40403162 |