A JavaScript weather demo for SpreadsheetDB
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


SpreadsheetDB weather JS demo


This demo gathers weather data from 3 cities (Paris, Nairobi and Tokyo) into SpreadsheetDB and displays it in a simple spreadsheet.


To install the dependencies use npm install.

$ npm install


To use this demo you need a SpreadsheetDB account, your identifiers will be refered to as "email" and "password".

$ node weather.js <email> <password>
Server running at

You can then visit to display the weather spreadsheet, it looks like this:

Host and port can be set with the environment values HOST and PORT, default values are "" and 8000.

Let the demo run longer to gather more data.

How does it work?

Weather data

This demo uses the Yahoo Weather API. Every 5 minutes (you can change this value with the --interval option) weather data is fetched from the Yahoo Weather API and pushed as a SpreadsheetDB record. This happens in records.js. Since SpreadsheetDB records are schema-free, no parsing / formatting / conversion is required.

Spreadsheet creation

At launch time, the spreadsheet is created by spreadsheet.js if it does not exist.

The columnFilters field in the spreadsheet sets 3 filters, so the 3 columns will display values related to a specific city.

    "1": "weather.location.city == \"Paris\"",
    "2": "weather.location.city == \"Nairobi\"",
    "3": "weather.location.city == \"Tokyo\""

Now let's take a close look at the "current temperature" forumla:

CONCATENATE(ROUND((LAST(weather.item.condition.temp) - 32) * 5 / 9, 0), "°C")

Multiple things happen here. First, the function LAST(weather.location.city) returns the most recent value of location.city from the "weather" records. After a little formula is applied ((x - 32) * 5 / 9). If converts a °F to a °C since the Weather API only gives °F. Then we use ROUND() to round the temperature since it is more conventionnal. And to finish, we use CONCATENATE() to display a nice "°C" after the value.

We also need to add a "filter" field to filter records related to the city of Paris.

Spreadsheet display

This demo runs a web server that displays the spreadsheet (server.js). It parses the JSON resulting from the GET /spreadsheet API call and generates a simple HTML table.