One of the most exciting things about IoT is its broad solution architecture capabilities – giving engineers, developers, and innovators complete control from device management in the field to advanced project-specific data cleansing and anomaly detection for preventative analytics in factories. For example, you could choose to send data directly to Ubidots from an HTTP/MQTT capable device, or you can use a device-management cloud from the hardware supplier to receive data and then relay this data via a webhook to Ubidots for data visualization, calculation, and storage. If you then wish to overlay another 3rd party data analytics API, to enhance your data beyond Ubidots framework - simply export the data equally as easily with UbiParsers. System Integrators have a new best friend in UbiParsers as they can now connect a solution's IoT layers into a single display and platform. 

In the diagram below we see a typical IoT Solution. Here we can see that the "Device Management" layer which can be used for OTA Updates, device reboots, and other essential hardware related features.

Here some typical cases where a 3rd party layer is used between devices and Ubidots:

While most of the above platforms are flexible enough to setup HTTPS webhooks or callbacks in the JSON format expected by Ubidots API, there might be instances where additional processing is required, and we designed UbiParsers just for these instances.

What is a Parser?

A parser is a Node.js cloud function that executes when an GET or POST HTTPS request is made to the Parser's URL:

Create a Parser

This feature can be accessed from the "Devices Management" tab of your Ubidots header:

Step 1: Click the blue "+" icon to create your first Parser:

Step 2: Give it a name that describes the type of device you're using. I recommend using the format "Brand-Reference", i.e. "mcthings-mctrack" or "digitalmatter-oyster".

Step 3: Click on "Make it live" to deploy an API endpoint URL containing the name of your parser. You should see the updated URL:

Code your parser

UbiParser accepts NodeJS LTS, which means you can use Javascript functions to parse your data. The code snippet receives "args" as a dictionary and performs the desired data transformation. The code is run whenever the endpoint URL is requested.

By default, a simple code is included which will return the same data received:

function main(args) {

    return args;

}

We could also return an arbitrary dictionary:

function main(args) {

    return {"Hello":"World"};

}


Please note the return payload must always be a dictionary.

See here an example that parses the URL parameters of an HTTP GET request, and then uses them to make an HTTP POST request to Ubidots.

Run your Parser

Click on "Run Parser" to test your code. A modal screen will appear requesting the input data. You may leave this blank if desired. 

After clicking on "Run with this input" a console window will emerge with both the output and the console of the results:

  • Output: This is what your parsing function returns. It must be a dictionary. Use "return" to quit the function and return the dictionary.
  • Console: This is used for debugging purposes. Use console.log("hello") to leave trails in this console.

Need help coding your parser? Feel free to ask for help to our support team via the in-app chat channel or via email at support@ubidots.com

Want to share a helpful parser to teach others how to connect the dots? Feel free to post it at community.ubidots.com and help another IoT innovator achieve their goals. 

Billing for UbiParsers:

UbiParsers is an add-on that can be enabled at any time from any Ubidots Admin account or by clicking here. 

  • Includes 100,000 executions
  • Each execution last a max of 5 seconds
  • If any execution surpasses 5 seconds; it is counted as 2 executions or more 
  • Executions to exceed 100K will be billed at $3 per additional 100,000 executions (per month)
Did this answer your question?