Convert

Documentation on interacting with a variety of OKX Convert and Convert History API functions through the PENDAX SDK.

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

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-currencies

Function Name:

getConvertCurrencies()

Usage:

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

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

Function Name:

getConvertCurrencyPair()

Usage:

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

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-convert-estimate-quote

Function Name:

convertEstimateQuote()

Usage:

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

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-convert-convert-trade

Function Name:

convertTrade()

Usage:

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

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-history

Function Name:

getConvertHistory()

Usage:

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)

Last updated