# `@xchainjs/xchain-thornode`

Thornode Module for XChainJS Clients

## Modules

Thornode module has been created using openapi-generator-cli to auto-generate rest api reading from "https://gitlab.com/thorchain/thornode/-/raw/release-{version}/openapi/openapi.yaml"
This library exposes all the Api's outlined in the swagger doc "https://gateway.liquify.com/chain/thorchain_api/thorchain/doc"

## Installation

```
yarn add @xchainjs/xchain-thornode
```

## Examples

Request data from MimirApi

```
// THORNODE_API_URL - default exported URL
// import { MimirApi, THORNODE_API_URL, Configuration } from '@xchainjs/xchain-thornode'

  const baseUrl = THORNODE_API_URL
  const apiconfig = new Configuration({ basePath: baseUrl })
  const mimirApi = new MimirApi(apiconfig)
  const mimirResponse = await mimirApi.mimir()
  console.log(mimirResponse.data)

```

## Example - set custom header

Request data from MimirApi

```
// THORNODE_API_URL - default exported URL
// import { MimirApi, THORNODE_API_URL, Configuration } from '@xchainjs/xchain-thornode'

  const baseUrl = THORNODE_API_URL
  const headers = {"x-client-id": "my-custom-val"}
  const baseOptions = { headers }
  const apiconfig = new Configuration({ basePath: baseUrl , baseOptions })
  const mimirApi = new MimirApi(apiconfig)
  const mimirResponse = await mimirApi.mimir()
  console.log(mimirResponse.data)

```

## Documentation

[`Thornode Liquify endpoint`](https://gateway.liquify.com/chain/thorchain_api/)

### Setting Headers for public endpoints

If you plan on using the publicly accessible endpoints listed below, ensure that you add a valid 'x-client-id' to all requests

- https://gateway.liquify.com/chain/thorchain_midgard
- https://api.haskoin.com (BTC/BCH/LTC)
- https://gateway.liquify.com/chain/thorchain_api

For a complete example please see this [test](https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-thorchain-amm/__e2e__/wallet.e2e.ts)
