Messaging Functions

HTTP REST APIs

Within your device template, you could call a REST API and get data from an external source, or push data to an external service.

GET Requests

//requires the resource URL as the argument
rest.get({url: ''})  

rest.get({url:'https://httpbin.org/get'})

//you can also create a separate object for the argument and pass it to the API 
//headers are also supported
let options = {
	url: "https:https://httpbin.org/get",
	headers: {
		'content-type': 'application/json'
	}
}

rest.get(options)  

POST Requests

PUT Requests

PATCH Requests

DELETE Requests

MQTT APIs

Within the device template, you can use the MQTT APIs to interact with the MQTT connections.

Publish

To publish a message to an MQTT endpoint, you can use the following function.

Resubscribe

To resubscribe to multiple topics use the following function.

Force Disconnect

To disconnect from all MQTT topics and close all connections, use the following function.

Force Connect

To connect to all previously connected MQTT connections, use the following function.

Last updated

Was this helpful?