# Trading Data

The API endpoints of `Trading Data` do not require authentication.

## Trading Data

### Get Support Coin

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-support-coin>
{% endhint %}

#### Function name:

```javascript
getSupportCoin()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSupportCoin(exchange) {
    try {
        let result = await exchange.getSupportCoin();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSupportCoin(myOkxAccount)
```

### Get Taker Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-volume>
{% endhint %}

#### Function name:

```javascript
getTakerVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerVolume(exchange) {
    try {
        let result = await exchange.getTakerVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerVolume(myOkxAccount, 
{
    ccy: "BTC",
    instType: "SPOT"
})
```

### Get Margin Lending Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-margin-lending-ratio>
{% endhint %}

#### Function name:

```javascript
getMarginLendingRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMarginLendingRatio(exchange) {
    try {
        let result = await exchange.getMarginLendingRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarginLendingRatio(myOkxAccount, 
{
        ccy: "BTC"
})
```

### Get Long/Short Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-long-short-ratio>
{% endhint %}

#### Function name:

```javascript
getLongShortRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getLongShortRatio(exchange) {
    try {
        let result = await exchange.getLongShortRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLongShortRatio(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Contracts Open Interest and Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-contracts-open-interest-and-volume>
{% endhint %}

#### Function name:

```javascript
getContractsOiAndVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getContractsOiAndVolume(exchange) {
    try {
        let result = await exchange.getContractsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getContractsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Options Open Interest and Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-options-open-interest-and-volume>
{% endhint %}

#### Function name:

```javascript
getOptionsOiAndVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOptionsOiAndVolume(exchange) {
    try {
        let result = await exchange.getOptionsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOptionsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Put/Call Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-put-call-ratio>
{% endhint %}

#### Function name:

```javascript
getPutCallRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPutCallRatio(exchange) {
    try {
        let result = await exchange.getPutCallRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPutCallRatio(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Open Interest and Volume (expiry)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-expiry>
{% endhint %}

#### Function name:

```javascript
getOiAndVolumeExpiry()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeExpiry(exchange) {
    try {
        let result = await exchange.getOiAndVolumeExpiry();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeExpiry(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Open Interest and Volume (strike)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-strike>
{% endhint %}

#### Function name:

```javascript
getOiAndVolumeStrike()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeStrike(exchange) {
    try {
        let result = await exchange.getOiAndVolumeStrikegetOiAndVolumeStrike();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeStrike(myOkxAccount, 
{
    ccy: "BTC",
    expTime: "<get example>"
})
```

### Get Taker Flow

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-flow>
{% endhint %}

#### Function name:

```javascript
getTakerFlow()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerFlow(exchange) {
    try {
        let result = await exchange.getTakerFlow();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerFlow(myOkxAccount, 
{
    ccy: "BTC"
})
```
