# GET /api/v1/pnl > Trading profit from the ledger: realised and unrealised on swaps and fills, first in first out, with the open lots and what is missing. Source: https://docs.getport.app/api/reference/pnl/ ## Example The key is read from `PORT_API_KEY`, so the command never prints it. ```sh curl -s https://getport.app/api/v1/pnl -H "Authorization: Bearer $PORT_API_KEY" ``` ## Response A 200 with the [envelope](https://docs.getport.app/api/#the-envelope) every endpoint answers, and this endpoint's answer in `data`. Amounts and USD figures are strings. What `data` looks like, with sample values: the shape is the schema's, checked when these pages are built, and the figures are made up, not anyone's port. ``` { "method": "FIFO", "realised30dUsd": "1204.55", "realisedYtdUsd": "8810.20", "unrealisedUsd": "216.00", "feesYtdUsd": "96.40", "fundingYtdUsd": "-210.75", "byMonth": [ { "month": "2026-09", "realisedUsd": "1204.55" } ], "byAsset": [ { "symbol": "ETH", "chainId": "ethereum", "realisedUsd": "1204.55" } ], "bySource": [ { "source": "swap", "share": 1 } ], "unrealisedByWallet": [ { "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "unrealisedUsd": "216.00" } ], "lots": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "symbol": "ETH", "tokenAddress": "native", "chainId": "ethereum", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "acquiredAt": "2026-08-14T10:02:00.000Z", "amount": "4.2", "costUsd": "9450.00", "unitCostUsd": "2250.00", "unitNowUsd": "2476.50", "unrealisedUsd": "951.30", "logoUrl": null } ], "trades": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "at": "2026-10-06T05:42:10.000Z", "action": "Sell", "symbol": "SOL", "amount": "25", "qty": "qty", "priceUsd": "228.40", "proceedsUsd": "5710.00", "realisedUsd": "1204.55", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "logoUrl": null } ], "fees": [ { "label": "Network fees", "detail": "Gas on 38 swaps", "usd": "42.10" } ], "trades30dCount": 1, "complete": true, "pricedEvents": 1, "unpricedEvents": 1, "unmatchedSales": 1, "unplacedMoves": 1, "income": { "events": 1, "valuedEvents": 1, "unvaluedEvents": 1, "ytdUsd": "0.00", "allUsd": "0.00", "rows": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "at": "2026-10-06T05:42:10.000Z", "kind": "staking", "symbol": "ETH", "chainId": "ethereum", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "amount": "0.012", "priceUsd": "2476.50", "usd": "29.72", "logoUrl": null } ] }, "hiddenByYou": { "tokens": 1, "lotCount": 1, "tradeCount": 1, "incomeCount": 1, "realisedYtdUsd": "8810.20", "unrealisedUsd": "216.00", "lots": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "symbol": "ETH", "tokenAddress": "native", "chainId": "ethereum", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "acquiredAt": "2026-08-14T10:02:00.000Z", "amount": "4.2", "costUsd": "9450.00", "unitCostUsd": "2250.00", "unitNowUsd": "2476.50", "unrealisedUsd": "951.30", "logoUrl": null } ], "trades": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "at": "2026-10-06T05:42:10.000Z", "action": "Sell", "symbol": "SOL", "amount": "25", "qty": "qty", "priceUsd": "228.40", "proceedsUsd": "5710.00", "realisedUsd": "1204.55", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "logoUrl": null } ], "income": [ { "id": "3f6c2a1e-8b7d-4e2f-9a1c-5d4b3e2f1a0c", "at": "2026-10-06T05:42:10.000Z", "kind": "staking", "symbol": "ETH", "chainId": "ethereum", "walletAddress": "0x8f3c0e7b2a91d4c6f5e3b2a1908d7c6b5a4fc21a", "amount": "0.012", "priceUsd": "2476.50", "usd": "29.72", "logoUrl": null } ] }, "viewableFrom": null } ``` | Field of `data` | Type | Always present | | -------------------- | ----------------------------------------- | -------------- | | `method` | `"FIFO" \| "LIFO" \| "HIFO" \| "average"` | yes | | `realised30dUsd` | `string` | yes | | `realisedYtdUsd` | `string` | yes | | `unrealisedUsd` | `string` | yes | | `feesYtdUsd` | `string` | yes | | `fundingYtdUsd` | `string` | yes | | `byMonth` | `array of object` | yes | | `byAsset` | `array of object` | yes | | `bySource` | `array of object` | yes | | `unrealisedByWallet` | `array of object` | no | | `lots` | `array of object` | yes | | `trades` | `array of object` | no | | `fees` | `array of object` | no | | `trades30dCount` | `integer` | no | | `complete` | `boolean` | no | | `pricedEvents` | `integer` | no | | `unpricedEvents` | `integer` | no | | `unmatchedSales` | `integer` | no | | `unplacedMoves` | `integer` | no | | `income` | `object` | no | | `hiddenByYou` | `object` | no | | `viewableFrom` | `string or null` | no | The whole schema of `data` As the OpenAPI document at [`https://getport.app/api/v1/openapi.json`](https://getport.app/api/v1/openapi.json) states it. Objects are left open, because a response only ever gains fields. ``` { "type": "object", "properties": { "method": { "type": "string", "enum": [ "FIFO", "LIFO", "HIFO", "average" ] }, "realised30dUsd": { "type": "string" }, "realisedYtdUsd": { "type": "string" }, "unrealisedUsd": { "type": "string" }, "feesYtdUsd": { "type": "string" }, "fundingYtdUsd": { "type": "string" }, "byMonth": { "type": "array", "items": { "type": "object", "properties": { "month": { "type": "string" }, "realisedUsd": { "type": "string" } }, "required": [ "month", "realisedUsd" ] } }, "byAsset": { "type": "array", "items": { "type": "object", "properties": { "symbol": { "type": "string" }, "chainId": { "type": "string" }, "realisedUsd": { "type": "string" } }, "required": [ "symbol", "chainId", "realisedUsd" ] } }, "bySource": { "type": "array", "items": { "type": "object", "properties": { "source": { "type": "string" }, "share": { "type": "number" } }, "required": [ "source", "share" ] } }, "unrealisedByWallet": { "type": "array", "items": { "type": "object", "properties": { "walletAddress": { "type": "string" }, "unrealisedUsd": { "type": "string" } }, "required": [ "walletAddress", "unrealisedUsd" ] } }, "lots": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "symbol": { "type": "string" }, "tokenAddress": { "type": "string" }, "chainId": { "type": "string" }, "walletAddress": { "type": "string" }, "acquiredAt": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "amount": { "type": "string" }, "costUsd": { "type": "string" }, "unitCostUsd": { "type": "string" }, "unitNowUsd": { "type": "string" }, "unrealisedUsd": { "type": "string" }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "symbol", "chainId", "walletAddress", "acquiredAt", "amount", "costUsd", "unitCostUsd", "unitNowUsd", "unrealisedUsd" ] } }, "trades": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "at": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "action": { "type": "string" }, "symbol": { "type": "string" }, "amount": { "type": [ "string", "null" ] }, "qty": { "type": [ "string", "null" ] }, "priceUsd": { "type": [ "string", "null" ] }, "proceedsUsd": { "type": "string" }, "realisedUsd": { "type": "string" }, "walletAddress": { "type": "string" }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "at", "action", "symbol", "amount", "priceUsd", "proceedsUsd", "realisedUsd", "walletAddress" ] } }, "fees": { "type": "array", "items": { "type": "object", "properties": { "label": { "type": "string" }, "detail": { "type": "string" }, "usd": { "type": "string" } }, "required": [ "label", "detail", "usd" ] } }, "trades30dCount": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "complete": { "type": "boolean" }, "pricedEvents": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "unpricedEvents": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "unmatchedSales": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "unplacedMoves": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "income": { "type": "object", "properties": { "events": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "valuedEvents": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "unvaluedEvents": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "ytdUsd": { "type": "string" }, "allUsd": { "type": "string" }, "rows": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "at": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "kind": { "type": "string" }, "symbol": { "type": "string" }, "chainId": { "type": "string" }, "walletAddress": { "type": "string" }, "amount": { "type": "string" }, "priceUsd": { "type": [ "string", "null" ] }, "usd": { "type": [ "string", "null" ] }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "at", "kind", "symbol", "chainId", "walletAddress", "amount", "priceUsd", "usd" ] } } }, "required": [ "events", "valuedEvents", "unvaluedEvents", "ytdUsd", "allUsd", "rows" ] }, "hiddenByYou": { "type": "object", "properties": { "tokens": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "lotCount": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "tradeCount": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "incomeCount": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "realisedYtdUsd": { "type": "string" }, "unrealisedUsd": { "type": "string" }, "lots": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "symbol": { "type": "string" }, "tokenAddress": { "type": "string" }, "chainId": { "type": "string" }, "walletAddress": { "type": "string" }, "acquiredAt": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "amount": { "type": "string" }, "costUsd": { "type": "string" }, "unitCostUsd": { "type": "string" }, "unitNowUsd": { "type": "string" }, "unrealisedUsd": { "type": "string" }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "symbol", "chainId", "walletAddress", "acquiredAt", "amount", "costUsd", "unitCostUsd", "unitNowUsd", "unrealisedUsd" ] } }, "trades": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "at": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "action": { "type": "string" }, "symbol": { "type": "string" }, "amount": { "type": [ "string", "null" ] }, "qty": { "type": [ "string", "null" ] }, "priceUsd": { "type": [ "string", "null" ] }, "proceedsUsd": { "type": "string" }, "realisedUsd": { "type": "string" }, "walletAddress": { "type": "string" }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "at", "action", "symbol", "amount", "priceUsd", "proceedsUsd", "realisedUsd", "walletAddress" ] } }, "income": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "at": { "type": "string", "format": "date-time", "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$" }, "kind": { "type": "string" }, "symbol": { "type": "string" }, "chainId": { "type": "string" }, "walletAddress": { "type": "string" }, "amount": { "type": "string" }, "priceUsd": { "type": [ "string", "null" ] }, "usd": { "type": [ "string", "null" ] }, "logoUrl": { "type": [ "string", "null" ] } }, "required": [ "id", "at", "kind", "symbol", "chainId", "walletAddress", "amount", "priceUsd", "usd" ] } } }, "required": [ "tokens", "lotCount", "tradeCount", "incomeCount", "realisedYtdUsd", "unrealisedUsd", "lots", "trades", "income" ] }, "viewableFrom": { "type": [ "string", "null" ] } }, "required": [ "method", "realised30dUsd", "realisedYtdUsd", "unrealisedUsd", "feesYtdUsd", "fundingYtdUsd", "byMonth", "byAsset", "bySource", "lots" ] } ``` ## From an agent The MCP tool `port_pnl` answers the same question ("how did my trades do, realised and unrealised") with the same figures, over the [MCP server](https://docs.getport.app/api/mcp/). ## Refusals Every endpoint shares three: `401` for a missing or dead key, `402` for an account whose plan has no API ("Agents, MCP and the API are on Pro+ and above."), and `429` past the minute or day limit. The [errors](https://docs.getport.app/api/#errors) section has each body.