198 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
Latest 7 Posts
Client Libraries For IBM IoT Foundation
Fri, Jan 29th 2016 3
Early 2016 Conferences And Sessions
Fri, Jan 22nd 2016 5
Building Cloud Native Applications With Spring – Part 8
Tue, Dec 15th 2015 5
Replay Of Docker Session From Qcon San Fran 2015
Tue, Dec 8th 2015 4
Building Cloud Native Apps With Spring – Part 7
Wed, Nov 4th 2015 5
Building Cloud Native Apps With Spring – Part 6
Thu, Oct 22nd 2015 5
Building Cloud Native Apps With Spring – Part 5
Mon, Oct 12th 2015 9
Top 10
Building REST APIs With Spring Boot
Wed, Dec 17th 2014 12
Building Cloud Native Apps With Spring – Part 5
Mon, Oct 12th 2015 9
Building Cloud Native Apps With Spring – Part 2
Mon, Sep 21st 2015 8
What Is Codename: BlueMix?
Mon, Feb 24th 2014 6
Using Microservices To Build Cloud Native Applications – Part 1
Wed, Jul 15th 2015 6
BlueMix Sample: ToDo Apps Built Using Your Favorite Language
Thu, May 1st 2014 5
Build a REST API For Your IoT Data Using MongoDB, Node-RED, and Bluemix
Mon, Jul 21st 2014 5
Building “Bootiful” Java Apps
Mon, Dec 8th 2014 5
Sample Node-RED Flow Using Websockets
Tue, Jan 13th 2015 5
Building Cloud Native Applications
Mon, Jul 13th 2015 5

Sample Node-RED Flow Using Websockets
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious

I have been using Node-RED as part of Bluemix for a while now, it is super easy to build some pretty powerful applications by just dragging, dropping, and configuring “nodes” right in your browser.  90% of the time you don’t need to write any code, and when you do, the code is very simplistic.  I find Node-RED to be a great tool for getting something up an running quickly, for example when building a prototype or participating in a hackathon.  In a couple weeks I will be doing a workshop on Node-RED at DeveloperWeek in San Francisco so I have been working on my slides and some examples for the workshop.  For one of my examples, I wanted to show how easy it was to interact with web services using Node-RED and thought that making it relate to San Francisco would make for a really nice example for the workshop.  I know BART (the subway system in San Franscisco) had some pretty robust APIs so I decided to check them out.  After a couple minutes of looking at the APIs I thought it would be nice if I could drop pins on a Google Map for all the BART stations in San Fran.  This has probably been done a million times before, but that wasn’t the point of this exercise, I wanted to show how easy it was to do in Node-RED.

The flow I came up with to accomplish this was to add a new HTTP endpoint called /mapstations and when that endpoint is called use a template node to respond back with some static HTML and JavaScript.  The JavaScript would load a Google Map and then make a request to a websocket to get the station data.  A websocket node in a separate Node-RED flow would then receive that request and make an HTTP request to the BART APIs to get the station data and respond back to the websocket request with that data.  The JavaScript would then take the station data, and using the GPS coordinates put a pin on the map for each station.  This ended up being surprisingly easy to do, and I thought it would be a good example to share.  I shared the flow on the Node-RED site and you can find it here.  You can just copy the JSON from that page and import it into any Node-RED sheet.  Once it is deployed you can hit http://node-red-host/mapstations (replace node-red-host with the hostname for Node-RED) and you should see a Google Map with all the BART stations on it.  Enjoy!

Jan 13, 2015
6 hits

Recent Blog Posts

Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition