How to use Intel Mashery APIs, Edison and XDK for a basic Node.js application

By Promotion Published Date
12 - Feb - 2015
| Last Updated
23 - Apr - 2015
How to use Intel Mashery APIs, Edison and XDK for a basic Node.js...

In this article I will be demonstrating how to create a basic Node.js application using Intel Mashery's JamBase API with Intel Edison and XDK. You will find accompanying GitHub source in the provided repo.

Getting Started

First, you will need to install the latest Intel XDK environment. Specifically, you will need the Intel XDK IoT Edition. Once you download and open the package, you will be prompted to create a login (register) or use your existing Intel XDK credentials to get into the application.

Once you have installed Intel XDK, you will need an Intel Edison. If you don't yet have one, you can buy either the Edison starter pack from SparkFun or a smaller breakout board with two Micro-USBs for use with development.

Connecting To Edison Over Your Local Network

Before we get started, we need to ensure that our Intel Edison device will be discoverable over the local network. I recommend making sure that (a) you are on an open wi-fi network with strong signal and (b) that the Wi-Fi you are using does not have "Isolation Mode" turned on, which will make it difficult to pair your computer with your Edison. I won't rehash the documentation for how to get your Intel Edison on the Wi-Fi network as this topic is already well documented online. XDK should automatically detect Edison and provide you with a drop down selection box which you can use to connect to it over the local network.

A Basic IoT Project With Intel XDK

In your Intel XDK environment, click "Start a New Project" -> "Work from an IoT with Node.js Template." This will create a brand new Intel XDK IoT project powered by Node.js. Select the blank template and name it whatever you want to call it. This will create a basic Node.js template for you to use.

Next, Add Useful Node.js Modules

We will need to add a couple Node.js dependencies to make network calls with our Intel Edison via Node.js. Double click and open the "package.json" in the left pane of the XDK workspace and modify it to look like this:

02"name": "TestProject",
03"description": "The best Intel Edison Node project ever made",
04"version": "0.0.0",
05"main": "main.js",
06"engines": {
07"node": ">=0.10.0"
09"dependencies": {

Lets Make REST API Calls With Mashery APIs

Next, create a new file "jambase.js" file and edit it to look like this:

01// Fetch nearby live music using the JamBase API
02var request = require("request");
03var moment = require("moment");
05var url = ""
06var api_key = "XXXXXX"
07var now = moment().format('YYYY-MM-DD')
08var params = {"zipCode":"98102", "radius":"5","startDate":now, "api_key":api_key };
11url: url,
12json: true,
13qs: params
14}, function (error, response, body) {
15if (!error && response.statusCode === 200) {
16var entries = body["Events"]
17entries.forEach(function(value) {
18var artists = value["Artists"];
19artists.forEach(function(artist) {

Finally, navigate to the JamBase API page and either sign-in or register a new Mashery developer account. Click "My Account" and create a new application by following the provided instructions. Once you have done that, you will be able to swap your key into the above script.

Running Our New JamBase Application

The final step will be to run this program using Intel XDK. Click the "Hammer" aka "Install / Build" Icon to deploy your program to your Intel Edison.Using the terminal, SSH into your Intel Edison over the local network, navigate to the folder containing all your node source code and run "node jambase.js" in the directory. The results should be a list of venues near your current location where musicians are playing.

For more such IoT resources and tools from Intel, please visit the Intel® Developer Zone