The Heartbeat of Cardano.

Streamlining CardanoBI API Integration via Python and Node.js SDKs

CardanoBi, short for Cardano Business Intelligence, serves as a fully open-source API that provides on-chain analytics and enable data-driven services on the Cardano network. As it’s name suggests, the platform is built with business intelligence at its core. CardanoBi isn’t just about seamless access to raw data; it’s about extracting meaningful insights from the Cardano blockchain. By analyzing on-chain data, CardanoBi enables informed decision-making, strategic planning, and innovative solutions for businesses, developers, and stakeholders.

    Another key aspect of the CardanoBi platform is it’s commitment to open source transparency and collaboration. As an open-source project, its code is accessible to developers, researchers, and enthusiasts alike. This openness fosters innovation, encourages community contributions, and ensures that CardanoBi remains a dynamic and evolving solution.

    While the above benefits are key to unlocking the immense potential of blockchain by pivoting data-driven innovations, a large portion of the community, particularly Cardano Python developers, lack the necessary tools to leverage CardanoBI. To solve this, Thomas Langlois proposes to build an open-source software development kit (SDK) with tools, libraries, and corresponding documentation. In turn, Python developers can integrate CardanoBI API into their applications and access data efficiently.

      This article explores the features of CardanoBI and how different users can take advantage of it’s services. It also introduces the proposed Python SDK that will enable Python developers to leverage Cardano’s capabilities. But before then, here’s a quick overview of the API should be a good start.

      Overview of CardanoBI API

      CardanoBi organizes its data into three distinct domains, each serving a specific purpose:

      Core Domain

      The Core domain provides all on-chain data related to Cardano. It’s the bedrock of CardanoBI, providing essential information about accounts, blocks, transactions, contracts, pools, epochs, polls, addresses, and more.

      From the core domain, you can pull on-chain data from multiple endpoints. For example, with addresses, you can get useful information about an address or all payment addresses linked to a given stake address. You can also query blocks by their number, hash, epoch, or slot number. The epoch endpoint returns information about all epochs, the latest, and even by their numbers. Similarly, the Transactions endpoint provides transaction details, each by its hash and consequent inputs and unspent outputs (UTXOs).

      This kind of on-chain data can be valuable to different types of users, including:

      • Developers: They gain access to granular on-chain data for building decentralized applications (dApps) and smart contracts.
      • Validators and Stake Pool Operators can use it to monitor network health, performance, and security.
      • Researchers can analyze historical trends, track network activity, and contribute to Cardano’s growth.

        Bi (Analytics) Domain

        Built on top of the Core domain, the BI or analytics domain offers aggregated and processed data points. These insights are valuable for understanding network behavior, patterns, and performance. The BI endpoint is key for those looking for statistical information related to addresses or pools. It can be valuable to:

        • Businesses and enterprise can make informed decisions based on trends, user behavior, and market dynamics.
        • Individual investors can use analytics to assess Cardano’s potential and evaluate investment strategies.
        • Governance participants gain insights into network governance and voting patterns.

          Partner Domain

          The partner domain extends beyond raw data. It provides data services and APIs that cater to specific use cases. Examples could include price feeds, historical data, and network statistics that could benefit financial institutions, news agencies, or even trades. When partners contribute their data to CardanoBI, the community can use it to add value to their businesses. A good example is the partnership with Zero Citizen, which has helped propel the realization of tokenized climate solutions.

          Expanding the scope of available data enhances the depth and breadth of business analytics and intelligence, which is of value to different users, including:

          • Third-party developers looking to create innovative applications by leveraging CardanoBi’s offerings.
          • Data analysts who need access to pre-processed data for research, modeling, and reporting.
          • DApps and DeFi projects looking to integrate CardanoBi services to enhance their functionality.

            The CardanoBI team provides multiple resources that can help you get started with the API. Their website enables you to discover functionalities, manage your user account, and begin interacting with the SaaS API. Since the API is organized into the core, BI, and partner domains, so is the API Reference documentation. You can use it to discover, explore, and consume different offerings of the API based on your project’s requirements

              CardanoBI also has GitHub repositories that host code for specific functionalities and components of the API. All are open-source with detailed contribution guidelines.

              • Cardano BI API backend – A .NET 6.0 backend leveraging cardano-db-sync, providing a denormalized endpoint that exposes on-chain data in user-friendly responses. It also handles the business logic of exposing endpoints for all domains.
              • CardanoBI Node.js/JavaScript SDK – Only available if registered at cardanobi.io; the SDK is used to authenticate API requests. The repo also links to the API docs and provides tutorials on CardanoBI capabilities.
              • Cardano BI DevOps ToolKit – A compact collection of DevOps tools, scripts, and automation for CardanoBI getaway.
              • API Identity – A server that helps secure all endpoints.

              Getting started with CardanoBI

              To get started with CardanoBI API, visit cardanobi.io and select Login at the top right corner. On the sign-in page, you can either register with your email or authenticate with Google or GitHub. Once authenticated, select the “Project” button to create your first project. Enter your preferred name and use the drop-down feature to select an environment for your project. This could be the mainnet, preprod, or preview environment. Select Save.

              After saving your project, CardanoBi displays your API key and API secret. The secret value is only displayed once and disappears as soon as the window is refreshed. Be sure to save this value for use in your API calls.

              To interact with CardanoBI, you can either install the Node.js SDK and import it to your project, or call the CardanoBI API directly using POST requests. Let’s take a closer look at the two options:

              Option 1: Making POST requests to the CardanoBI API

              To call the CardanoBI API using Postman, cURL, Insomnia, or your preferred platform for interacting with APIs, you start by obtaining an access token using the client credentials grant, as follows:

              curl -d "client_id=YOUR-KEY&client_secret=YOUR-SECRET&grant_type=client_credentials" -X POST https://cardanobi.io:44010/connect/token

              In your cURL request above, replace the placeholders with the API key and secret values you recorded from the CardanoBi dashboard. A successful request to the token endpoint returns a bearer token that you can use to authenticate and authorize subsequent requests to the CardanoBI API. Using the bearer token, you can make a request to look up for the latest block on mainnet, as follows:

              curl https://cardanobi.io:4000/api/core/blocks/latest -H "Authorization: Bearer YOUR-BEARER-TOKEN" -H "Client-Api-Key: YOUR-API-KEY"

              If everything worked correctly, you should receive a response like the following:

              {
                "id": 10176830,
                "hash": "1P0IVhrhLqW7pOvm2PSgGw2nId/5fQ7PleP9eunNwT0=",
                "epoch_no": 477,
                "slot_no": 120744631,
                "epoch_slot_no": 43831,
                "block_no": 10146882,
                "previous_id": 10176829,
                "slot_leader_id": 5756706,
                "size": 38803,
                "time": "2024-04-05T09:55:22",
                "tx_count": 10,
                "proto_major": 8,
                "proto_minor": 0,
                "vrf_key": "vrf_vk1t9rhj4pxmlmem2th6pa8lwwpnrn38vs8jlvxqmf85fhnum5smksshhxpq0",
                "op_cert": "wxeZvzc5uE5w3AOWZIbKlBFss9JP16lG+oSuEC0mwOg=",
                "op_cert_counter": 25,
                "hash_hex": "d4fd08561ae12ea5bba4ebe6d8f4a01b0da721dff97d0ecf95e3fd7ae9cdc13d",
                "op_cert_hex": "c31799bf3739b84e70dc03966486ca94116cb3d24fd7a946fa84ae102d26c0e8"
              }

              Option 2: Using the Node.js SDK

              If you’re a Node.js developer who prefers a higher level of abstraction while interacting with CardanoBI, you can use the Node.js SDK as opposed to interacting with the service via its API. To install the SDK, use the following:

              $ git clone https://github.com/cardanobi/cardanobi-js.git
              cd cardanobi-js
              npm install
              

              You then import CardanoBI.js in your project as follows:

              import { CardanoBI } from './cardanobi-js/CardanoBI.js'

              And then make your first request to get the latest block on mainnet.

              const CBI = await new CardanoBI({ apiKey: "YOUR-KEY", API secret: "YOUR-SECRET"});
              const block = await CBI.core.blocks.latest_();
              console.log(block);
              

              You need to replace the API key and secret values in your request. If everything worked correctly, the expected response should be similar to the one above, where we interacted with the API directly.

              For a better understanding of CardanoBI, please watch the Fund 8 close-out report, which covers the project’s architecture, deliverables, a working demo, and a look into the product roadmap.

              As seen, the project is a reflection of building resilient infrastructure that promotes inclusive and sustainable industrialization and fosters innovation. Access to Cardano data insights, if well utilized, is a key to supporting economic development built on affordable accessibility for all. Remember, the data acquired here spans accounts, addresses, assets, blocks, epochs, polls, pools, transactions, and partners.

              Project Roadmap and Budget

              Having built the CardanoBI REST API and Node.js SDK, the development team aims to deliver the Python SDK in three months, with milestones consisting of well-outlined tasks clearly laid out. Here’s a breakdown of the project plan.

              MilestoneDescriptionExpected Results
              SDK specs and design– Initiate the project by defining the scope and objectives, including the three CardanoBI domains.
              – Gather detailed specifications of the SDK, beginning with the JavaScript SDK.
              – Create a comprehensive SDK architecture and design plan.
              – Set up Python development environments with the necessary tools and libraries.
              – A detailed GitHub project with detailed tasks and their priority board.
              – Tasks will entail the design, development, testing, and release of the Python 3 SDK
              – SDK scope mirrors the Node.js (JavaScript) SDK and covers all endpoints exposed by CardanoBI instances.
              – Thorough testing covers unit, integration, and performance tests
              Development– Develop core SDK functionalities, including authentication and authorization tokens, RestAPI connectivity for reaching CardanoBi API instances, and logical processing units with boundaries for each endpoint.
              – Unit tests for the above development steps.
              – Link to SDK’s GitHub repository.
              – Unit test results for all endpoints (execution logs will be presented in .txt files, and responses will be in. JSON format).
              Testing, documentation, and release– Extensive testing, including integration and performance assessment.
              – Develop a comprehensive documentation packed with set-up guides and API references.
              – Avail real-world use case examples.
              – Release a Beta version for community feedback.
              – Launch the official SDK version.
              – Successful integration with CardanoBI API, backed with rigorous testing where all tests have passed and all issues resolved.
              – An accessible documentation for all user levels
              – Incorporated feedback from the Beta release
              – Official release of stable SDK ratified by integration test results (both scripts and their outputs), link to the official documentation, link to GitHub SDK repo, and tutorials describing how to use the SDK.

              In their quest to build the Python SDK, Thomas and team requested ADA 19,950 that would be allocated as follows:

              MilestoneAllocationTimeline
              Specification/DesignADA 75/hour1 week
              Development/TestingADA 75/hour4 weeks
              Documentation/ReleaseADA 75/hour1.5 weeks

              The Team

              The talented development team that’s responsible for bringing the CardanoBI REST API to life consists of:

              • Thomas Langlois – A lead architect and full-stack (backend and frontend) software developer with 22 years of active contribution to the financial industry. Coming from a master’s degree in software engineering, he brings a rich experience with success in software development and team leadership. He is also a stake pool operator and passionate blockchain technology enthusiast.
              • Ahmed Abouelnour – A data architect and backend developer. Ahmed is a senior solution architect bridging the ocean between businesses, IT, analysis, blueprints, and implementation in the software industry. He is passionate about the Internet of Things (IoT) and distributed ledger technology (DLT). He’s also good at agile software development methodology.

              Ramping Up Cardano’s Developer Activity

              By building the Python SDK, the Cardano ecosystem benefits from enhanced development and fosters innovation. This project triggers the creation of innovative digital experiences and services on Cardano By unblocking developers who create utility services. Unlocking business value stored in Cardano’s on-chain data promotes the growth of the whole ecosystem. This uptick in developer activity will ultimately bring new ideas and solutions to the ecosystem, propelling growth, and adding to the overall competitiveness of the Cardano blockchain.

              To learn more about CardanoBI’s Python SDK, check out their recently approved fund 11 proposal on Project Catalyst.

              Leave a Reply

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

              Related Posts