AppChains
Components
Advanced APIs
Query API

Query API

Query API is a part of Advanced APIs' collection of methods that can be added as the add-on premium feature to the AppChains package.

Query API is an access-ready solution that enables your projects to interact with multiple blockchains in a single request. By indexing blockchain data from all eight currently supported chains, searching through large amounts of data is easier and faster than ever before. Query API can boast almost instantaneous processing speeds (due to the key-value filtering supported) for the searches that might ordinarily take hours to process.

Query API serves to request info on the ranges of blocks (max range is 100) for a full list of block metadata.

Query API implements the JSON-RPC 2.0 specification (opens in a new tab) for interaction.

Query API Methods

Query API consists of the following methods to request info on the ranges of blocks (max range is 100) for a full list of block metadata:


ankr_getBlocks

Retrieves the blocks' data.

Retrieves complete information for the block specified.

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • blockchain (string; required): either of the supported chains (bas_bombchain, bas_bombchain_testnet, bas_metaapes, bas_metaapes_testnet).
    • decodeLogs (boolean): set to true to decode logs, or to false if you don't need this kind of info.
    • decodeTxData (boolean): set to true to decode transaction data, or to false if not interested in it.
    • descOrder (boolean): choose data order, either descending (if true) or ascending (if false).
    • fromBlock (uint64): the first block of the range.
    • toBlock (uint64): the last block included in the range.
    • includeLogs (boolean): set to true to include logs, or to false to exclude them. Note that logs are stored inside transactions, so make sure the following parameter is also set to true if you'd like to include logs.
    • includeTxs (boolean): set to true to include transactions, or to false to exclude them.
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "ankr_getBlocks",
  "params": {
    "blockchain": "string",
    "decodeLogs": true,
    "decodeTxData": true,
    "descOrder": true,
    "fromBlock": 0,
    "includeLogs": true,
    "includeTxs": true,
    "toBlock": 0
  }
}

Response

Returns complete information for the block specified by request parameters.

Code Examples

Request

curl --location --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getBlocks",
    "params": {
        "blockchain": "bas_bombchain",
        "fromBlock": 14500000,
        "toBlock": 14500000,
        "decodeLogs": false,
        "decodeTxData": true,
        "includeLogs": true,
        "includeTxs": true
    },
    "id": 1
}'

Response

Code: 200 OK

{
  "error": {},
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "blocks": [
      {
        "blockHash": "string",
        "blockHeight": "string",
        "blockchainLogo": "string",
        "blockchainName": "string",
        "details": {
          "ethBlock": {
            "difficulty": "string",
            "extraData": "string",
            "gasLimit": 0,
            "gasUsed": 0,
            "miner": "string",
            "nonce": "string",
            "sha3Uncles": "string",
            "size": "string",
            "stateRoot": "string",
            "totalDifficulty": "string"
          }
        },
        "parentHash": "string",
        "timestamp": "string",
        "transactionsCount": 0
      }
    ]
  }
}

ankr_getLogs

Retrieves the blocks' history data.

Retrieves history data for the blocks specified.

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • address (uint8): an address of the contract created the logs. Supported value formats: hex or array of hexes.
    • blockchain (string): a chain or a combination of chains to query:
      • Single chain: bas_bombchain, bas_bombchain_testnet, bas_metaapes, bas_metaapes_testnet.
      • Chains combination: [bas_bombchain, bas_metaapes, bas_bombchain_testnet].
      • All chains: leave the value empty to query all the chains available.
    • decodeLogs (boolean): set to true to decode logs, or to false if you don't need this kind of info.
    • descOrder (boolean): choose data order, either descending (if true) or ascending (if false).
    • fromBlock (string): the first block of the range. Supported value formats: hex, decimal, "earliest", "latest".
    • fromTimestamp (uint64): the first timestamp of the range.
    • pageSize (string): a number of result pages you'd like to get.
    • pageToken (string): a token is provided at the end of the response body and can be referenced in the request to fetch the next page.
    • toBlock (string): the last block included in the range.
    • toTimestamp (uint64): the last timestamp of the range.
    • topics (uint8): the data the log contains.
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "ankr_getLogs",
  "params": {
    "address": [
      [
        0
      ]
    ],
    "blockchain": [
      "string"
    ],
    "decodeLogs": true,
    "descOrder": true,
    "fromBlock": 0,
    "fromTimestamp": 0,
    "pageSize": 0,
    "pageToken": "string",
    "toBlock": 0,
    "toTimestamp": 0,
    "topics": [
      [
        [
          0
        ]
      ]
    ]
  }
}

