Explorer API vs custom methods

Table of Contents

    Introduction

    Developing wallets and decentralized applications (dApps) requires reliable access to blockchain data. Traditionally, developers use direct data parsing from the blockchain, but this can be a complex and time-consuming process. With the advent of blockchain explorers and their API interfaces, such as the Blockbook endpoint, a more convenient alternative has emerged. In this article, we will explore the advantages of using Explorer via API compared to traditional data parsing.

    Brief Comparison: Indexer, Blockbook, Explorer

    Indexer:

    • Organizes and indexes blockchain data for quick and efficient access.
    • Supports complex queries and scales to handle large volumes of data.

    Blockbook:

    • Combines features of an indexer and a blockchain explorer.
    • Supports multiple blockchains and offers a comprehensive set of APIs for real-time data retrieval.

    Explorer:

    • A blockchain explorer that allows users to view blockchain data through a web interface.
    • Used for searching and analyzing transactions, addresses, and blocks.

    Advantages of Using Explorer via API

    Resources and Costs

    Traditional data parsing requires significant effort to set up and maintain the infrastructure. Developers need to create and maintain blockchain nodes, implement their own methods for extracting and processing data.

    Using Explorer via API, such as Blockbook, significantly simplifies this process. The API provides ready-made methods for obtaining the necessary data, eliminating the need for complex parsing operations.

    By delegating the work of setting up and maintaining blockchain nodes, which require significant computational resources and time, to the provider, developers can focus on creating the functionality of their applications rather than on infrastructure. This not only speeds up the development process but also reduces system maintenance costs.

    Reliability and Data Accuracy

    Blockchain explorers, such as Blockbook, ensure high reliability and data accuracy. They constantly synchronize with the blockchain and provide up-to-date data in real time. This is especially important for wallets and dApps where data accuracy is critical. Using the API ensures that the application always receives reliable information.

    API interfaces of blockchain explorers offer a wide range of functional capabilities that are difficult to implement on your own. These can include functions for obtaining balances, transaction history, block data, and many other aspects of the blockchain. Such rich functionality allows developers to quickly integrate necessary features into their applications. Methods can be found in the NOWNodes documentation.

    Most API interfaces, such as Blockbook, come with extensive documentation and community support. This facilitates the integration and use of the API, as developers can refer to the documentation or ask the community for help, reducing the number of potential errors.

    Practical Application of Blockbook API

    Let’s look at a few examples where using the Blockbook API facilitates the development of wallets and dApps:

    We have also WSS (WebSocket Secure) – a protocol that provides a persistent and secure connection for real-time data transmission, unlike standard HTTP/HTTPS methods which require reopening the connection for each request.

    1. Get transaction ETH

    Get transaction returns “normalized” data about transaction, which has the same general structure for all supported coins. It does not return coin specific fields.

    Method: GET

    https://etc-blockbook.nownodes.io/api/v2/tx/<txid>

    Example response: 200

    {
        "txid": "0x212bfc5b1d8c32da6584764c746d19306c6dfe36e5fef6954688b6f12ce51af1",
        "vin": [
            {
                "n": 0,
                "addresses": [
                    "0xBcF9Af410cf09bdf81a73Fe5DEf32457B0e469aC"
                ],
                "isAddress": true
            }
        ],
        "vout": [
            {
                "value": "13542016697178286",
                "n": 0,
                "addresses": [
                    "0xA52f32E3612aFB089A500A79eB8B83c744D52Eb6"
                ],
                "isAddress": true
            }
        ],
        "blockHash": "0xd43ce56aaec39484fcdbadb2c5a60d5ea36bc7f5c1bf23fea3099dfcae48f7d6",
        "blockHeight": 19763401,
        "confirmations": 166,
        "blockTime": 1713969153,
        "value": "13542016697178286",
        "fees": "21000000000000",
        "ethereumSpecific": {
            "status": 1,
            "nonce": 265806,
            "gasLimit": 50000,
            "gasUsed": 21000,
            "gasPrice": "1000000000",
            "data": "0x"
        }
    }

    2. Get transaction specific ETH

    Returns transaction data in the exact format as returned by backend, including all coin specific fields:

    Method: GET

    https://etc-blockbook.nownodes.io/api/v2/tx-specific/<txid>

    Example response: 200

    {
        "tx": {
            "nonce": "0x40e4e",
            "gasPrice": "0x3b9aca00",
            "gas": "0xc350",
            "to": "0xA52f32E3612aFB089A500A79eB8B83c744D52Eb6",
            "value": "0x301c6476c718ae",
            "input": "0x",
            "hash": "0x212bfc5b1d8c32da6584764c746d19306c6dfe36e5fef6954688b6f12ce51af1",
            "blockNumber": "0x12d90c9",
            "blockHash": "0xd43ce56aaec39484fcdbadb2c5a60d5ea36bc7f5c1bf23fea3099dfcae48f7d6",
            "from": "0xBcF9Af410cf09bdf81a73Fe5DEf32457B0e469aC",
            "transactionIndex": "0x1"
        },
        "receipt": {
            "gasUsed": "0x5208",
            "status": "0x1",
            "logs": []
        }
    }

    How to connect to Explorer via API with NOWNodes

    First of all, you can obtain access to the NOWNodes via using your personal API key, which you need to create in your profile page.

    • The first step is to Sign up for your personal account by simply using your email address. The email address is the only thing you need to use the NOWNodes service.
    • Then you will see all the available pricing options. You can choose the free tariff plan to access and test Explorers with ease. If you have a major project then you can choose any of the paid plans, according to your needs.
    • Then you need to navigate to the “DASHBOARD’’ in your account and scroll down the page. There you will see the button “ADD NEW KEY”. Just push the button and your API key will be ready to use.
    Where API key NOWNodes

    Conclusion

    Using Explorer via API, such as the Blockbook endpoint, offers developers of wallets and dApps numerous advantages over traditional data parsing. It simplifies the development process, saves time and resources, ensures data reliability and accuracy, and offers extended functional capabilities. As a result, developers can create higher quality and more reliable applications, focusing their efforts on functionality and user experience.