Friday, September 12, 2025
No Result
View All Result
Ajoobz
Advertisement
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Scam Alert
  • Regulations
  • Analysis
Marketcap
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Scam Alert
  • Regulations
  • Analysis
No Result
View All Result
Ajoobz
No Result
View All Result

Top Block Explorer API – How to Get All the Blockchain Data You Need

2 years ago
in Web3
Reading Time: 15 mins read
0 0
A A
0
Home Web3
Share on FacebookShare on TwitterShare on E-Mail


If you wish to construct a block explorer – or implement related performance into your decentralized functions (dapps) – you’ll seemingly need to leverage a complete block explorer API. And, if that is so for you, you’ve come to the appropriate place!

In as we speak’s article, we’ll introduce you to Moralis’ industry-leading Web3 API suite – the last word device for constructing block explorers. With our premier interfaces, you may effortlessly get block knowledge, token costs, pockets balances, and way more. When you’re desperate to get going, listed here are three outstanding Moralis API endpoints that may turn out to be useful when constructing a block explorer: 

getBlock() – Question the contents of a block by its block quantity or hash:const response = await Moralis.EvmApi.block.getBlock({
“chain”: “0x1”,
“blockNumberOrHash”: “18541416”
}); getWalletTransactions() – Fetch all transactions of any deal with:const response = await Moralis.EvmApi.transaction.getWalletTransactions({
“chain”: “0x1”,
“deal with”: “0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326”
}); getWalletTokenBalances() – Get the token balances of any pockets: const response = await Moralis.EvmApi.token.getWalletTokenBalances({
“chain”: “0x1”,
“deal with”: “0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326”
});

For a extra detailed breakdown of the endpoints above and a tutorial on how one can name them, be part of us on this article as we discover the intricacies of Moralis’ Web3 APIs. Moreover, in case you choose watching movies to be taught, take a look at the clip under, the place we cowl some outstanding endpoints wanted to construct your individual block explorer: 

Additionally, if you wish to use our instruments and APIs to save lots of invaluable improvement time and assets, don’t neglect to enroll with Moralis. You’ll be able to create your account freed from cost, and also you’ll be capable to leverage blockchain expertise’s full energy instantly! 

Overview 

We’ll kickstart as we speak’s article by diving into the ins and outs of block explorers. From there, we’ll cowl the intricacies of block explorer APIs and clarify why you would possibly want one when constructing dapps. Subsequent, we’ll introduce you to the {industry}’s premier API supplier: Moralis. Moreover, we’ll cowl some outstanding endpoints that you simply’ll want when constructing block explorers or implementing related performance into your tasks. Lastly, to high issues off, we’re going to provide you a block explorer API tutorial the place we present you how one can get the token balances of any pockets in three steps: 

Arrange MoralisWrite a Script Calling the getWalletTokenBalances() EndpointRun the Code

If this sounds intriguing, be part of us under as we kick issues off by taking a look at what a block explorer is! 

What’s a Block Explorer? 

Block explorers – additionally generally known as blockchain explorers – are software program functions that mean you can extract, visualize, and assessment blockchain knowledge. This contains important details about blocks, sensible contracts, occasions, transactions, pockets balances, and way more! 

Most blockchain networks have their very own distinct block explorers. For instance, some outstanding examples embrace Ethereum’s Etherscan, Polygon’s PolygonScan, and BNB Good Chain’s (BSC) BscScan.

So, what precisely does a block explorer do? To reply this query, let’s take a look at some key options of block explorers. And let’s use Etherscan for example: 

View Block Information: With Etherscan, you may seamlessly verify the contents of any block on Ethereum. This contains data similar to timestamps, transactions, gasoline used, gasoline restrict, and way more: 

Discover Token Information: Discover any token deal with to get knowledge similar to the whole provide, variety of holders, transfers, costs, market caps, and details about underlying sensible contracts: 

Etherscan block explorer showing total supply, number of holders, transfers, prices, market caps, and information about underlying smart contracts

Test Pockets Addresses: Test any pockets deal with and get data like native balances, token balances, transactions, inner transactions, switch histories, NFT transfers, and way more: 

native balances, token balances, transactions, internal transactions, transfer histories, NFT transfers, and much more on Etherscan

To have the ability to effortlessly fetch and show the knowledge above, together with block knowledge, token costs, pockets transfers, and many others., instantly from the blockchain, software program functions like Etherscan leverage block explorer APIs! 

However what’s a block explorer API? Additionally, why must you use one?

What’s a Block Explorer API? 

A block explorer API (software programming interface) is a algorithm, protocols, and strategies that mean you can seamlessly work together with a blockchain to combine block explorer performance and knowledge into your tasks. Consequently, a block explorer API basically offers a structured solution to entry knowledge about blocks, transactions, wallets, crypto addresses, and way more! 

Art illustration - blocks connected via software - illustration a block explorer API

However why do you want a block explorer API?

Querying knowledge instantly from a blockchain community is a tedious and time-consuming activity. And from a standard perspective, it required builders to, as an illustration, run a full node themselves and construct their very own infrastructure for knowledge retrieval. 

Luckily, that is not the case with refined instruments like block explorer APIs, as they summary away loads of complexity related to blockchain expertise, providing you with a standardized solution to talk with the varied networks. 

All in all, a block explorer API makes the method of querying knowledge from a blockchain a lot simpler. And with interfaces like these, you may leverage premade strategies and protocols, that means you don’t need to reinvent the wheel. Because of this, block explorer APIs mean you can save each loads of improvement time and assets, underscoring the essential position these interfaces have inside the blockchain house! 

So, which is the very best block explorer API supplier? 

Introducing Moralis: The Final Block Explorer API Supplier 

Moralis is an industry-leading API supplier, and our suite of premier interfaces makes Web3 improvement as seamless as Web2. Consequently, when working with Moralis, it has by no means been simpler to construct the whole lot from NFT marketplaces to your individual block explorer! 

Moreover, in our suite of Web3 APIs, you’ll discover the whole lot {that a} block explorer API has to supply and extra. As such, when working with Moralis, you may effortlessly fetch block knowledge, transactions, balances, token costs, NFTs, and many others., with solely single strains of code. 

Marketing banner - Art image - Moralis Block Explorer API

However why must you be utilizing our Web3 APIs? 

To reply the query above, let’s take a look at three outstanding advantages of Moralis: 

Scalability: Our Web3 APIs are constructed to scale. Consequently, you don’t have to fret when your tasks develop and see elevated adoption, as Moralis can have no bother dealing with the visitors.Excessive Efficiency: Our APIs are the {industry}’s premier interfaces. Select any metric – whether or not you need to measure by reliability, knowledge protection, velocity, or the rest – our Web3 APIs outperform the competitors day-after-day of the week. 

Moralis vs. Competition Block Explorer APIs - Graph with results

Cross-Chain Compatability: With our Web3 APIs, you may seamlessly construct throughout the preferred blockchain networks, together with Ethereum, BNB Good Chain, Polygon, Avalanche, Gnosis, Chiliz, and lots of others. As such, it has by no means been simpler to construct cross-chain appropriate dapps! 

So, what instruments can you discover in Moralis’ Web3 API suite? 

Nicely, right here’s an inventory of a few of our most outstanding interfaces: 

If you wish to discover all of them, take a look at our Web3 API web page! 

The way to Construct a Block Explorer with Moralis’ API Suite 

Now, with an outline of Moralis’ Web3 API suite, you could be questioning how one can leverage our instruments to construct a block explorer your self. Nevertheless, since block explorers are fairly in depth items of software program, we gained’t be capable to cowl all performance on this tutorial. As a substitute, we’ll concentrate on a number of examples and dive into the important endpoints wanted to: 

Get Block Information with the Blockchain APIFetch Token Costs with the Token API Question Token Balances with the Pockets API

So, with out additional ado, let’s kick issues off by displaying you how one can get block knowledge utilizing Moralis’ Blockchain API! 