Response

Returns history data for the blocks specified by request body parameters.

Code Examples

Request

curl --location --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getLogs",
    "params": {
        "blockchain": "bas_bombchain",
        "fromBlock": "0xdaf6b1", // hex, decimal, "earliest", "latest" are supported
        "toBlock": 14350010, // hex, decimal, "earliest", "latest" are supported
        "address": ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"], // hex or array of hexes are supported
        "topics": [
            [],
            [
                "0x000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff"
            ]
        ]
    },
    "id": 1
}'

Response

Code: 200 OK

{
  "error": {},
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "logs": [
      {
        "address": "string",
        "blockHash": "string",
        "blockNumber": "string",
        "data": "string",
        "event": {
          "anonymous": true,
          "id": "string",
          "inputs": [
            {
              "indexed": true,
              "name": "string",
              "size": 0,
              "type": "string",
              "valueDecoded": "string"
            }
          ],
          "name": "string",
          "signature": "string",
          "string": "string",
          "verified": true
        },
        "logIndex": "string",
        "removed": true,
        "topics": [
          "string"
        ],
        "transactionHash": "string",
        "transactionIndex": "string"
      }
    ],
    "nextPageToken": "string"
  }
}

ankr_getTransactionsByHash

Retrieves data for the hash-specified transaction.

Retrieves the details for a transaction specified by hash.

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • blockchain (string): a chain or a combination of chains to query:
      • Single chain: bas_bombchain, bas_bombchain_testnet, bas_metaapes, bas_metaapes_testnet.
      • Chains combination: [bas_bombchain, bas_metaapes, bas_bombchain_testnet].
      • All chains: leave the value empty to query all the chains available.
    • transactionHash (string): a hash of the transactions you'd like to request the details for.
    • decodeLogs (boolean): set to true to decode logs, or to false if you don't need this kind of info.
    • decodeTxData (boolean): set to true to decode transaction data, or to false if not interested in it.
    • includeLogs (boolean): set to true to include logs, or to false to exclude them.
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "ankr_getTransactionsByHash",
  "params": {
    "blockchain": [
      "string"
    ],
    "decodeLogs": true,
    "decodeTxData": true,
    "includeLogs": true,
    "transactionHash": "string"
  }
}

Response

Returns all transactions' metadata for the hash specified in request body parameters.

Code Examples

Request

curl --location -g --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getTransactionsByHash",
    "params": {
        "transactionHash": "0x82c13aaac6f0b6471afb94a3a64ae89d45baa3608ad397621dbb0d847f51196f",
        "decodeLogs": true,
        "decodeTxData": true
    },
    "id": 1
}'

Response

Code: 200 OK

{
  "error": {},
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "transactions": [
      {
        "blockHash": "string",
        "blockNumber": "string",
        "blockchain": "string",
        "contractAddress": "string",
        "cumulativeGasUsed": "string",
        "from": "string",
        "gas": "string",
        "gasPrice": "string",
        "gasUsed": "string",
        "hash": "string",
        "input": "string",
        "logs": [
          {
            "address": "string",
            "blockHash": "string",
            "blockNumber": "string",
            "data": "string",
            "event": {
              "anonymous": true,
              "id": "string",
              "inputs": [
                {
                  "indexed": true,
                  "name": "string",
                  "size": 0,
                  "type": "string",
                  "valueDecoded": "string"
                }
              ],
              "name": "string",
              "signature": "string",
              "string": "string",
              "verified": true
            },
            "logIndex": "string",
            "removed": true,
            "topics": [
              "string"
            ],
            "transactionHash": "string",
            "transactionIndex": "string"
          }
        ],
        "logsBloom": "string",
        "method": {
          "id": "string",
          "inputs": [
            {
              "name": "string",
              "size": 0,
              "type": "string",
              "valueDecoded": "string"
            }
          ],
          "name": "string",
          "signature": "string",
          "string": "string",
          "verified": true
        },
        "nonce": "string",
        "r": "string",
        "s": "string",
        "status": "string",
        "timestamp": "string",
        "to": "string",
        "transactionHash": "string",
        "transactionIndex": "string",
        "type": "string",
        "v": "string",
        "value": "string"
      }
    ]
  }
}

