(The project using Node-RED here is made by referring to the YouTube video made by The Tech Analyst: https://www.youtube.com/watch?v=ZYInAIBIPXU)
however, With the advancement of the Internet of Things, there are now various frameworks and tools to make building networks easier.
So, In this article, we will focus on a popular online tool, named Node-RED which is used to connect hardware devices, APIs and other networking services.
What is Node-RED?
According to the website, “Node-RED is a browser-based editor that makes it is thus easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.”
although It is built on a popular JavaScript environment, Node JS, which is an open-source runtime environment
One major benefit of using the Node-RED environment is that it however stores the files in a JSON format, which makes it easy to transfer files for sharing.
Node-RED is very flexible and can be run locally, on a raspberry pi device or in a cloud server.
The YouTube API!
In the previous section, the tool to be used for the project was introduced. Here, let us talk about the data that we will be using.
Youtube is a video streaming platform that is popular worldwide. But with the increase in the viewership, it sometimes gets difficult to keep track. The YouTube API allows you to access youtube functions such as subscriber count, uploading videos, managing playlists etc. It can be called using HTTP requests such as GET, PUT, POST and DELETE.
Here in this project, we will be using the GET function to call the Youtube API to show the subscriber statistics to the user.
Building the Node-RED flow:
Before beginning to build the project, ensure that the Chart.js node is installed as we will be trying to visualize the statistics.
We will thus be using an HTTP protocol to call the API. The first node in the flow will be the inject node. so The inject node acts as a trigger for the flow to start working.
Timestamp:
Request Setup:
The next node that we will be working with is the Request Setup using the function node. therefore, This node is used to define the API key and the youtube channel ID of which we need to see the details. thus, The node and the properties are mentioned in the picture given below.
HTTP Request:
To call the information regarding the youtube channel the GET method is used. therefore, It is a communication method used to request data from a specified source.
JSON:
To display the data efficiently using the msg.payload on the browser, we convert the data into JSON format.
Now that we have discussed all the important nodes, the flow between the nodes will look as follows.
Creating a Youtube API
- Login to your google account in console cloud google account.
- Go to API and libraries. Enable the Youtube API V3.
- Click on create credentials and follow the steps that are required
Since my youtube account has no videos public, the stats are not interesting but the expected stats of the project are shown below using the output from the youtube video.
Conclusion:
This brings us to the end of the project. Here, we learnt about an IoT tool named Node-RED. We tried to understand the HTTP protocol using the Youtube API.
An HTTP GET request was used to call the relevant information.
There are also other nodes, which reduce the length of the flow. To know more about these nodes, visit the Node-RED documentation.
Hope you liked the project!
Written by: Suchitra Srinivasan
Reviewed by: Batta Pruthvi
If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs