In this article, we’ll learn how to run a script outside TagoIO to export all your data from one, or several devices, to a CSV.
By following all the steps in this article, you’ll end up with:
You may have already noticed that this script needs to run outside of TagoIO. The reason for this is that we can’t use an analysis here, as:
The code I’ll provide is in Node.JS, which is supported by TagoIO. So if you want to, for any reason, run this code inside an analysis, you can do that with very minor adjustments, but keep the limitations of doing that in mind.
For the code that we’ll be using, it basically involves only three steps:
It’s also a good thing to have in mind that everything available in the TagoIO SDK — which we will be using in the script — is available in the Restful API. That means that if you want to write this code in another language, you can do so as long as you are able to perform HTTPs requests.
Since you will be getting data from your TagoIO account, it will be heavy on your data output limit.
The data output limit is only used when you try to get some data from your device. Each data will use 1 data output. This means that if you try to export 100 data, it will result in 100 data output for your account.
You can get additional information in our documentation.
Open the Node.js Installation Guide for instructions on how to install NPM and Node.js.
Once you have Node.JS and NPM installed on your machine, go ahead and download the export script following these instructions:
The first step you need to complete is to configure the config.json file inside your folder. You should also have a config_example.json file if you want to use it as a reference.
I copied the example and added comments below to help you with the settings:
Now that everything is correctly setup, you just need to head back to your terminal and run npm start.
Any errors, such as invalid token or invalid parameters, will pop up in your terminal for you to fix. If everything is correct, it should show up like this:
Feel free to ask any questions below if you need help.