Python

Table of Contents

Base URLs

BASE_URLS = {
    "TESTNET": "https://perps-tradeapi.kanalabs.io",
    "MAINNET": "https://perps-tradeapi.kana.trade"
}

NODE_URLS = {
    "TESTNET": "https://api.testnet.aptoslabs.com/v1",
    "MAINNET": "https://api.mainnet.aptoslabs.com/v1"
}

Authentication

All endpoints require an API key in the request headers:

Core Concepts

Profile Address

On-chain trades use a profile address rather than a wallet address. You can fetch it using the /getProfileAddress endpoint.

Endpoint: GET /getProfileAddress

Account Management

Get Wallet Balance

Retrieves the wallet balance for a given user address.

Endpoint: GET /getWalletAccountBalance

Get Profile Balance

Retrieves the profile balance snapshot for a given user address.

Endpoint: GET /getProfileBalanceSnapshot

Get Net Profile Balance

This endpoint returns the net profile balance, which includes both the available balance in trading account and any pending balances from closed positions on all markets.

Endpoint: GET /getNetProfileBalance

Deposit Funds

Deposits funds from wallet to trading profile.

Endpoint: GET /deposit

Withdraw Funds

Withdraws funds from trading profile to wallet for a specific market.

Endpoint: GET /withdrawSpecifiMarket

Market Data

Get Market Info

Retrieves information about a specific market.

Endpoint: GET /getMarketInfo

Get Market Price

Gets the current price for a specific market.

Endpoint: GET /getMarketPrice

Get Last Execution Price

Retrieves the last execution price for a market.

Endpoint: GET /getLastPlacedPrice

Get Perpetual Market Info

Retrieves information about perpetual assets, optionally filtered by market ID or base name.

Endpoint: GET /getPerpetualAssetsInfo

Get All Markets

Retrieves information about all available markets.

Endpoint: GET /getPerpetualAssetsInfo/allMarkets

Order Management

Place Limit Order

Places a limit order on the exchange.

Endpoint: GET /placeLimitOrder

Place Market Order

Places a market order on the exchange.

Endpoint: GET /placeMarketOrder

Place Multiple Orders

Places multiple orders in a single transaction.

Endpoint: POST /placeMultipleOrders

Cancel Multiple Orders

Cancels multiple orders in a single transaction.

Endpoint: POST /cancelMultipleOrders

Cancel and Place Multiple Orders

Cancels existing orders and places new ones in a single transaction.

Endpoint: POST /cancelAndPlaceMultipleOrders

Position Management

Get Positions

Retrieves current positions for a user, optionally filtered by market ID.

Endpoint: GET /getPositions

Update Take Profit

Updates the take profit price for a position.

Endpoint: GET /updateTakeProfit

Update Stop Loss

Updates the stop loss price for a position.

Endpoint: GET /updateStopLoss

Collapse Position

Closes a position immediately at market price.

Endpoint: GET /collapsePosition

Trade History

Get Open Orders

Retrieves all open orders for a user, optionally filtered by market ID.

Endpoint: GET /getOpenOrders

Get All Open Order Ids

Endpoint: GET /getAllOpenOrderIds

Get Order Status By Order Id

Endpoint: GET /getOrderStatusByOrderId

Get Order History

Retrieves order history for a user, optionally filtered by market ID.

Endpoint: GET /getOrderHistory

Get All Trades

Retrieves all trades for a specific market.

Endpoint: GET /getAllTrades

Get Fills

Retrieves fill history for a specific market and address within a time range.

Endpoint: GET /getFills

Get Order Status by Order ID

Retrieves the status of a specific order by its ID.

Endpoint: GET /getOrderStatusByOrderId

Get All Open Order IDs

Endpoint: GET /getAllOpenOrderIds

Retrieves all open order IDs for a user, optionally filtered by market ID.

Add Margin

Endpoint: GET /addMargin

Settle Pnl

This API returns a transaction payload used to manually (or automatically, on user interactions) refresh the user's position and settle the Pnl for a specific market, allowing the user to claim any unreleased Pnl.

Endpoint: GET /settlePnl

Utility Endpoints

Get Account APT Balance

Retrieves the APT balance for a user's account.

Endpoint: GET /getAccountAptBalance

Helper Types

Last updated