How to Query Historical Hedera Data with the DragonGlass REST API
Jan 03, 2020
by DragonGlass Team

This post was authored by Sreejith Kaimal and Ashu Mahajan, Application Architects at OpenCrowd. OpenCrowd is a design and technology firm that provides custom blockchain development and consulting services to enterprise clients and startups.

Coming to Hedera from a traditional blockchain background, one of the first things users must wrap their heads around is how the network handles state. As a development partner since 2017, we at OpenCrowd are keenly aware that companies building on Hedera need a seamless way to access all of their live and historical data in an operational data store. Additionally, users of these applications may want to access any relevant information about them. These issues are what led us to create the DragonGlass platform.

Accessing Historical Data with DragonGlass

The DragonGlass API is a REST API that allows you to query historical data by transactions and accounts on both the testnet and mainnet.

For instance, if you’d like to query the balance of a given account at a certain point in time you can use the following:{accountID}/balances/(asOfInEpoch}

As you can imagine this makes it easy to incorporate into your application. We’ll demonstrate how to in a few quick examples within a JavaScript environment.

If you’re trying to follow along you’ll need:

I’d also suggest using Postman to make it easy to format. After obtaining a DragonGlass access key, it’s straightforward to retrieve data from DragonGlass. We will start by first submitting a transaction to Hedera.

Create a client

For the JS SDK, the sample client is available on the public repo at You could always build a custom client using the protobuf definitions for the Hedera APIs, but we’ll stick to JS SDK for this example.

Code Snippet Background

import {Client} from "@hashgraph/sdk";

const client = new Client({
network: {"": "0.0.3"},
operator: {
account: { shard: 0, real: 0, account: MyAccountID},
privateKey: MyPrivateKey


Send hbars

Once you have set up your Hedera keys, the client can send a transaction. For the sake of our demo we'll do a simple cryptocurrency transfer:

Code Snippet Background

new CryptoTransferTransaction()
.addSender({ shard: 0, realm: 0, account: SenderAccount }, 10_000_000)
.addRecipient({ shard: 0, realm: 0, account: ReceiverAccount }, 10_000_000)

Query DragonGlass

Now we can use the DragonGlass API to monitor this transaction by accountID. Notice you’ll need to add the DragonGlass API key to the GET request.

Code Snippet Background

* Note: You should not expose your API key in browser.
* i.e. Should not call DragonGlass directly from client app.
* Ideally use your own server. Your client (UI) calls your server * which internally calls DragonGlass

const apiKey = '<Your_Access_Key>';
const getTransactionsByAccount = (accountId) =>
fetch(`${accountId}`, {
headers: { 'x-api-key': apiKey, Accept: 'application/json', Host: '' }

You can also use DragonGlass to fetch other types of Hedera transactions, such as contract calls, for a contractID in the transaction:

Code Snippet Background

const getTransactionsByContract = (contractID) =>


contractID=${contractID}&transactionType=CONTRACT_CALL`, {

headers: { 'x-api-key': apiKey, Accept: 'application/json', Host: '' }


Or fetch a raw transaction for a given DragonGlass generated transactionRecordID:

Code Snippet Background

const getTransactionsByRecord = (transactionRecordID) =>


transactionRecordID=${transactionRecordID}`, {

headers: { 'x-api-key': apiKey, Accept: 'application/json', Host: '' }


It is of note that behind the scenes, and before the API even responds to your request, DragonGlass is automating many normally time-consuming services, such as signature verification and unmarshalling / indexing data. We think by doing so, we can help the community focus on building scalable decentralized applications without needing to invest precious time and money in building the platform that houses operational data.

DragonGlass dApp Marketplace

The second major item of interest for dApp creators is the DragonGlass dApp Marketplace. Each dApp is given a dedicated page in the marketplace that provides detailed insight into dApp activities. Users can view transaction history, access smart contract templates and token transfer records, and quickly view stats such as the number of active users.

As the blockchain ecosystem becomes more and more decentralized, the need for a centralized information center becomes increasingly valuable; instead of dApp users having to navigate to multiple locations to reach relevant dApp information, they can simply visit DragonGlass and have all the info they need presented in a single, clean location.

With more and more users convening on DragonGlass each day, creating a dApp page is a simple and easy way to increase your product's visibility for potential new customers, connect with other dApp developers, and create a home base for your users.

Dragonglass Dapp

A sample dApp page within the Marketplace

The Marketplace is currently live with pages for, Hash Name Service, AdsDax, PlayHash, and AoChain.

To recap, DragonGlass extends Hedera with a wide range of capabilities:

  1. Customizable Dashboard that works for B2C: Allows your users to enable rich previews of historical transactions on your customer accounts. You can even attach this to your customer profile for a delegated user experience.
  2. Embedded Transactional Data in your dApp with DragonGlass APIs: Use our rich REST-based APIs to fetch any Hedera data for specific scenarios. Fetch and store data that matter to you most, not the whole thing.
  3. Configurable Notification Services: Do your customers need alerting? Be it winning a lottery or a large payment, dApp creators can use this service as a way of sending push notifications without the need of constantly asking the network or paying additional fees for fetching records.
  4. dApp Marketplace: dApp owners can create a page within the DragonGlass dApp Marketplace where users can access detailed dApp data including contracts, byte code, usage, source, and more.

For the time being, we kept our focus on the two aspects of DragonGlass most relevant to dApp developers: the full set of DragonGlass APIs, and the dApp Marketplace. If you would like to feature your dApp on DragonGlass, or to learn more about the platform, please email [email protected] to get your dApp page set up and running.