Kana Perps Python REST API
1. Get Market Info
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getMarketInfoMethod:
GETQuery Parameters:
marketId(Required) - The ID of the market you want information about.
Example Request:
GET https://perps-tradeapi.kanalabs.io/getMarketInfo?marketId=66Example Response:
Status Code:
200 OKResponse Body:
{
"success": true,
"message": "Fetched market info successfully",
"data": [
{
"base_decimals": 8,
"base_name": "APT/USDC",
"counter": "0",
"creator_address": "0xb61d7b57333abf8ac036e752f19d0ba0c4baa5404db1cbf868c57dac3628f2bf",
"lot_size": "150000000",
"maintenance_margin": "250",
"market_address": "0x2b1c1f9288506541f5a9ad37b5071e100bf289a74d27801cb6d3dc92a2c5fcca",
"market_id": "301",
"max_leverage": "20",
"max_lots": "1500000",
"min_lots": "500",
"quote_decimals": 6,
"quote_precision": 3,
"tick_size": "1"
}
]
}Example Code to Fetch Market Information:
The following TypeScript/Node.js script demonstrates how to call the Get Market Info API using the axios library.
2. Get Wallet Account Balance
Method:
GETQuery Parameters:
marketId(Required) - The ID of the market you want information about.address (Required) - The wallet address for which the account balance is being fetched.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Wallet Account Balance Information:
The following TypeScript/Node.js script demonstrates how to call the Get Wallet Account Balance API using the axios library.
3. Get Trading Account Balance
Method:
GETQuery Parameters:
marketId(Required) - The ID of the market you want information about.address (Required) - The wallet address for which the account balance is being fetched.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Trading Account Balance Information:
The following TypeScript/Node.js script demonstrates how to call the Get Trading Account Balance API using the axios library.
4. Deposit
Endpoint URL:
https://perps-tradeapi.kanalabs.io/depositMethod:
GETQuery Parameters:
amount(Required) - The amount of the quote coin to deposit.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Depsoit a quote coin:
The following TypeScript/Node.js script demonstrates how to call the Get Deposit API using the axios library.
5. Withdraw
Endpoint URL:
https://perps-tradeapi.kanalabs.io/withdrawMethod:
GETQuery Parameters:
marketId(Required) - The ID of the market you want to withdraw.amount(Required) - The amount of the quote coin to withdraw.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Withdraw a quote coin:
The following TypeScript/Node.js script demonstrates how to call the Get Withdraw API using the axios library.
6. Place Limit Order
Endpoint URL:
https://perps-tradeapi.kanalabs.io/limitOrderMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market where the limit order will be placed.
tradeSide (Required) - Indicates the trade side:
truefor the long side.falsefor the short side.
direction (Required) - Indicates the direction of the trade:
falseto open a position.trueto close a position.
size (Required) - The size of the order.
price (Required) - The price at which the order is to be placed.
leverage (Required) - The leverage to be used for the order.
restriction - Specifies the type of order restriction. It is an optional parameter with a default value of
0. Possible values are:0-NO_RESTRICTION: Optionally fill as a taker, then post to the book as a maker.1-FILL_OR_ABORT: Abort if any size posts as a maker (only fill).3-POST_OR_ABORT: Abort if any size fills as a taker (only post).If
restrictionis not provided, it defaults to0. It can either be a number or left undefined.
takeProfit - The take profit value is optional. If not provided, it defaults to
0. It can either be a number or left undefined.stopLoss - The stop loss value is also optional. If not provided, it defaults to
0. It can either be a number or left undefined.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Place a limit order:
The following TypeScript/Node.js script demonstrates how to call the Get Place Limit Order API using the axios library.
7. Place Market Order
Endpoint URL:
https://perps-tradeapi.kanalabs.io/marketOrderMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market where the limit order will be placed.
tradeSide (Required) - Indicates the trade side:
truefor the long side.falsefor the short side.
direction (Required) - Indicates the direction of the trade:
falseto open a position.trueto close a position.
size (Required) - The size of the order.
leverage (Required) - The leverage to be used for the order.
takeProfit - The take profit value is optional. If not provided, it defaults to
0. It can either be a number or left undefined.stopLoss - The stop loss value is also optional. If not provided, it defaults to
0. It can either be a number or left undefined.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Place a market order:
The following TypeScript/Node.js script demonstrates how to call the Get Place Market Order API using the axios library.
8. Cancel Multiple Orders
Endpoint URL:
htps://perps-tradeapi.kanalabs.io/cancelMultipleOrdersMethod:
POSTRequest Body:
marketId: The ID of the market for which the orders will be canceled.
orderIds: A list of order IDs to cancel.
cancelTradeSides: The sides of the orders to cancel (true for long, false for short).
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Cancel multiple orders:
The following TypeScript/Node.js script demonstrates how to call the Post Cancel Multiple Orders API using the axios library.
8. Place Multiple Orders
Endpoint URL:
https://perps-tradeapi.kanalabs.io/placeMultipleOrdersMethod:
POST
Request Body :
marketId (Required) - The ID of the market where the orders will be placed.
orderTypes (Required) - An array of order types for each order:
true for limit orders.
false for market orders.
tradeSides (Required) - An array indicating the trade sides for each order:
true for long positions.
false for short positions.
directions (Required) - An array indicating the direction of each trade:
false to open a position.
true to close a position.
sizes (Required) - An array of sizes for each order.
leverages (Required) - An array of leverages for each order.
prices (Required) - An array of prices at which each order is to be placed.
restriction - Specifies the type of order restriction. It is an optional parameter with a default value of
0. Possible values are:0-NO_RESTRICTION: Optionally fill as a taker, then post to the book as a maker.1-FILL_OR_ABORT: Abort if any size posts as a maker (only fill).3-POST_OR_ABORT: Abort if any size fills as a taker (only post).If
restrictionis not provided, it defaults to0. It can either be a number or left undefined.
takeProfits - The take profit value is optional. If not provided, it defaults to
0. It can either be a number or left undefined.stopLosses - The stop loss value is also optional. If not provided, it defaults to
0. It can either be a number or left undefined.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Place a multiple orders:
The following TypeScript/Node.js script demonstrates how to call the Get Place Multiple Orders API using the axios library.
9. Cancel and Place Multiple Orders
Method:
POST
Request Body :
marketId (Required) - The ID of the market where the orders will be placed.
orderIds (Required) - An array of strings representing the IDs of the orders to be canceled.
cancelTradeSides (Required) - An array indicating the sides of the orders being canceled:
truefor long sides.falsefor short sides.
orderTypes (Required) - An array of order types for each order:
true for limit orders.
false for market orders.
orderTradeSides (Required) - An array indicating the trade sides for each order:
true for long positions.
false for short positions.
directions (Required) - An array indicating the direction of each trade:
false to open a position.
true to close a position.
sizes (Required) - An array of sizes for each order.
leverages (Required) - An array of leverages for each order.
prices (Required) - An array of prices at which each order is to be placed.
restriction - Specifies the type of order restriction. It is an optional parameter with a default value of
0. Possible values are:0-NO_RESTRICTION: Optionally fill as a taker, then post to the book as a maker.1-FILL_OR_ABORT: Abort if any size posts as a maker (only fill).3-POST_OR_ABORT: Abort if any size fills as a taker (only post).If
restrictionis not provided, it defaults to0. It can either be a number or left undefined
takeProfits - The take profit value is optional. If not provided, it defaults to
0. It can either be a number or left undefined.stopLosses - The stop loss value is also optional. If not provided, it defaults to
0. It can either be a number or left undefined.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to cancel and Place a multiple orders:
The following TypeScript/Node.js script demonstrates how to call the Get Cancel And Place Multiple Orders API using the axios library.
10. Get Open Orders
Endpoint URL:
https://perps-tradeapi.kanalabs.io/openOrdersMethod:
GETQuery Parameters:
address (Required) - The wallet address to retrieve open orders for.
marketId (Required) - The ID of the market to filter open orders.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Open Orders:
The following TypeScript/Node.js script demonstrates how to call the Get Open Orders API using the axios library.
11. Get Order History
Endpoint URL:
https://perps-tradeapi.kanalabs.io/orderHistoryMethod:
GETQuery Parameters:
address (Required) - The wallet address to retrieve the order history for.
marketId (Required) - The ID of the market to filter the order history.
offset (Optional) - The number of records to skip for pagination (default is
0if not provided).limit (Optional) - The maximum number of records to retrieve (default is
10if not provided).order (Optional) - The sorting order for the results. Options:
'asc'for ascending order.'desc'for descending order.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Order History:
The following TypeScript/Node.js script demonstrates how to call the Get Order History API using the axios library.
12. Get Open Position
Endpoint URL:
https://perps-tradeapi.kanalabs.io/viewPositionsMethod:
GETQuery Parameters:
address (Required) - The wallet address of the user to view positions for.
marketId (Required) - The ID of the market to filter the positions.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Open Position:
The following TypeScript/Node.js script demonstrates how to call the Get Open Position API using the axios library.
12. Get All Trades
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getAllTradesMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market to retrieve all trades information.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Open Position:
The following TypeScript/Node.js script demonstrates how to call the Get Open Position API using the axios library.
13. Get Order Status By Order Id
Method:
GETQuery Parameters:
marketId (Required) - The ID of the market associated with the order.
orderId (Required) - The unique identifier of the order to retrieve its status.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Order Status B Order Id:
The following TypeScript/Node.js script demonstrates how to call the Get Order Status By Order Id API using the axios library.
14. Get Fills
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getFillsMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market for which fills are retrieved.
address (Optional) - The address of the user to filter fills (if applicable).
from (Required) - The start time of the range in ISO 8601 format (e.g.,
2024-11-21T00:00:00Z).to (Required) - The end time of the range in ISO 8601 format (e.g.,
2024-11-21T23:59:59Z).orderId (Required) - The unique identifier of the order to retrieve its status.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Order Status B Order IdFills Data:
The following TypeScript/Node.js script demonstrates how to call the Get Fills Data API using the axios library.
14. Get Market Price
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getMarketPriceMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market for which the price information is being retrieved.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Market Price:
The following TypeScript/Node.js script demonstrates how to call the Get Market Price API using the axios library.
15. Get Last Execution Price
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getLastPlacedPriceMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market for which the last execution price information is being retrieved.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Last Execution Price:
The following TypeScript/Node.js script demonstrates how to call the Get Last Execution Price API using the axios library.
16. Get Open Order Ids
Endpoint URL:
https://perps-tradeapi.kanalabs.io/openOrderIdsMethod:
GETQuery Parameters:
address (Required) - The address associated with the orders.
marketId (Required) - The ID of the market for which open order IDs are being retrieved.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Open Order Ids:
The following TypeScript/Node.js script demonstrates how to call the Get Open Order Ids API using the axios library.
17. Update Take Profit
Endpoint URL: https://perps-tradeapi.kanalabs.io/updateTp
Method:
GETQuery Parameters:
marketId (Required) - The ID of the market for which the take profit values will be updated.
tradeSide (Required) - The trade side:
truefor the long side.falsefor the short side.
newTakeProfitPrice (Required) - The new take profit price to be set for the trade.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Update take profit price:
The following TypeScript/Node.js script demonstrates how to call the Get Update Take Profit Price API using the axios library.
18. Get Account Aptos Balance
Endpoint URL:
https://perps-tradeapi.kanalabs.io/getAccountAptBalanceMethod:
GETQuery Parameters:
marketId (Required) - The ID of the market for which the account's balance is being retrieved.
address (Required) - The address of the account whose balance will be
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Fetch Wallet Account Aptos Balance Information:
The following TypeScript/Node.js script demonstrates how to call the Get Wallet Account Aptos Balance API using the axios library.
19. Update Stop Loss
Endpoint URL: https://perps-tradeapi.kanalabs.io/updateSl
Method:
GETQuery Parameters:
marketId (Required) - The ID of the market for which the take profit values will be updated.
tradeSide (Required) - The trade side:
truefor the long side.falsefor the short side.
newStopLossPrice (Required) - The new stop loss price to be set for the trade.
Example Request:
Example Response:
Status Code:
200 OKResponse Body:
Example Code to Update stop loss price:
The following TypeScript/Node.js script demonstrates how to call the Get Update Stop Loss Price API using the axios library.
Last updated