Contract

Query product information

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-product-information

Function Name:

getProductInfo()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getProductInfo(myMainPhemexExchange);

Query server time

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-server-time

Function Name:

getServerTime()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getServerTime(myPhemexExchange);

Place order

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io/#place-order-http-put-prefered

Function Name:

placeOrderPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await placeOrderPerp(myPhemexExchange, {
        symbol: "BTCUSD",
        clOrdID: "nkluwnfkdddlnladad34o33sli4nfaao2m3",
        side: "Buy",
        orderQty: "2001",
        ordType: "Limit",
        priceEp: "100000000"
        });

Cancel order by order ID or client order ID

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#cancel-order-by-order-id-or-client-order-id

Function Name:

cancelOrderPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await cancelOrderPerp(myPhemexExchange, {
         symbol: "BTCUSD",
         orderID: "e31db900-ec06-47b4-97ee-c9018e22322f"
     });

Bulk cancel orders

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#bulk-cancel-orders

Function Name:

cancelBatchOrderPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await cancelBatchOrderPerp(myMainPhemexExchange, {
        symbol: "BTCUSDT",
        orderID: "234fsfs3,d2123dada2"
     });

Cancel all orders

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#cancel-all-orders

Function Name:

cancelAllOrdersPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await cancelAllOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query trading account and positions

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-trading-account-and-positions

Function Name:

getTradingAccountPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getTradingAccountPerp(myMainPhemexExchange, {
        currency: "USDT"
    });

Query trading account and positions with realtime unPnL

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-trading-account-and-positions-with-realtime-unpnl

Function Name:

getTradingAccountUnPnLPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getTradingAccountUnPnLPerp(myPhemexExchange, {
         currency: "BTC"
     });

Set leverage

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#set-leverage

Function Name:

setLeverage()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await setLeverage(myPhemexExchange, {
         symbol: "BTCUSD",
         leverage: "10"
     });

Set position risklimit

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#set-position-risklimit

Function Name:

setRiskLimit()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await setRiskLimit(myPhemexExchange, {
         symbol: "BTCUSD",
         riskLimit: "10"
     });

Assign position balance in isolated marign mode

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#assign-position-balance-in-isolated-marign-mode

Function Name:

assignPositionBalance()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await assignPositionBalance(myPhemexExchange, {
         symbol: "BTCUSD",
         posbalance: "10"
     });

Query open orders by symbol

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-open-orders-by-symbol

Function Name:

getOpenOrdersPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getOpenOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query closed orders by symbol

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-closed-orders-by-symbol

Function Name:

getClosedOrdersPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getClosedOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query user order by order ID or client order ID

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-user-order-by-order-id-or-client-order-id

Function Name:

getUserOrderPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getUserOrderPerp(myPhemexExchange, {
         symbol: "BTCUSD",
         orderID: "987515a0-3b56-4a9a-9f2e-48ecdd674f4a"
     });

Query user trade

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-user-trade

Function Name:

getUserTradePerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getUserTradePerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query order book

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-order-book

Function Name:

getOrderBook()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getOrderBook(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });

Query full order book

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-full-order-book

Function Name:

getOrderBookFull()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getOrderBookFull(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });

Query kline

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-kline

Function Name:

getKline()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getKline(myPhemexExchange, {
         symbol: "BTCUSD",
         resolution: "60"
     });

Query recent trades

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-recent-trades

Function Name:

getRecentTrades()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getRecentTrades(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });

Query 24 hours ticker

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-24-hours-ticker

Function Name:

get24HourTickerPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await get24HourTickerPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query 24 hours ticker for all symbols

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-24-hours-ticker-for-all-symbols

Function Name:

get24HourTickerAllSymbolsPerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await get24HourTickerAllSymbolsPerp(myPhemexExchange);

Query history trades by symbol

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-history-trades-by-symbol

Function Name:

getHistoryTradePerp()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getHistoryTradePerp(myPhemexExchange, {
         market: "BTCUSD"
     });

Query funding rate history

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-funding-rate-history

Function Name:

getFundingRateHistoryHedged()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getFundingRateHistoryHedged(myPhemexExchange, {symbol: ".ETHUSDTFR8H"});

Query funding fee history

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-funding-fee-history

Function Name:

getFundingFeeHistory()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getFundingFeeHistory(myPhemexExchange, {
         symbol: "BTCUSD"
     });

Query contract fee rate

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-contract-fee-rate

Function Name:

getContractFeeRate()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getContractFeeRate(myPhemexExchange, {
         settleCurrency: "BTC"
     });

Query Funds Detail

Please refer to the official Phemex API Docs for the Required parameters.

https://phemex-docs.github.io#query-funds-detail

Function Name:

getFundsDetail()

Usage:

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

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

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

let result = await getFundsDetail(myMainPhemexExchange);

Last updated