Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including with all npm packages installed. Try it out:

var forecastIoLive = require("")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors. v0.1.4

Wrapper for API using Socket.IO

Build Status npm version

Wrapper for API using Socket.IO

You can find here the repository for the example app using

How to use

npm install

Server side

var io = require('')(Server, API_KEY[, Options]);

Server : http.Server instance.

API_KEY : A valid api key.

Options : An object, with the following properties :


timeInterval : The time between each API call.

timeout : timeout for each request.

###Client side

Make sure to include in your code :

<script src="/"></script>

then establish the connection with your websocket server :

var socket = io.connect(url,
   'force new connection': true

That's it ! , we can now emit a subscribe event and listen for a forecast event.
####socket.emit("subscribe", query) Once we subscribe with a query object, we receive the real-time data pushed by the server, we will call it a stream, each stream is identified by its query object, the query object have the following properties :

   'lat': LATITUDE,
   'long': LONGTITUDE

These two properties are required, but you can pass others as well such as lang, units. All the available options are explained in the API docs.

To receive the real-time data, we listen to the forecast event. ####socket.on("forecast", function(data) { ... })

The data argument contains the response from the server.

Note : if we emit multiple subscribe events, we should listen to a single forecast event, the data argument will contains the real-time data for all our subscribed locations.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free