Get Block Information with the Blockchain API 

The primary central function of any block explorer that we coated within the ”What’s a Block Explorer?” part was the flexibility to view block knowledge, together with timestamps, transactions, gasoline limits, and many others: 

view block data, including timestamps, transactions, gas limits, etc on Etherscan via API

The simplest solution to get this data is to leverage Moralis’ Blockchain API and the getBlock() endpoint. All it’s important to do is name this endpoint with two parameters: chain and blockNumberOrHash: 

const response = await Moralis.EvmApi.block.getBlock({
“chain”: “0x1”,
“blockNumberOrHash”: “18541416”
});

Calling the endpoint above returns the contents of the block in query, together with a timestamp, hash, transactions, gasoline used, gasoline restrict, and way more. That is what it would seem like:

{
“timestamp”: “2023-11-10T12:02:11.000Z”,
“quantity”: “18541416”,
“hash”: “0xe9de65582d5a210f3f5703e0d7dc1daf9fbb5a0670937f5d92283a41ea1bcb2b”,
“parent_hash”: “0xb63af7df0e2639cc25c323f22359b784408a117b534dea09cfec14263ea8d4fb”,
“nonce”: “0x0000000000000000”,
“sha3_uncles”: “0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347”,
“logs_bloom”: “0x00200//…”,
“transactions_root”: “0x0b6895fbd7fdf9b8e0239e5be21a195c89ffae093c1c2bcdea9ad498d720003b”,
“state_root”: “0x787cc0fff225d2b6d8acef1cea33522293d134297c1f4b22819a90f157db183d”,
“receipts_root”: “0x6d7caa30f12937a232dcedda5f8bc2c973ba917a67062cedeb4ccb52c729058c”,
“miner”: “0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5”,
“problem”: “0”,
“total_difficulty”: “58750003716598352816469”,
“dimension”: “7792”,
“extra_data”: “0x6265617665726275696c642e6f7267”,
“gas_limit”: “30000000”,
“gas_used”: “1372772”,
//…
}

If you wish to know extra about how this works, take a look at our Blockchain API tutorial! 

Fetch Token Costs with the Token API 

One other vital function of most block explorers is the flexibility to discover token knowledge, together with transfers, holders, and many others. And on this part, we’ll present you how one can get the worth of any token: 

Etherscan Block Explorer API Example on get the price of any token

Probably the most easy solution to get this knowledge is to leverage Moralis’ Token API. With solely a single name to the getTokenPrice() endpoint, you may seamlessly get the worth of any token, and all it’s important to do is specify two parameters: chain and deal with: 

const response = await Moralis.EvmApi.token.getTokenPrice({
“chain”: “0x1”,
“deal with”: “0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0”
});

In return for calling the getTokenPrice() endpoint, you get the token’s value denominated within the chain’s native forex and USD. Right here’s an instance of what it would seem like: 

{
“tokenName”: “Matic Token”,
“tokenSymbol”: “MATIC”,
“tokenLogo”: “https://cdn.moralis.io/eth/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png”,
“tokenDecimals”: “18”,
“nativePrice”: {
“worth”: “423085770833740”,
“decimals”: 18,
“identify”: “Ether”,
“image”: “ETH”,
“deal with”: “0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2”
},
“usdPrice”: 0.8771902804648514,
“usdPriceFormatted”: “0.877190280464851369”,
“exchangeName”: “Uniswap v3”,
“exchangeAddress”: “0x1F98431c8aD98523631AE4a59f267346ea31F984”,
“tokenAddress”: “0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0”
}

Question Token Balances with the Pockets API 

Lastly, a remaining core function of most block explorers is the performance to verify knowledge related to a pockets deal with, together with transfers, balances, and many others. And on this part, we’ll present you how one can fetch all token holdings of a pockets: 

data associated with a wallet address, including transfers, balances, etc., on Etherscan using Block Explorer API

The simplest solution to get this data is to leverage Moralis’ Pockets API. All you want is a single name to the getWalletTokenBalances() endpoint whereas passing alongside two parameters: chain and deal with: 

