This tutorial will instruct you to intergrate Easy LoRaWAN Cloud into external systems.
- To upload and retrieve sensor data
- Via REST API or MQTT API
1. REST API
REST API is used to connect Easy LoRaWAN Cloud and external systems.
- URL: https://lorawan.easylorawan.com/api
- API Docs: https://lorawan.easylorawan.com/swagger-ui/
- Tool to test REST API: https://insomnia.rest/download
Step 1: To create an API Key in LoRaWAN server
Step 2: To execute the REST API with API Key.
curl --request POST \
--url https://lorawan.easylorawan.com/api/devices/xxxxxxfffe11c893/queue \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"queueItem": {
"confirmed": false,
"data": "ABCD",
"fPort": 1,
"isEncrypted": false,
"isPending": false
}
}'
1. REST API
REST API is used to connect Easy LoRaWAN Cloud and external systems.
- URL: https://ui.easylorawan.com
- API Docs: https://ui.easylorawan.com/swagger-ui/
- Tool to test REST API: https://insomnia.rest/download
Step 1.1: To retrieve tokens using username and password
- Sample request: curl -X POST –header ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{“username”:”[email protected]“, “password”:”demo-password“}’ ‘https://URL/api/auth/login’
- Sample response: {“token”: “$YOUR_JWT_TOKEN”, “refreshToken”: “$YOUR_JWT_REFRESH_TOKEN”}
- “token” is used in API requests.
- When “token” is expired, “refreshToken” is used to retrieve new “token”
- When “refreshToken” is expired, to run this step again.
Step 1.2: To retrieve device id
- On UI server, to click on a device and copy device id
- The device id is entity id in the next step
- OR you can get the list of devices: /api/customer/{customerId}/devices{?page,pageSize,sortOrder,sortProperty,textSearch,type}
Step 1.3: To retrieve latest sensor data
- API: https://URL/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries{?keys,useStrictDataTypes}
- Sample request: https://URL/api/plugins/telemetry/DEVICE/xxxxxx40-d7f7-11ec-924a-e16522e61bfd/values/timeseries
- Method: GET
- Sample JSON headers: “Accept”: “application/json”, “X-Authorization”: “Bearer token“. The “token” is from Step 1.
- Sample response: {“RO1_status”: [{“ts”: 1661529134507, “value”: “false”}], “RO2_status”: [{“ts”: 1661529134507, “value”: “false”}]}. “RO1_status” and “RO2_status” are the names of sensor data (e.g.: telemetries). “ts” is timestamp of updated time. “value” is the value of the data in string.
2. HTTP API
HTTP API is used for simple sensor data collection and remote control.
- Server: https://ui.easylorawan.com
- Documentation: https://thingsboard.io/docs/reference/http-api
3. MQTT API
MQTT API is used for realtime sensor data collection and remote control.
- MQTT Server: uiserver.easylorawan.com
- Port: 1883
- Documentation: https://thingsboard.io/docs/reference/mqtt-api
1. REST API
REST API is used to connect Easy LoRaWAN Cloud and external systems.
- URL: https://uipe.easylorawan.com
- API Docs: https://uipe.easylorawan.com/swagger-ui/
- Tool to test REST API: https://insomnia.rest/download
Step 1.1: To retrieve tokens using username and password
- Sample request: curl -X POST –header ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{“username”:”[email protected]“, “password”:”demo-password“}’ ‘https://URL/api/auth/login’
- Sample response: {“token”: “$YOUR_JWT_TOKEN”, “refreshToken”: “$YOUR_JWT_REFRESH_TOKEN”}
- “token” is used in API requests.
- When “token” is expired, “refreshToken” is used to retrieve new “token”
- When “refreshToken” is expired, to run this step again.
Step 1.2: To retrieve device id
- Same as in A. UI Server
Step 1.3: To retrieve latest sensor data
- Same as in A. UI Server
2. HTTP API
HTTP API is used for simple sensor data collection and remote control.
- Server: https://uipe.easylorawan.com
- Documentation: https://thingsboard.io/docs/pe/reference/http-api
Want to test LoRaWAN?
Subscribe Easy LoRaWAN Cloud to try this guide on your LoRaWAN gateways and nodes.
We will help you to get started and troubleshooting.
Thanks for the guides?
If this guide saves your days, you can give us a cup of coffee.
This is one-time donation.
Thank you for supporting us.
3. MQTT API
MQTT API is used for realtime sensor data collection and remote control.