> For the complete documentation index, see [llms.txt](https://xchainjs.gitbook.io/xchainjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xchainjs.gitbook.io/xchainjs/protocols/thorchain/xchain-midgard-query/how-to-use.md).

# How to Use

## Installation <a href="#installation" id="installation"></a>

```
yarn add @xchainjs/xchain-midgard-query
```

### Peer Dependencies <a href="#dependencies" id="dependencies"></a>

You can visit the [xchain-midgard-query](https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-midgard-query/package.json) package repository to get the updated peer dependencies by looking at the "peerDependencies" object in the "package.json" file.

## Examples <a href="#basic-usage-examples" id="basic-usage-examples"></a>

```
import { AssetBTC } from '@xchainjs/xchain-bitcoin'
import { AssetATOM } from '@xchainjs/xchain-cosmos'
import { Midgard, MidgardCache, MidgardQuery, SaversPosition } from '@xchainjs/xchain-midgard-query'
import { Network } from '@xchainjs/xchain-client'

const saverBtc: getSaver = {
  asset: AssetBTC,
  address: '',
}
const saverAtom: getSaver = {
  asset: AssetATOM,
  address: '',
}

const midgardCache = new MidgardCache(new Midgard(Network.Testnet))
const midgardQuery = new MidgardQuery(midgardCache)
// Get saver positions (cached)
const getSavers: SaversPosition[] = await midgardQuery.getSaverPositions([saverAtom, saverBtc])
// Get thorname info (no cached)
const thorname = await midgardQuery.midgardCache.midgard.getTHORNameDetails('gx')
```