const response = await Moralis.EvmApi.token.getWalletTokenBalances({
“chain”: “0x1”,
“deal with”: “0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326”
});

In return for calling the endpoint above, you get an inventory of all tokens held by the pockets in query. It should look one thing like this: 

[
{
“token_address”: “0x3c978fc9a42c80a127863d786d8883614b01b3cd”,
“symbol”: “USDT”,
“name”: “USDTOKEN”,
“logo”: null,
“thumbnail”: null,
“decimals”: 18,
“balance”: “10000000000000000000000”,
“possible_spam”: true
},
{
“token_address”: “0xdac17f958d2ee523a2206206994597c13d831ec7”,
“symbol”: “USDT”,
“name”: “Tether USD”,
“logo”: “https://cdn.moralis.io/eth/0xdac17f958d2ee523a2206206994597c13d831ec7.png”,
“thumbnail”: “https://cdn.moralis.io/eth/0xdac17f958d2ee523a2206206994597c13d831ec7_thumb.png”,
“decimals”: 6,
“balance”: “209355461”,
“possible_spam”: false
},
//…
]

If you wish to discover all different endpoints, take a look at our official Web3 API documentation web page! 

What’s extra, in case you’re on the lookout for a tutorial on how one can combine this knowledge into your dapps, take a look at the Moralis YouTube video under. This clip offers a complete breakdown of how one can construct an Etherscan clone in lower than twelve minutes:

Block Explorer API Tutorial: The way to Get the Token Balances of a Pockets in 3 Steps 

On this a part of the article, we’ll current an entire tutorial on how one can name the varied endpoints of Moralis. To spotlight the accessibility of our premier interfaces, we’ll use the getWalletTokenBalances() endpoint for example and present you how one can get the token balances of a pockets in three steps:

Arrange MoralisWrite a Script Calling the getWalletTokenBalances() EndpointRun the Code

Nevertheless, you have to take care of a number of conditions earlier than we are able to proceed! 

Conditions 

This can be a JavaScript tutorial. As such, it is advisable to have the next prepared: 

Step 1: Set Up Moralis 

For step one, it is advisable to be part of Moralis to get your API key. As such, in case you don’t have already got an account, click on on the ”Begin for Free” button on the high proper to enroll: 

Moralis Block Explorer API - Get Started for Free button

From there, go to the ”Settings” tab, scroll down, and replica your API key: 

Moralis Block Explorer API interface - showing how to copy API

Preserve it for now, as you’ll want it within the subsequent part! 

Step 2: Write a Script Calling the getWalletTokenBalances() Endpoint 

For the second step, arrange a brand new venture in your IDE, open a brand new terminal, and run the next command within the root folder to put in the Moralis SDK: 

npm set up moralis @moralisweb3/common-evm-utils

Subsequent, create an ”index.js” file and add the next code: 

const Moralis = require(“moralis”).default;
const { EvmChain } = require(“@moralisweb3/common-evm-utils”);

const runApp = async () => {
await Moralis.begin({
apiKey: “YOUR_API_KEY”,
// …and some other configuration
});

const deal with = “0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d”;

const chain = EvmChain.ETHEREUM;

const response = await Moralis.EvmApi.token.getWalletTokenBalances({
deal with,
chain,
});

console.log(response.toJSON());
};

runApp();

From there, add your Moralis API key by changing YOUR_API_KEY: 

Block Explorer API key code parameter

Subsequent, configure chain and deal with to suit your question: 

chain and address code parameters for the block explorer API feature

From right here, we then move alongside chain and deal with as parameters when calling the endpoint: 

Calling the block explorer API endpoint

And that’s it for the script! 

Step 3: Run the Code 

For the ultimate step, open a brand new terminal and run the command under within the venture’s root folder: 

node index.js

In return, you’ll get an array of all tokens held by the pockets in query. And it’ll look one thing like this:

