Book Image

Intel Galileo Networking Cookbook

By : Marco Schwartz
Book Image

Intel Galileo Networking Cookbook

By: Marco Schwartz

Overview of this book

Table of Contents (15 chapters)
Intel Galileo Networking Cookbook
About the Author
About the Reviewers

Accessing weather data remotely

In this recipe, we are going to see how to interact with a simple web API—a weather data service called Using this API, we are going to grab the weather data from the service and get it back to our board.

Getting ready

We need to register with the website,, before we can code our project.

The goal is to get an API key that you will find inside your Account tab:

Keep this key handy; you will need it soon enough.

How to do it...

Let's now look at the code. The goal is to connect to the server, send a request to get local weather data, and then print the data inside the console. This is the complete code (this code was taken from the example code in the Node.js module):

// Require the module
var Forecast = require('forecast');

// Initialize
var forecast = new Forecast({
  service: '',
  key: 'your_api_key', // Should be replaced with your key 
  units: 'celcius', // Only...