💻Common Functions
This page documents common functions across exchanges within the PENDAX SDK that developers can utilize while integrating.
Common functions are widely used calls available on different platforms and will work by just changing the "exchange" parameter and making edits to API credential layouts (depending on the selected exchange).
Some exchanges may not be included in common functions due to unique API layouts native to that platform. If a common function is not found here for your selected exchange then please visit that exchange's functions page.
Account Data
Get Balances
getBalances(options)Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Please refer to the official OKX API documentation for all available and/or required parameters to send.
OKX Example:
const exchange = createExchange({
exchange: "okx",
key: "jdsklsakh-76sruuu2",
secret: "GASDF45II@kkkk",
label: "okx", // any value
passphrase: "hhsgr$!kkks",
margintype: "usdt" // coin, usdt
});
// If no param passed, returns balances of all coins/assets, etc.
// To filter to specific assets, pass an object with a property 'tokens',
// where tokens is an array of asset names (see example)
const result =
try {
return await exchange.getBalances(
{
tokens: ['BTC', 'USD']
}
)
}
catch (err) {
console.log(err);
} ⚠️ FTX
Please refer to the official FTX API documentation for all available and/or required parameters to send.
FTX Example:
const exchange = createExchange({
exchange: "ftx",
authenticate: true,
key: "123455676890",
secret: "abcdefghijk",
subaccount: "subaccountname",
label: "ftx", // any value
});
// If no param passed, returns balances of all coins/assets, etc.
// To filter to specific assets, pass an object with a property 'tokens',
// where tokens is an array of asset names (see example)
const result =
try {
return await exchange.getBalances(
{
tokens: ['BTC', 'USD']
}
)
}
catch (err) {
console.log(err);
}
Trading
Place Order
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-trade-place-order
OKX Example
⚠️ FTX
Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#place-order
FTX Example
⚠️ FTX US
Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#place-order
FTX US Example
Cancel Order
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-order
OKX Example:
⚠️ FTX
Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#cancel-order
FTX Example:
⚠️ FTX US
Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.us/#cancel-order
FTX US Example:
Cancel All Orders
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
Not supported on OKX (Use combination of getLiveOrders() or the native getOrderList() and cancelMultiOrder() ) - WARNING - Okx rate-limits cancelMultiOrder() - see documents for details: https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-multiple-orders
⚠️ FTX
Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#cancel-all-orders
If no options are passed in, then all orders on the account will be canceled without regard to any other considerations.
FTX Example:
⚠️ FTX US
Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#cancel-all-orders
If no options are passed in, then all orders on the account will be canceled without regard to any other considerations.
FTX US Example:
Get Open Positions
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
OKX Example
⚠️ FTX
This is a hybrid function that calls api getBalances() and api getPositions(). It adds the ability to filter results by:
open or closed (does not affect balances)
markets (must contain an array of market names)
market type (spot or future - spot returns account balances, future returns account positions)
in addition, the boolean parameter 'showAvgPrice' is supported as shown in the FTX getPositions api document: https://docs.ftx.com/#get-positions
FTX Example:
Get Open Orders
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
Market Info
Get Markets
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Okx does not actually offer a getMarkets api. So this function calls api getTickers() twice. Once using parameter "SPOT", and once using parameter "SWAP". This returns markets for each in a combined format. If you want more detailed information you can call getTickers() directly, using the parameters detailed in the OKX api document. Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickers
OKX Example:
OKX Example with filtering:
OKX returns coins whether they are 'enabled' or not. An example of how to filter the results to include only enabled coins is below.
⚠️ FTX
Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#get-markets
FTX Example:
⚠️ FTX US
Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#get-markets
FTX US Example:
Get Market
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
OKX
Fetches details on a given market. Relays a call to endpoint getTicker(). Please refer to the official FTX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-market-data-get-ticker
OKX Example:
⚠️ FTX
Fetches details on a given market. Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#get-single-market
FTX Example:
⚠️ FTX US
Fetches details on a given market. Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.us/#get-single-market
Get Open Interest
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
Get Current Funding Rate
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
Get Next Funding Rate
Available Exchanges:
FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)
Last updated