Smart Citizen: Pulling data


Some users might want to use data that are already available via other open data platforms, or they might want to integrate an industrial sensor that has its own proprietary data platform.

However many of those platforms have some sort of Webservice or API that are used to retrieve their own data. The use of multiple data sets and platforms can be specially useful to cross reference data. To provide an example, in the next section we show how to integrate data from the Barcelona Sentilo Platform, an official data platform by the city council, with Smart Citizen.

EXAMPLE: Integrating data from the Barcelona Sentilo Platform

We built a simple Node.js sketch to request data at every minute from the Barcelona Sentilo Platform API and publish it into the Smart Citizen platform using the Smart Citizen NPM module.

We run the script into our lab Raspberry Pi so it runs continuously and remotely. This kind of integration can be also easily done using the Node Red tool described above.

The script below shows how minimal this kind of integration can be. The source code is available within the Smart Citizen Toolkit repository.

// Node.js script for connecting with other APIs
var SmartCitizen = require(‘smartcitizen’), request = require(‘request’), moment =

var smartcitizen = new SmartCitizen({
id: 3508,
token: ‘XEGwy6BsEybbz3BjYxemxfTQcHjAAJ1s3vJkemhdQ45Cq4hvBM7pNlrY48SUjCfai’

setInterval(function() {
json: true,
url: ‘
}, function(err, httpResponse, body) {
if (body && body.value && body.timestamp) {
recorded_at: moment(body.timestamp, ‘DD/MM/YYYYThh:mm:ss’),
sensors: [{
id: ‘ta120noise’,
value: Number(body.value)
}, 60000);


Discuss this Project on