[
{
“token_address”: “0xefd6c64533602ac55ab64442307f6fe2c9307305”,
“name”: “APE”,
“symbol”: “APE”,
“logo”: null,
“thumbnail”: null,
“decimals”: 18,
“balance”: “101715701444169451516503179”
},
{
“token_address”: “0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2”,
“name”: “Wrapped Ether”,
“symbol”: “WETH”,
“logo”: “https://cdn.moralis.io/eth/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.webp”,
“thumbnail”: “https://cdn.moralis.io/eth/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_thumb.webp”,
“decimals”: 18,
“balance”: “85000000000000000”
}
]

Congratulations! You now know how one can get the token balances of a pockets with Moralis! 

If questions stay, take a look at the official documentation web page demonstrating how one can get all ERC-20 tokens owned by an deal with. Additionally, you may comply with the steps above to name some other Moralis endpoint. All it’s important to do is change the endpoint and configure the parameters through the second step!  

Abstract: Exploring the Trade’s Premier Block Explorer API

In as we speak’s article, we launched you to Moralis’ industry-leading suite of Web3 APIs. With our premier interfaces, you get the whole lot it is advisable to construct a block explorer or combine related performance into your tasks, making it the last word Etherescan API different. And due to the accessibility of our APIs, you may get the information you want with single strains of code! 

Along with introducing you to Moralis, we additionally confirmed you how one can get the token balances of a pockets in three steps: 

Arrange MoralisWrite a Script Calling the getWalletTokenBalances() EndpointRun the Code

Consequently, when you have adopted alongside this far, you now know how one can get blockchain knowledge utilizing Moralis! 

When you preferred this block explorer API tutorial, think about trying out extra content material on the Web3 weblog. As an example, take a look at our Ropsten faucet information or find out about the very best blockchain API suppliers! 

Additionally, if you wish to leverage our industry-leading Web3 APIs, don’t neglect to enroll with Moralis as we speak! 



Source link

Tags: APIblockblockchaindataexplorerTop
Previous Post

SOL Price Uptrend To Continue? Can Bulls Send Solana To $75?

Next Post

🔴 Altcoins Awakening | This Week in Crypto – Nov 13, 2023

Related Posts

Futures Traders Flock to Ethereum as ETF Investors Rotate to Bitcoin
Web3

Futures Traders Flock to Ethereum as ETF Investors Rotate to Bitcoin

19 hours ago
AI agents can now pay APIs with USDC in 200 ms as Coinbase activates x402 Bazaar
Web3

AI agents can now pay APIs with USDC in 200 ms as Coinbase activates x402 Bazaar

2 days ago
QMMM Stock Skyrockets Nearly 1,750% on Bitcoin, Ethereum, Solana Treasury Plan
Web3

QMMM Stock Skyrockets Nearly 1,750% on Bitcoin, Ethereum, Solana Treasury Plan

2 days ago
Strategy Buys 7 Million More In Bitcoin After S&P 500 Snub
Web3

Strategy Buys $217 Million More In Bitcoin After S&P 500 Snub

4 days ago
Wall Street’s Needs Will Advance Ethereum’s Privacy, Says Etherealize
Web3

Wall Street’s Needs Will Advance Ethereum’s Privacy, Says Etherealize

5 days ago
Robinhood Set to Join S&P 500 as Bitcoin Giant Strategy Misses Out
Web3

Robinhood Set to Join S&P 500 as Bitcoin Giant Strategy Misses Out

6 days ago
Next Post
🔴 Altcoins Awakening | This Week in Crypto – Nov 13, 2023

🔴 Altcoins Awakening | This Week in Crypto – Nov 13, 2023

Permissionless Blockchain: A Definitive Guide

Permissionless Blockchain: A Definitive Guide

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

[ccpw id="587"]
  • Disclaimer
  • Cookie Privacy Policy
  • Privacy Policy
  • DMCA
  • Terms and Conditions
  • Contact us
Contact us for business inquiries: cs@ajoobz.com

Copyright © 2023 Ajoobz.
Ajoobz is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Scam Alert
  • Regulations
  • Analysis

Copyright © 2023 Ajoobz.
Ajoobz is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In