GET
/
portfolio
/
:portfolioId
/
pnl
curl --request GET \
  --url https://api.glider.fi/portfolio/:portfolioId/pnl \
  --header 'X-API-KEY: <api-key>'
{
  "success": true,
  "data": {
    "pnl": {
      "costBasis": {
        "[assetId]": {
          "amount": "<string>",
          "costBasisUsd": "<string>",
          "averagePrice": "<string>"
        }
      },
      "realizedPnl": {
        "[assetId]": {
          "amount": "<string>",
          "realizedPnlUsd": "<string>"
        }
      },
      "unrealizedPnl": {
        "[assetId]": {
          "amount": "<string>",
          "currentValueUsd": "<string>",
          "costBasisUsd": "<string>",
          "unrealizedPnlUsd": "<string>",
          "unrealizedPnlPercentage": "<string>"
        }
      },
      "trades": [
        {
          "id": "<string>",
          "timestamp": 123,
          "type": "<string>",
          "assetIn": {},
          "assetOut": {},
          "amountIn": "<string>",
          "amountOut": "<string>",
          "valueIn": "<string>",
          "valueOut": "<string>",
          "costBasis": "<string>",
          "realizedPnl": "<string>"
        }
      ],
      "summary": {
        "totalCostBasisUsd": "<string>",
        "totalRealizedPnlUsd": "<string>",
        "totalUnrealizedPnlUsd": "<string>",
        "totalPnlUsd": "<string>",
        "totalPnlPercentage": "<string>"
      }
    }
  },
  "NOT_FOUND": {},
  "UNAUTHORIZED": {},
  "FORBIDDEN": {}
}

This endpoint returns detailed performance metrics for a specific portfolio, including cost basis, realized profit/loss, and unrealized profit/loss information.

Path Parameters

portfolioId
string
required

The unique identifier of the portfolio

Query Parameters

includeTrades
boolean
default:"true"

Include per-trade performance data in the response

realtime
boolean
default:"false"

Use real-time market data for calculating unrealized profit/loss

Request Headers

X-API-KEY
string
required

Your API key

Response

success
boolean

Indicates if the request was successful

data
object

Example Request

curl -X GET "https://api.glider.fi/portfolio/port_1a2b3c4d5e6f/pnl?realtime=true" \
  -H "X-API-KEY: YOUR_API_KEY"

Example Response

{
  "success": true,
  "data": {
    "pnl": {
      "costBasis": {
        "usdc-usd-coin": {
          "amount": "500000000",
          "costBasisUsd": "500.00",
          "averagePrice": "1.00"
        },
        "weth-wrapped-ethereum": {
          "amount": "250000000000000000",
          "costBasisUsd": "500.00",
          "averagePrice": "2000.00"
        }
      },
      "realizedPnl": {
        "usdc-usd-coin": {
          "amount": "0",
          "realizedPnlUsd": "0.00"
        }
      },
      "unrealizedPnl": {
        "usdc-usd-coin": {
          "amount": "500000000",
          "currentValueUsd": "500.00",
          "costBasisUsd": "500.00",
          "unrealizedPnlUsd": "0.00",
          "unrealizedPnlPercentage": "0.00"
        },
        "weth-wrapped-ethereum": {
          "amount": "250000000000000000",
          "currentValueUsd": "550.00",
          "costBasisUsd": "500.00",
          "unrealizedPnlUsd": "50.00",
          "unrealizedPnlPercentage": "10.00"
        }
      },
      "summary": {
        "totalCostBasisUsd": "1000.00",
        "totalRealizedPnlUsd": "0.00",
        "totalUnrealizedPnlUsd": "50.00",
        "totalPnlUsd": "50.00",
        "totalPnlPercentage": "5.00"
      }
    }
  }
}

Error Codes

NOT_FOUND
404

The specified portfolio could not be found

UNAUTHORIZED
401

Invalid or missing API key

FORBIDDEN
403

The API key does not have permission to access this portfolio

Notes

  • Performance data is calculated based on the complete transaction history of the portfolio
  • Real-time pricing data can be enabled with the realtime parameter to get current unrealized PnL
  • Without real-time pricing, only realized PnL and cost basis data will be provided
  • The per-trade PnL calculations use FIFO (First In, First Out) accounting methodology