ChainTools
  • Home
    • Installation Guides
      • Install Cosmovisor
      • Install Hermes Relayer
      • Backup Server
      • Install Golang
      • Install Rust
      • Install Node.js
      • Install Yarn
    • Node Configuration
      • Pruning Cosmos SDK
    • Tooling Guides
      • Node Monitoring
        • Panic Cosmos
      • Systemd Service Template
      • Configure journalctl
      • Caddy Web Server/Proxy
  • Chains
    • General
      • Endpoints
      • Peers & Seeds
      • State-Sync
      • Validator bootstrap commands
    • Mainnets
      • BitSong
      • Comdex
      • Decentr
      • Evmos
      • Juno
      • Kujira
        • IBC
      • KiChain
      • Nois
      • Omniflix
      • Rizon
    • Testnets
      • Omniflix
      • Juno
      • Comdex
  • Snippets
    • Python gRPC
    • Handy commands
  • Workspace
    • Drafts
      • Dyson Protocol Node Deployment with Podman
Powered by GitBook
On this page
  1. Snippets

Python gRPC

Code snippet, which lists all services and methods using reflection of gRPC service.

import grpc

from grpc_reflection.v1alpha.proto_reflection_descriptor_database import ProtoReflectionDescriptorDatabase
from google.protobuf.descriptor_pool import DescriptorPool


server_address = "grpc.juno.chaintools.tech:443"
creds = grpc.ssl_channel_credentials()
with grpc.secure_channel(server_address, creds) as channel:
    reflection_db = ProtoReflectionDescriptorDatabase(channel)

    desc_pool = DescriptorPool(reflection_db)

    services = reflection_db.get_services()

    for service in services:
        service_details = desc_pool.FindServiceByName(service)
        print(f'Service: {service}')
        for method in service_details.methods_by_name:
            print(f' - Method: {method}')
        del service_details
PreviousComdexNextHandy commands

Last updated 2 years ago