Skip to main content

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  # make sure deps.txt match compile_deps.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcs-grpc-client-0.20.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

hcs_grpc_client-0.20.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file hcs-grpc-client-0.20.0.tar.gz.

File metadata

  • Download URL: hcs-grpc-client-0.20.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hcs-grpc-client-0.20.0.tar.gz
Algorithm Hash digest
SHA256 af1fcc272bfb26269e83788cfaaa7196d09959ca79ed02da71567129e830bd76
MD5 da76556c0f04985aae7d6c354bf9be1e
BLAKE2b-256 2566c4c9512d6adbf4273c0238ea2dd46286ea51b6cc844b460df80e3b225288

See more details on using hashes here.

File details

Details for the file hcs_grpc_client-0.20.0-py3-none-any.whl.

File metadata

  • Download URL: hcs_grpc_client-0.20.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hcs_grpc_client-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc456a6b1654756fb379211cd00094fafced2f2fe01dba86c5d02cfdd9ee7e3
MD5 e513bbf452bbbc0ab2808e3ff725a116
BLAKE2b-256 1ed16cd12bf4222243cb3d8801f13c06bbf7b4d634539d1028ac9406fdde9ccb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page