Indexers API
Overview
XDEFI provides Indexers API for developers to fetch balances, transactions, fees across many blockchains supported by Ctrl Wallet.
The base URL for all API endpoints is: https://gql-router.xdefi.services/graphql.
Here are the chains supported by the Indexers API:
| Chain | Key | Base chain |
|---|---|---|
| Akash | akash | CosmosChain |
| Arbitrum | arbitrum | EVM |
| Aurora | aurora | EVM |
| Avalanche | avalanche | EVM |
| Axelar | axelar | CosmosChain |
| Binance | binance | BinanceChain |
| Binance Smart Chain | binanceSmartChain | EVM |
| Bitcoin | bitcoin | BitcoinChain |
| Bitcoin Cash | bitcoincash | BitcoinChain |
| Canto | cantoEVM | EVM |
| Cosmos Hub | cosmos | CosmosChain |
| Crescent | crescent | CosmosChain |
| Cronos | cronosEVM | EVM |
| Dogecoin | dogecoin | BitcoinChain |
| Ethereum | ethereum | EVM |
| Fantom | fantom | EVM |
| Juno | juno | CosmosChain |
| Kava | kava | CosmosChain |
| Kujira | kujira | CosmosChain |
| Litecoin | litecoin | BitcoinChain |
| Maya Protocol | mayachain | MayaChain |
| Optimism | optimism | EVM |
| Osmosis | osmosis | CosmosChain |
| Polygon | polygon | EVM |
| Solana | solana | SolanaChain |
| Stargaze | stargaze | StargazeChain |
| Stride | stride | CosmosChain |
| ThorChain | thorchain | ThorChain |
| Tron | tron | TronChain |
Get Balance
javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetBalances($address: String!, $first: Int, $after: String) {
${chain.key} {
balances(address: $address, first: $first, after: $after) {
amount {
value
}
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
variables: {
address: address // Input address
first: 1,
after: null,
},
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetBalances($address: String!, $tokenAddresses: [String!]) {
${chain.key} {
balances(address: $address, tokenAddresses: $tokenAddresses) {
amount {
value
}
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
query,
variables: {
address: address // Input address
tokenAddresses: null,
},
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetBalances($address: String!) {
${chain.key} {
balances(address: $address) {
amount {
value
}
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
variables: {
address: address, // Input address
},
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});Get Gas Fee
javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetGasFee {
${chain.key} {
fee {
high
low
medium
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetFee {
${chain.key} {
fee {
defaultGasPrice
high {
maxFeePerGas
baseFeePerGas
priorityFeePerGas
}
low {
baseFeePerGas
maxFeePerGas
priorityFeePerGas
}
medium {
baseFeePerGas
maxFeePerGas
priorityFeePerGas
}
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});UTXOs (Bitcoin, Bitcoin Cash, Dogecoin, Litecoin)
Get Unspent Transaction Outputs (UTXOs)
javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query GetUnspentTxOutputsV5($address: String!, $page: Int!) {
${chain.key} {
unspentTxOutputsV5(address: $address, page: $page) {
oIndex
oTxHash
value {
value
}
scriptHex
oTxHex
isCoinbase
address
}
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
variables: {
address: address, // Input address
page: 1,
},
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});Broadcast Transaction
javascript
const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql";
const query = `query BroadcastTransaction($rawHex: String!) {
${chain.key} {
broadcastTransaction(rawHex: $rawHex)
}
}`;
await fetch(GRAPHQL_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"apollographql-client-name": "docs-indexers-api",
"apollographql-client-version": "v1.0",
},
body: JSON.stringify({
query,
variables: {
rawHex: rawHex, // Input raw transaction hex
},
}),
})
.then((response) => response.json())
.then((result) => {
console.log(result);
// Do something with the result
});View more about raw transaction hex here.