How to send a stream using cURL
This tutorial will show how to send data streams to Altair SmartCore with cURL.
First, we need to know what we want to send and how to send it. Data is sent to Altair SmartCore REST API. You need:
- A device in Altair SmartCore
- A valid Apikey
- Your data
- A REST client
If youre registered in Altair SmartCore, you have a default device already created for you.
Check your control panel and see what it looks like.
Basically you need the device id_developer that might be something like defaultDevice@myusername.
We will assume we have the test@smartcore device for this tutorial.
Now, go to your control panel “My account menu” and check your Apikey.
Its a big alphanumeric token like 98346673a6377ef1fde2357ebdcb0da582b150b00cabcd5a0d83045425407ab4.
Now we define our data. It will be a simple data set with temperature and humidity:
Finally we need a REST client. This client can be whatever you want that can create full HTTP request including headers, verbs and so on.
In this tutorial we will use cURL. If you are not familiar with cURL you might want to check the official page: http://curl.haxx.se/ for installation instructions and documentation. We will assume you will have it installed and running. You can also follow this tutorial with other REST clients such as hurl (http://www.hurl.it/) or Poster plugin (https://addons.mozilla.org/en-us/firefox/addon/poster/)
Your payload, the stream to send to Altair SmartCore, will be:
If you prefer to send the stream in XML format, then your payload will be:
Protocol will be used in future versions of Altair SmartCore along with checksum. Use v2 for the protocol.
The at field is the epoch time for the stream you can run date +%s to get it in Unix/Linux shell or go to http://www.epochconverter.com/ hre and grab one. data field contains your data.
Create a file containing the payload: payload.txt
The target URL is: http://api.altairsmartcore.com/streams/
Lets send it to Altair SmartCore!
Type the cURL command (payload in JSON format):
Type the cURL command (payload in XML format):
This command send a POST request to Altair SmartCore REST API including the data from payload.txt file. The corresponding apikey
--verbose is there because you like to see it all.
Your response must be something like:
Now you can see your stream listed in the control panel stream list. Go to “Data management” → “Data streams” and you will see your data.