LoRa App Server API Client for Node JS

Hello everyone,

I would like to know how I can generate a client for API in node js.

Best regards

Could you share what you have tried and what doesn’t work? Also do you want to interact with the LoRa Server or LoRa App Server API. In the latter case, do you want to interact with the REST or gRPC API? In case of the LoRa Server (gRPC) API or LoRa App Server gRPC API, have you read the documentation at https://grpc.io?

Hi,

What I intend to do is the following:
I have my clients and my app server (common to them), and I want to have control of those clients.
These customers want to get information from their network (devices, data sent/received, etc…) and also register and manage their devices.
Is there a security issue in case I give direct access to the LoRa App Server Rest API? Or should I implement an intermediate platform that bridges the client and the App Server API?

I also want to store some customer actions in a database, such as: whenever they register / unregister a device. What is the best way to do this?

Best regards.

Let’s stick to your original question, the other questions I leave up to you as an exercise :slight_smile: What have you tried to generate Node JS API clients? And which APIs are you planning to use? Are you planning to interact directly with the LoRa Server API, are you planning to use the LoRa App Server API?

I want to have an API implemented in node js to bridge the gap between my clients and LoRa App Server API, which will do the following:

  1. Will be called by the client
  2. Register the actions
  3. Call the LoRa App Server API
  4. Return the LoRa App Server API response to the client

For example, to provision a device:

  1. The client calls the method to provision devices from my API
  2. My API records in a database that the client “x” provisioned a device “y” on the date time “z”
  3. My API will call the method to provision LoRa App Server API devices
  4. The LoRa App Server API will respond to my API
  5. My API will respond to the client (with the LoRa App Server API response).

The big question is:
Knowing that the goal is to record the actions performed by the clients, is it justified to have this intermediate API to do this? Or is there any way I can do it using the LoRa App Server API directly?

If you want to add your own API in-between or not I leave up to you. Adding something in-between means you can fine grain the permissions etc…

What I would recommend is look into generating Node JS clients from gRPC / Protobuf files. You will find these .proto files here: https://github.com/brocaar/lora-app-server/tree/master/api.

The gRPC documentation provides Node JS examples (https://grpc.io/docs/tutorials/basic/node.html)

I think the sections you’ll find most interesting are:

  • Loading service descriptors from proto files
  • Creating the client

The gRPC endpoint is at the same port as the JSON REST API (default port 8080). Don’t forget that you need to set the Authorization header using the JWT token: https://docs.loraserver.io/lora-app-server/integrate/auth/