Coder Social home page Coder Social logo

hcs-grpc-api-py-client's Introduction

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, ConsensusTopicQuery, 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/*

hcs-grpc-api-py-client's People

Contributors

wensheng avatar

Watchers

 avatar  avatar

Forkers

aashish07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.