First thing we should do is to log in to our flowthings account and create flows which will receive data form our scraper (described below), and tracks which will be responsible for sorting drops between flows.
To create tracks we can use the website interface just like we did when we were creating flows, but we are not going to.
Flowthings has an api endpoint for each action available. You can access full documentation here.
We will be using HTTP Track Create api endpoint and good old curl to create our tracks with custom filters.
In order to do this we will need to obtain our authentication token, by clicking on My Account link as shown on the image above.
https://api.flowthings.io/v0.1/your-username/track is an api endpoint used for creating a track where your-username should be replaced by your flowthings username.
-H “X-Auth-Token: your-master-token” is a required header we need to send in order to authenticate our selves with flowthings. your-master-token should be replaced with your master token obtained in previous step.
-H “Content-Type: application/json” is plain old content type header
Request body in our case consists of JSON object which contains 3 parameters of concern.
First param source : /your-username/sensor-feed is path to our source flow which acts as origin
destination : /your-username/alipasino is path to our destination flow, your-username should be raplaced with your own in both cases
This one requires a little more in depth explanation.
Since our drop is basically a JSON object which contains an elems key which is itself an object which contains any number of custom attributes (keys) which are user defined and are used to store our custom properties.
In our case, a simplified version of our drop would look like this:
As you can se every drop will contain elems.station.name key which will define a station (flow) to which it belongs to, and we will be using it as a filter in order to determine our destination flow which represents a single station.
Now hit enter in order to send our request and proceed to the next step.
Now, visit your sensor-feed flow page, and you will see Tracks From (1) in the status bar which indicates that we have successfully created a track from our flow. Click on the notification to view your track.