# Market Data

API calls for market data functions do not require account authentication/authorization.

## Market Data

### Get Tickers

{% hint style="success" %}
This function is also included in "Common Functions" as getMarkets()
{% endhint %}

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

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

#### Function Name:

```javascript
getTickers()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getTickers(exchange, options) {
    try {
        let result = await exchange.getTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTickers(myOkxAccount,
<strong>{
</strong>    instType:"SWAP"
})
</code></pre>

### Get Ticker

{% hint style="success" %}
This function is also included in "Common Functions" as getMarket()
{% endhint %}

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

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

#### Function Name:

```javascript
getTicker()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getTicker(exchange, options) {
    try {
        let result = await exchange.getTicker(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTicker(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD-SWAP"
</strong>})
</code></pre>

### Get Index Tickers

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-tickers>
{% endhint %}

#### Function Name:

```javascript
getIndexTickers()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getIndexTickers(exchange, options) {
    try {
        let result = await exchange.getIndexTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexTickers(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT"
</strong>})
</code></pre>

### Get Order Book

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-order-book>
{% endhint %}

#### Function Name:

```javascript
getOrderBook()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getOrderBook(exchange, options) {
    try {
        let result = await exchange.getOrderBook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderBook(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT"
</strong>})
</code></pre>

### Get Candlesticks

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

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

#### Function Name:

```javascript
getCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getCandles(exchange, options) {
    try {
        let result = await exchange.getCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT-SWAP"
</strong>})
</code></pre>

### Get Candlesticks History

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-candlesticks-history>
{% endhint %}

#### Function Name:

```javascript
getCandleHistory()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getCandleHistory(exchange, options) {
    try {
        let result = await exchange.getCandleHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandleHistory(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT-SWAP"
</strong>})
</code></pre>

### Get Index Candlesticks

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getIndexCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getIndexCandles(exchange, options) {
    try {
        let result = await exchange.getIndexCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>})
</code></pre>

### Get Mark Price Candlesticks

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-mark-price-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getMarkPriceCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getMarkPriceCandles(exchange, options) {
    try {
        let result = await exchange.getMarkPriceCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarkPriceCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>})
</code></pre>

### Get Trades

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

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

#### Function Name:

```javascript
getTrades()
```

#### Usage:

<pre class="language-javascript"><code class="lang-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 getTrades(exchange, options) {
    try {
        let result = await exchange.getTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTrades(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>});
</code></pre>

### Get Trades History

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-trades-history>
{% endhint %}

#### Function Name:&#x20;

```javascript
getTradesHistory()
```

#### Usage:

```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 getTradesHistory(exchange, options) {
    try {
        let result = await exchange.getTradesHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTradesHistory(myOkxAccount,
{
    instId: "BTC-USDT"
});
```

### Get 24H Total Volume

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-24h-total-volume>
{% endhint %}

#### Function Name:&#x20;

```javascript
get24HrPlatformVolume()
```

#### Usage:

```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 get24HrPlatformVolume(exchange, options) {
    try {
        let result = await exchange.get24HrPlatformVolume(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await get24HrPlatformVolume(myOkxAccount);
```

### Get Oracle

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

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

#### Function Name:&#x20;

```javascript
getOracle()
```

#### Usage:

```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 getOracle(exchange, options) {
    try {
        let result = await exchange.getOracle(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOracle(myOkxAccount);
```

### Get Exchange Rate

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-exchange-rate>
{% endhint %}

#### Function Name:

```javascript
getExchangeRate()
```

#### 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 getExchangeRate(exchange, options) {
    try {
        let result = await exchange.getExchangeRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getExchangeRate(myOkxAccount);
```

### Get Index Components

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-components>
{% endhint %}

#### Function Name:

```javascript
getIndexComponents()
```

#### 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 getIndexComponents(exchange, options) {
    try {
        let result = await exchange.getIndexComponents(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexComponents(myOkxAccount,
{
    index: "BTC-USD"
});
```

### Get Block Tickers

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-tickers>
{% endhint %}

#### Function Name:

```javascript
getBlockTickers()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-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 getBlockTickers(exchange, options) {
    try {
        let result = await exchange.getBlockTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTickers(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Block Ticker

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-ticker>
{% endhint %}

#### Function Name:

```javascript
getBlockTicker()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-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 getBlockTicker(exchange, options) {
    try {
        let result = await exchange.getBlockTicker(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTicker(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USD-SWAP"
});
</code></pre>

### Get Block Trades

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

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-trades>
{% endhint %}

#### Function Name:

```javascript
getBlockTrades()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-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 getBlockTrades(exchange, options) {
    try {
        let result = await exchange.getBlockTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTrades(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USDT"
});
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.compendium.finance/pendax/using-pendax-sdk/okx-functions/market-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
