Stocks on Magicbit
MagicBlocks Project

Stocks on Magicbit

Make Magicbit display upto date Stock details.


In this lesson, we will use a Magicbit board to display the Stock details. We will use an API service to obtain the latest news on Stocks. We have used API services before in previous lessons.

Intended Learning Outcomes

  • You will learn how to handle Stocks API.
  • You will learn how to give a display output to the Magicbit.

What are Stocks?

Stocks are an investment in a company and that company’s profits. Investors buy stock to earn a return on their investment.

This is how ordinary people invest in some of the most successful companies in the world. For companies, stocks are a way to raise money to fund growth, products, and other initiatives.

When you buy the stock of a company, you’re effectively buying an ownership share in that company.

Setting up the Nodes

First, you need the below nodes.


Make the following arrangement.

Configuring the Inject Node.

Double click on it to access its settings. Make the below settings.

Now, let’s configure the HTTP request block.

  • Enter Method as GET.
  • Set the return field as “a parsed JSON object”
  • Paste the given link on the URL field:


Function Node

Enter the given code in the Function.

var companyName = "IBM";
var time = msg.payload.IBM.values[0].datetime.slice(11,16) + " USA-NY"
var high = msg.payload.IBM.values[0].high + " $";
var low = msg.payload.IBM.values[0].low + " $";

msg.payload = "Company: "+companyName + "\n" +"Time:    "+time+"\n"+ "High:    "+high+ "\n" + "Low:     "+low ;
msg.topic = "";

return msg;

Template Node

Enter the below settings.

Display Node

Connect the Magicbit board with the Magicblocks platform.

Enter the Device(Board) ID. you can see your device ID in the devices tab.

Related Posts
Leave a Reply