Skip to main content

Indexer API Reference & Usage

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

Getting Started

The Sequence 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.

Sequence Indexer endpoints

Sequence Indexer offers the same API across a variety of EVM networks. Make sure to check the Indexer endpoints and use the corresponding host for your dapp/game. For example, the Etheruem mainnet the Sequence Indexer endpoint is https://mainnet-indexer.sequence.app and Polygon is https://polygon-indexer.sequence.app.

🌄 View the full list of supported networks and Indexer endpoints here


Web / node.js Installation

npm install 0xsequence

or

npm install @0xsequence/indexer

then in your app,

import { SequenceIndexerClient } from '@0xsequence/indexer'

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

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

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


Go Installation

go get -u github.com/0xsequence/[email protected]

then in your app,

import (
"github.com/0xsequence/go-sequence/indexer"
)

// see https://docs.sequence.xyz/indexer#supported-networks--endpoints for list of
// indexer hosts for the chain you'd like to query
seqIndexer := indexer.NewIndexerClient("https://mainnet-indexer.sequence.app", http.DefaultClient)

// see examples below for the kinds of queries you can make
tokenBalances, err := seqIndexer.GetTokenBalances(...)

Unity or Unreal Installation

The Sequence Indexer is integrated directly inside of the respective Sequence Web3 Unity and Sequence Web3 Unreal SDKs.


Fetch all tokens & NFTs in any wallet

Fetches all ERC20, ERC721 and ERC1155 token balances and metadata in any wallet.

Sequence Indexer GetTokenBalances Method:

  • Request: POST /rpc/Indexer/GetTokenBalances
  • Content-Type: application/json
  • Body (in JSON):
    • accountAddress (string) -- the wallet account address
    • includeMetadata (boolean - optional - default: false) -- toggle token metadata to be included in the response

Example: GetTokenBalances of a wallet account address on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetTokenBalances -d '{ "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9", "includeMetadata": true }'

Query ownership and balances of ERC721 and ERC1155 collections.

Sequence Indexer GetTokenBalances Method:

  • Request: POST /rpc/Indexer/GetTokenBalances
  • Content-Type: application/json
  • Body (in JSON):
    • accountAddress (string) -- the wallet account address
    • contractAddress (string) -- the contract address of the ERC721 / ERC1155 collection
    • includeMetadata (boolean - optional - default: false) -- toggle token metadata to be included in the response

Example: GetTokenBalances of a contract + account address on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetTokenBalances -d '{ "contractAddress": "0x631998e91476DA5B870D741192fc5Cbc55F5a52E", "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9", "includeMetadata": true }'

Fetch the transaction history for any wallet address

Fetches the transaction / token history for any wallet address of any ERC20, ERC721 and ERC1155 token. The response includes decoded transaction details for easy consumption / rendering.

Sequence Indexer GetTransactionHistory Method:

  • Request: POST /rpc/Indexer/GetTransactionHistory
  • Content-Type: application/json
  • Body (in JSON):
    • filter (object)
      • accountAddress (string) -- the wallet account address
      • contractAddress (string) -- optionally specify a contract address to filter
    • includeMetadata (boolean - optional - default: false) -- toggle token metadata to be included in the response

Example: GetTransactionHistory of a wallet account address on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetTransactionHistory -d '{ "filter": { "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9" }, "includeMetadata": true }'

Fetch all unique tokens in a particular ERC20/721/1155 contract, including total supplies

Fetches token supplies and metadata for any ERC20, ERC721, ERC1155 contract.

This query is helpful to render all tokens in a token contract, or to query the total token supplies. In this example, we use the Skyweaver token contract address 0x631998e91476DA5B870D741192fc5Cbc55F5a52E on the Polygon network. You may query any contract address on any of the supported networks (but make sure to query the indexer of the corresponding network).

Sequence Indexer GetTokenSupplies Method:

  • Request: POST /rpc/Indexer/GetTokenSupplies
  • Content-Type: application/json
  • Body (in JSON):
    • contractAddress (string) -- a ERC20 / ERC721 / ERC1155 contract address
    • includeMetadata (boolean - optional - default: false) -- toggle token metadata to be included in the response

Example: GetTokenSupplies of Skyweaver contract on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetTokenSupplies -d '{ "contractAddress": "0x631998e91476DA5B870D741192fc5Cbc55F5a52E", "includeMetadata": true }'

Fetch the transaction history for any token contract address

Fetch / listen to the transaction history for any ERC20, ERC721, ERC1155 contract.

This query is helpful to track transaction history of a particular token contract. In this example, we use the Skyweaver token contract address 0x631998e91476DA5B870D741192fc5Cbc55F5a52E on the Polygon network. You may query any contract address on any of the supported networks (but make sure to query the indexer of the corresponding network).

Sequence Indexer GetBalanceUpdates Method:

  • Request: POST /rpc/Indexer/GetBalanceUpdates
  • Content-Type: application/json
  • Body (in JSON):
    • contractAddress (string) -- a ERC20 / ERC721 / ERC1155 contract address

Example: GetBalanceUpdates of Skyweaver contract on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetBalanceUpdates -d '{ "contractAddress": "0x631998e91476DA5B870D741192fc5Cbc55F5a52E" }'

Fetch native network balance (aka ETH on Ethereum, MATIC on Polygon, AVAX on Avalanche, BNB on BSC, etc.)

Sequence Indexer GetEtherBalance Method:

  • Request: POST /rpc/Indexer/GetEtherBalance
  • Content-Type: application/json
  • Body (in JSON):
    • accountAddress (string) -- the wallet account address

Example: GetEtherBalance MATIC balance of a wallet account address on Polygon

curl -X POST -H"Content-Type: application/json" https://polygon-indexer.sequence.app/rpc/Indexer/GetEtherBalance -d '{ "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9" }'

Fetch the chain ID

Sequence Indexer GetChainID Method:

  • Request: POST /rpc/Indexer/GetChainID
  • Content-Type: application/json

curl -X POST -H"Content-Type: application/json" https://mainnet-indexer.sequence.app/rpc/Indexer/GetChainID