Indexer Installation

MinerGate Indexer is a simple API to query any blockchain token and NFT data. Below are instructions on how to integrate the MinerGate Indexer API into your Webapps, Games, and backends. In case you missed it, please also see the Indexer Overview.

Installation

The MinerGate Indexer is built as a HTTP API with RPC endpoints that you may call directly from your Webapp, Game or server backend. Below you'll find information on the RPC endpoint schema with sample curl commands, along with examples in both Javascript/Typescript and Go.

We provide SDKs for Web / node.js and Go. Or if you'd like to integrate the Indexer with another language target, simply follow the API reference below to implement the HTTP requests. Additionally, read the Typescript client source code as reference implementation of the Indexer API client as well.

Web / node.js Installation

npm install minergate ethers

or

pnpm install minergate ethers

or

yarn add minergate ethers

This code requires an API Access Key from MinerGate Builder.

then in your app (using your API_Access_Key),

import { MinergateIndexer } from '@minergate/indexer'

// see https://docs.minergate.xyz/indexer#supported-networks--endpoints for list of
// indexer hosts for the chain you'd like to query
const indexer = new MinergateIndexer('https://mainnet-indexer.minergate.xyz', 'c3bgcU3LkFR9Bp9jFssLenPAAAAAAAAAA')

// see examples below for the kinds of queries you can make
const tokenBalances = await indexer.getTokenBalances(...)

NOTE: if you're using @minergate/indexer from node.js, we recommend using node v18.x or newer.

Go Installation

go get -u github.com/minergate/go-minergate@latest

then in your app,

import (
	"github.com/minergate/go-minergate/indexer"
)

// see https://docs.minergate.xyz/indexer#supported-networks--endpoints for list of
// indexer hosts for the chain you'd like to query
mgtIndexer := indexer.NewIndexer("https://polygon-indexer.minergate.xyz", "c3bgcU3LkFR9Bp9jFssLenPAAAAAAAAAA")

// see examples below for the kinds of queries you can make
accountAddress := "ACCOUNT_ADDRESS"
includeMetadata := true
metadataOptions := indexer.MetadataOptions{
	VerifiedOnly: true,
}

_, tokenBalances, err := mgtIndexer.GetTokenBalances(context.Background(), &accountAddress, nil, nil, &includeMetadata, &metadataOptions, nil)

Last updated