Portfolio API

Get Address Recent PnL List#

Get a list of recent PnL for an address in reverse chronological order

Limit: 1000 records, up to 100 per request

Request Path#

GET https://web3.okx.com/api/v6/dex/market/portfolio/recent-pnl

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier of the chain, pass the chain ID (e.g., 501 for Solana), only single-chain query is supported
walletAddressStringYesWallet address to query
cursorStringNoPagination cursor, pass the cursor value returned from the previous request
limitStringNoNumber of records per page, max 100

Response Parameters#

ParameterTypeDescription
cursorStringPagination cursor
pnlListArrayPnL list
>chainIndexStringUnique identifier of the chain
>tokenContractAddressStringToken contract address
>tokenSymbolStringToken symbol
>lastActiveTimestampStringLast active timestamp (milliseconds)
>unrealizedPnlUsdStringUnrealized PnL (USD), returns SELL_ALL if the address has sold all holdings
>unrealizedPnlPercentStringUnrealized PnL percentage
>realizedPnlUsdStringRealized PnL (USD)
>realizedPnlPercentStringRealized PnL percentage
>totalPnlUsdStringTotal PnL (USD)
>totalPnlPercentStringTotal PnL percentage
>tokenBalanceUsdStringToken balance value (USD)
>tokenBalanceAmountStringToken balance amount
>tokenPositionPercentStringToken position percentage
>tokenPositionDurationObjectToken position duration info
>>holdingTimestampStringHolding start timestamp (milliseconds)
>>sellOffTimestampStringSell-off timestamp (milliseconds), empty if still holding
>buyTxCountStringNumber of buy transactions
>buyTxVolumeStringBuy transaction volume
>buyAvgPriceStringAverage buy price
>sellTxCountStringNumber of sell transactions
>sellTxVolumeStringSell transaction volume
>sellAvgPriceStringAverage sell price

Request Example#

Shell
curl --location --request GET 'https://web3.okx.com/api/v6/dex/market/portfolio/recent-pnl?chainIndex=1&walletAddress=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&limit=10' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'

Response Example#

Json
{
    "code": "0",
    "data": {
        "pnlList": [
            {
                "chainIndex": "1",
                "tokenContractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                "tokenSymbol": "USDT",
                "lastActiveTimestamp": "1710000000000",
                "unrealizedPnlUsd": "100.00",
                "unrealizedPnlPercent": "10.00",
                "realizedPnlUsd": "200.00",
                "realizedPnlPercent": "20.00",
                "totalPnlUsd": "300.00",
                "totalPnlPercent": "30.00",
                "tokenBalanceUsd": "1000.00",
                "tokenBalanceAmount": "1000",
                "tokenPositionPercent": "10.00",
                "tokenPositionDuration": {
                    "holdingTimestamp": "1700000000000",
                    "sellOffTimestamp": ""
                },
                "buyTxCount": "5",
                "buyTxVolume": "900.00",
                "buyAvgPrice": "0.99",
                "sellTxCount": "2",
                "sellTxVolume": "400.00",
                "sellAvgPrice": "1.01"
            }
        ]
    },
    "msg": ""
}