What web3. js API is and why do we need it ?
What is web3.js ?
In simple terms, web3.js is a collection of libraries that allows us to interact with a local or remote Ethereum Node.
What is an Ethereum Node ? Let’s understand this with the help of the above picture.
The above figure is a an Ethereum Blockchain Network where each and every system is connected with each other through a p2p network. In the Ethereum Blockchain world, these systems are called Ethereum Nodes.
So, web3.js helps us to interact with these Ethereum Nodes via HTTP, IPC or Web Socket.
Now you must be wondering why anyone will want to interact with these ethereum nodes. And why do we need web3.js ?
Importance of web3.js
1) It helps you to query data from the Blockchain. For example – to get the balance of an account, to send ether to another account etc. The web3.js library is a collection of modules that contain functionality for the ethereum ecosystem.
web3-ethis for the ethereum blockchain and smart contracts.
web3-shhis for the whisper protocol, to communicate p2p and broadcast.
web3-bzzis for the swarm protocol, the decentralized file storage.
web3-utilscontains useful helper functions for Dapp developers.
2) It helps you to create Decentralized Applications (Dapps). Your real world technology, i.e. your frontend cannot directly interact blockchain world technology i.e. your smart contract . As both of these belong to two different worlds. The web3.js library acts as a bridge between your real world and the blockchain world.
So, I hope it is now clear what is web3.js and why do need it. To know more about refer here.