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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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)
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Copy getTransactionDetails ()
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Usage:
Copy 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
Function name:
Copy getCurrentPlanOrders ()
Usage:
Copy 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
Function name:
Copy getHistoryPlanOrders ()
Usage:
Copy 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"
});