ankr_getTransactionsByAddress

Retrieves transactions by address.

Retrieves the details of transactions specified by address.

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • address (string; required): an address to search for transactions.
    • blockchain (string): either of the supported chains (bas_bombchain, bas_bombchain_testnet, bas_metaapes, bas_metaapes_testnet).
    • fromBlock (integer): narrow your search indicating the block number to start from (inclusive; >= 0).
    • toBlock (integer): narrow your search indicating the block number to end with (inclusive; >= 0).
    • fromTimestamp (integer): narrow your search indicating the timestamp to start from (inclusive; >= 0).
    • toTimestamp (integer): narrow your search indicating the timestamp to end with (inclusive; >=0).
    • includeLogs (boolean): set to true to include logs, or to false to exclude them.
    • descOrder (boolean): choose data order, either descending (if true) or ascending (if false).
    • pageSize (int32): a number of result pages you'd like to get.
    • pageToken (string): a token is provided at the end of the response body and can be referenced in the request to fetch the next page.
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "ankr_getTransactionsByAddress",
    "params": {
        "blockchain": "string",
        "includeLogs": true,
        "descOrder": true,
        "pageSize": 0,
        "pageToken": "string",
        "toTimestamp": 0,
        "address": "string"
    }
}

Response

Returns the transactions specified by address.

Code Examples

Request

curl --location -g --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "ankr_getTransactionsByAddress",
    "params": {
        "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
    }
  }'

Response

Code: 200 OK

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "transactions": [
            {
                "blockHash": "string",
                "blockNumber": "string",
                "blockchain": "string",
                "cumulativeGasUsed": "string",
                "from": "string",
                "gas": "string",
                "gasPrice": "string",
                "gasUsed": "string",
                "hash": "string",
                "input": "string",
                "nonce": "string",
                "r": "string",
                "s": "string",
                "status": "string",
                "timestamp": "string",
                "to": "string",
                "transactionIndex": "string",
                "type": "string",
                "v": "string",
                "value": "string"
            }
        ]
    }
}

ankr_getBlockchainStats

Retrieves blockchain statistics.

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • blockchain (string): a chain or a combination of chains to query:
      • Single chain: bas_bombchain, bas_bombchain_testnet, bas_metaapes, bas_metaapes_testnet.
      • Chains combination: [bas_bombchain, bas_metaapes, bas_bombchain_testnet].
      • All chains: leave the value empty to query all the chains available.
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "ankr_getInteractions",
  "params": {
    "address": "string"
  }
}

Response

Returns statistics for the blockchains specified.

Code Examples

Request

curl --location --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getBlockchainStats",
    "params": {},
    "id": 1
}'

Response

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "stats": [
      {
        "blockTimeMs": 3000,
        "blockchain": "bas_bombchain",
        "latestBlockNumber": 24274429,
        "nativeCoinUsdPrice": "245.153233940444766334",
        "totalEventsCount": 11643833187,
        "totalTransactionsCount": 3764960943
      },
      {
        "blockTimeMs": 4000,
        "blockchain": "bas_metaapes",
        "latestBlockNumber": 37350500,
        "nativeCoinUsdPrice": "0.803307052493372837",
        "totalEventsCount": 8710949888,
        "totalTransactionsCount": 2318753716
      }
    ]
  }
}

ankr_getInteractions

Retrieves blockchains interacted with a particular address.

Retrieves a list of blockchains on which the address interaction was registered and manifested by the info available for the address (tokens, NFTs, transactions).

Request

Build your request using the parameters below.

Parameters

  • id (int64; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (object; required): the data object containing request body parameters:

    • address (string): an address of the contract created the logs.
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "ankr_getInteractions",
  "params": {
    "address": "string"
  }
}

Response

Returns the list of blockchains interacted with the address specified in request body parameters.

Code Examples

Request

curl --location -g --request POST 'https://rpc.chainscanner.xyz/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
		"jsonrpc": "2.0",
		"method": "ankr_getInteractions",
		"params": {
			"address":"0xF977814e90dA44bFA03b6295A0616a897441aceC"
		},
		"id": "1"
	}'

Response

Code: 200 OK

{
  "error": {},
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "blockchains": [
      "string"
    ]
  }
}