Portfolio API

Get Address Latest PnL for Specific Token#

Get the latest income of the specified token of the address

Request Path#

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

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier of the chain, pass the chain ID (e.g., 501 for Solana)
walletAddressStringYesWallet address to query
tokenContractAddressStringYesToken contract address

Response Parameters#

ParameterTypeDescription
totalPnlUsdStringTotal PnL (USD)
totalPnlPercentStringTotal PnL percent
unrealizedPnlUsdStringUnrealized PnL (USD)
unrealizedPnlPercentStringUnrealized PnL percent
realizedPnlUsdStringRealized PnL (USD)
realizedPnlPercentStringRealized PnL percent
isPnlSupportedBooleanWhether PnL calculation is supported

Request Example#

Shell
curl --location --request GET 'https://web3.okx.com/api/v6/dex/market/portfolio/token/latest-pnl?chainIndex=1&walletAddress=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&tokenContractAddress=0xdac17f958d2ee523a2206206994597c13d831ec7' \
--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": {
        "totalPnlUsd": "1371.68",
        "totalPnlPercent": "20.22",
        "unrealizedPnlUsd": "685.4",
        "unrealizedPnlPercent": "10.11",
        "realizedPnlUsd": "-685.4",
        "realizedPnlPercent": "-10.11",
        "isPnlSupported": true
    }
}