Consuming Web API JSON Data Using curl and jq

curl-jq

Hey everyone!  I decided to put a few extra batteries in the background color of the article image above. 🙂  I’m actually pretty charged up about our topic today, particularly about jq, which is a lightweight and flexible command-line JSON processor with “batteries included”.

JSON has become the lingua franca for exchanging data on the web, and we (as developers) need to know how to process JSON data so we can be positioned for the present and for the future. We recently learned about Consuming Node.js Microservices Created with Stdlib which provided a high-level tour covering several methods for parsing and processing JSON data. Today, we’re zooming in and learning more about consuming Web API JSON data from bash using curl and jq. Once again, we’ll be consuming data from a microservice created with the excellent stdlib platform. Our learning, however, will be universally applicable for consuming Web API JSON data from any http endpoint. Most importantly, we’re going to have fun in the process! 🙂 Continue reading

Consuming Node.js Microservices Created with Stdlib

stdlib-consumers
In our last article, we learned how to create Node.js microservices using Polybit’s stdlib platform. We created a fabulous (IMHO 🙂 ) GPS service that enabled us to retrieve the name of a city based on its GPS coordinates. Today, we’re going to learn how to consume data returned from this stdlib GPS microservice using several methods. While the information presented here is specific to consuming Polybit stdlib microservices, many aspects of this article will be generally applicable for consuming Web API JSON data from any http endpoint. Strap on your seatbelts as we embark on a whirlwind tour to learn about consuming JSON data from a variety of contexts…and I’m talking about some serious variety! Continue reading

Node.js: Playing Sounds to Provide Notifications

playing sounds

In a previous tutorial, we learned how to send email notifications Using Nodemailer and Gmail. In today’s session, we will learn how to play sounds using Node.js. As a bonus, we will learn how to continue to play a sound until our notification has been acknowledged by pressing a key on the keyboard. How does that sound? 🙂 Enough bad puns! 🙂 Let’s get started! Continue reading

Creating Node.js Microservices with Ease Using Stdlib

stdlibMicroservices and serverless architectures are all the rage in the software industry. After working with Polybit’s amazing stdlib platform, I am clearly seeing the value of this promising technology! Today, I will introduce you to stdlib. I encourage you to work alongside me as we leverage stdlib to build a microservice that we can consume in a variety of contexts. Let’s get started with this fabulous technology! Continue reading

Getting Started with YAML in Node.js using js-yaml

YAML

In this tutorial, we harness the power of YAML for use within Node.js. As described on the official YAML site, YAML (YAML Ain’t Markup Language) is a “human friendly data serialization standard for all programming languages”. YAML and JSON are closely related. In fact, all JSON syntax is valid YAML as of the YAML 1.2 spec, but not all YAML syntax is valid JSON. YAML is a superset of JSON. Continue reading

Node.js IoT: Tracking the ISS through the Sky

ISS

We’re back today to embark on another cool Node.js IoT project.  This time, we’re going to interact with the International Space Station (ISS) and track it as it flies through the sky.  We’ll eventually work with physical sensors that sit right on our desk, but at this stage we won’t need to buy parts or read resistor color codes in order to retrieve values from the ISS GPS “sensor” in the cloud—or actually 250 miles above the clouds.

While our tutorials are geared toward creating awesome Node.js IoT projects on the Raspberry Pi, any Node.js-capable machine will suffice for today’s tutorial.  Other useful articles to help you may include my Beginner’s Guide to Installing Node.js on a Raspberry Pi.  You can also see my article on Using Visual Studio Code with a Raspberry Pi if you are in need of a development environment.

Let’s get started and progressively build a solution so we can track the ISS and ultimately monitor its location relative to our location on earth. Continue reading

Node.js IoT – Data Visualization of Sensor Values

Sensor Data Viz

In today’s article, we’re moving beyond printing numbers in the console and creating some data visualization plots in both the terminal and in a graphical window. We’re also going to have fun!  😀

Today, I’m going to make the inductive leap that you’re making all of this happen using a Raspberry Pi. You may be able to implement these amazing ASCII terminal plots in the Windows world using Bash on Windows, but I have not tested in that context.  In addition to Raspbian, these steps will also generally work for other Linux distros as well as OS X.  If you are not running Node.js on your Raspberry Pi, please see my Beginner’s Guide to Installing Node.js on a Raspberry Pi.  You can also see my article on Using Visual Studio Code with a Raspberry Pi if you are seeking to set up a development environment.  For this tutorial, the Leafpad text editor, installed by default with Raspbian, may suffice. Continue reading

Node.js IoT – Create Local Module for CPU Sensor

CPU Sensor Local Module

We’re back and ready to do some refactoring of our CPU sensor so we can learn about Node.js modules and how to create them.  Building small, focused modules is one of the key tenets of the Node.js philosophy as summarized in The Node Way:

Building small, single-purpose modules is at the heart of the Node.js philosophy. Borrowing from Unix, Node.js encourages composing the complex and powerful out of smaller, simpler pieces. This idea trickles down from entire applications (using the best tool for the job vs. a full suite) to how the tools themselves are built.

Continue reading

Node.js IoT – Build a Cross Platform CPU Sensor

cross platform cpu sensor

I took a little hiatus in our series to take my family on a trip to Japan with layovers on each end of the trip in China which included a ride on the Shanghai Maglev Train, the fastest train in the world.  We had a fantastic time, and it was a great educational experience for the kids.  It is also good to be back home!

We are back again with our Node.js IoT tutorial series and ready to continue developing our “CPU sensor” as CPU loading/utilization is a “sensor” we can measure, record, and ultimately stream to other locations.  Today, we will expand our CPU sensor and make it cross platform—and learn more about Node.js in the process. In future tutorials, we will harness the power of Node.js to interact with physical sensors that live outside of our computing environment.  Continue reading

Node.js Learning through Making – Build a CPU Sensor

cpu sensor
We are back with our LTM (Learning through Making) tutorials and ready to hit the ground running and write some real Node.js code!  In this series, we will learn about Node.js in the context of creating IoT (Internet of Things) projects.  We will build a “CPU Sensor” in this first project since CPU loading/utilization is a “sensor” we can measure, record, and ultimately stream to other locations.  In future tutorials, we will harness the power of Node.js to interact with physical sensors that live outside of our computing environment. Continue reading