How can we use Covalent API to query on-chain data on moonbeam and moonriver network?

Benixs
MATeS of Moonbeam
Published in
3 min readApr 24, 2022

Hello everyone! Are you facing issues when you need to query on-chain data for doing something but you don’t know how?

If yes, today I have a simple solution for you to query on-chain data by using a third-party that is fully integrated with moonbeam and moonriver called Covalent API.

Step by step

To be used by Covalent you must have a Covalent API key by doing following this step.

Step 1. Register with your email.

Image 1. Register page

Step 2. Login with your username and password then go to the API key menu.

Image 2. Manage API Keys icon

Step 3. Click on “Add” button and fill your API key name then click “Save”

Image 3. Create API key page

Step 4. Click on the API that you have created early and you will see an example request like this.

Image 4. API Info page

Step 5. After that, you can try to send a simple request like this

Request

curl -X GET https://api.covalenthq.com/v1/1/block_v2/5000000/ \-u “YOUR_API_KEY”:-H 'Content-Type: application/json'

Response

{
"data": {
"updated_at": "2022-02-17T10:42:35.389193176Z",
"items": [
{
"signed_at": "2018-01-30T13:41:33Z",
"height": "5000000"
}
],
"pagination": null
},
"error": false,
"error_message": null,
"error_code": null
}

About Covalent API

Covalent can be used to pull balances, positions, and historical granular transaction data from dozens of blockchain networks.

Covalent Parameter

Covalent API is integrated on EVM compatibility including Moonbeam and Moonriver network. If you want to switch from one blockchain network to another is simply changing the chain_id path parameter.
Moonbeam chain id: 1284
Moonriver chain id: 1285
Moonbase Alpha chain id: 1287

Covalent API Structure.

There separate API into 3 classes of endpoints.

  1. Class A: endpoints that return enriched blockchain data applicable to all blockchain networks, eg: balances, transactions, log events, etc.
  2. Class B: endpoints maintained by Covalent for a specific protocol on a specific blockchain, eg: AAVE is Ethereum/Polygon-only and is not applicable to other blockchain networks (yet.)
  3. Class C (Soon): endpoints maintained by the community.

Covalent URL Host

Host: https://api.covalenthq.com/v1/

Authentication: You should authenticate with your API from an early step.

Authentication mechanisms

  • Authentication via query parameter (Put some example later)
  • Authentication via Basic Auth (Put some example later)

For more information

Conclusion

You can use a Covalent API for many use-cases like wallets, investor dashboards, taxation tools, and as-of-yet unknown use-cases, and the important thing, Currently it’s free!

Have fun with your passionate project. See you.

--

--