# Convert

The API endpoints of `Convert` require authentication. Please start by creating an OKX API key. Only the assets in the funding account can be used for conversion.

## Convert

### Get Convert Currencies

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

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

#### Function Name:

```javascript
getConvertCurrencies()
```

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

const result = await getConvertCurrencies(myOkxAccount)
```

### Get Convert Currency Pair

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

<https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-currency-pair>
{% endhint %}

#### Function Name:

```javascript
getConvertCurrencyPair()
```

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

const result = await getConvertCurrencyPair(myOkxAccount,
{
        fromCcy: "USDT",
        toCcy: "BTC"
})
```

### Estimate Quote

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

<https://www.okx.com/docs-v5/en/#rest-api-convert-estimate-quote>
{% endhint %}

#### Function Name:

```javascript
convertEstimateQuote()
```

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

const result = await convertEstimateQuote(myOkxAccount,
{
    baseCcy: "ETH",
    quoteCcy: "USDT",
    side: "buy",
    rfqSz: "30",
    rfqSzCcy: "USDT"
}
)
```

### Convert Trade

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

<https://www.okx.com/docs-v5/en/#rest-api-convert-convert-trade>
{% endhint %}

#### Function Name:

```javascript
convertTrade()
```

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

const result = await convertTrade(myOkxAccount,
{
    baseCcy: "ETH",
    quoteCcy: "USDT",
    side: "buy",
    sz: "30",
    szCcy: "USDT",
    quoteId: "quoterETH-USDT16461885104612381"
}
)
```

### Get Convert History

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

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

#### Function Name:

```javascript
getConvertHistory()
```

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

const result = await getConvertHistory(myOkxAccount)
```


---

# 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/convert.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.
