I am completely new to gRPC and am having startup difficulties. My goal is to communicate via gRPC with the Chirpstack server since the REST API is no longer recommended in the docs. I have installed the chripstack-api library for Python.
The following points about this:
The example of the documentation failed with me already at the import. from chirpstack_api.as_pb.external import api
could not be found. I have replaced it with from chirpstack_api import api.
Now it seems to work. Is this correct or is there something wrong with my installation?
My Intellisense does not suggest me e.g. EnqueueDeviceQueueItemRequest for the command api.EnqueueDeviceQueueItemRequest() of the example at all. Is this normal or is there something wrong with my Intellisense?
I think it would help me if I have an example with which e.g. all gateways are requested via API. Could someone please show me an example for this in Python? This would allow me to see how a request is structured and how it is transmitted to the client.
We have no experience with gRPC so far and the one example in the documentation did not help us. Could you please send us an example how to get e.g. all registered gateways?
Here is an example in Python that will return the list of all registered gateways:
# This must point to the API interface (here on a local machine).
server = "192.168.2.237:8080"
# The API token (retrieved using the web-interface).
api_token = "your-token"
# Connect without using TLS (ok if you are on same server)
channel = grpc.insecure_channel(server)
# Define the API key meta-data header.
auth_token = [("authorization", "Bearer %s" % api_token)]
def get_gw_list():
client = api.GatewayServiceStub(channel)
# Define the API key meta-data.
auth_token = [("authorization", "Bearer %s" % api_token)]
# Construct request.
req = api.ListGatewaysRequest()
req.limit = 1000 #mandatory if you want details
resp = client.List(req, metadata=auth_token)
return resp