Links

Trade (Spot)

Documentation on interacting with Bitget's Spot Market Trading & Order API functions through the PENDAX Javascript SDK.
All Spot Market Trading & Order API endpoints require authentication. Please create Bitget API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post.

Place Order

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

Function name:

placeOrder(options)

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function placeOrder(exchange, options) {
try {
let result = await exchange.placeOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await placeOrder(myBitgetAccount,
{
symbol: 'BTCUSDT_SPBL',
side: 'buy',
orderType: 'market',
force: 'normal',
quantity: '10'
});

Batch Order

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

Function name:

placeBatchOrder()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function placeBatchOrder(exchange) {
try {
let result = await exchange.placeBatchOrder();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await placeBatchOrder(myBitgetAccount,
{
symbol: 'BTCUSDT_SPBL',
orderList: [{
symbol: 'BTCUSDT_SPBL',
side: 'buy',
orderType: 'market',
force: 'normal',
quantity: '10'
},
{
symbol: 'BTCUSDT_SPBL',
side: 'buy',
orderType: 'market',
force: 'normal',
quantity: '20'
}]
});

Cancel Order

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

Function name:

cancelOrder()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function cancelOrder(exchange) {
try {
let result = await exchange.getServerTime();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelOrder(bitget_exchange,
{
symbol:'BTCUSDT_SPBL',
orderId:'1002321893754589184'
})

Cancel Order in Batch (single instruments)

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

Function name:

cancelBatchOrders()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function cancelBatchOrders(exchange) {
try {
let result = await exchange.cancelBatchOrders();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelBatchOrders(bitget_exchange, {
symbol: 'BTCUSDT_SPBL',
orderIds: [
'111111111111111111',
'222222222222222222'
]
});

Get Order Details

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

Function name:

getOrderDetails()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getOrderDetails(exchange) {
try {
let result = await exchange.getServerTime();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOrderDetails(myBitgetAccount
{
symbol:'BTCUSDT_SPBL',
orderId:'1002341348069003264'
}
);

Get Order List

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

Function name:

getOrderList()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getOrderList(exchange) {
try {
let result = await exchange.getOrderList();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOrderList(bitget_exchange, {symbol: ""});

Get Order History

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

Function name:

getOrderHistory()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getOrderHistory(exchange) {
try {
let result = await exchange.getOrderHistory();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOrderHistory(myBitgetAccount,
{
symbol: 'BTCUSDT_SPBL'
}
);

Get Transaction Details

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

Function name:

getTransactionDetails()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getTransactionDetails(exchange) {
try {
let result = await exchange.getTransactionDetails();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTransactionDetails(myBitgetAccount,
{
"symbol: BTCUSDT_SPBL"
});

Place Plan Order

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

Function name:

placePlanOrder()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function placePlanOrder(exchange) {
try {
let result = await exchange.placePlanOrder();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await placePlanOrder(myBitgetAccount,
{
symbol: "BTCUSDT_SPBL",
side: "buy",
triggerPrice: "20000",
size: "20",
triggerType: "market_price",
orderType: "market"
});

Modify Plan Order

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

Function name:

modifyPlanOrder()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function modifyPlanOrder(exchange) {
try {
let result = await exchange.modifyPlanOrder();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await modifyPlanOrder(myBitgetAccount
{
orderId: "123456",
triggerPrice: "19999",
orderType: "market"
});

Cancel Plan Order

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

Function name:

cancelPlanOrder()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function cancelPlanOrder(exchange) {
try {
let result = await exchange.cancelPlanOrder();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelPlanOrder(myBitgetAccount,
{
orderId: "123456"
})

Get Current Plan Orders

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

Function name:

getCurrentPlanOrders()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getCurrentPlanOrders(exchange) {
try {
let result = await exchange.getCurrentPlanOrders();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getCurrentPlanOrders(myBitgetAccount,
{symbol: "BTCUSDT_SPBL"});

Get History Plan Orders

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

Function name:

getHistoryPlanOrders()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myBitgetAccount = createExchange({
exchange: "bitget",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "bitget",
marginType: "usdt"
});
async function getHistoryPlanOrders(exchange) {
try {
let result = await exchange.getHistoryPlanOrders();
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getHistoryPlanOrders(myBitgetAccount,
{
symbol: "BTCUSDT_SPBL",
pageSize: "20",
startTime: "1667889483000",
endTime: "1668134732000"
});