# PnL By Market

## Get Prediction Market PnL by Market

> Get profit and loss breakdown for all traders in a specific prediction market.\
> Includes buy cost, sell proceeds, redemption values, and unrealized positions.\
> \
> \*\*What it helps to answer:\*\*\
> \
> 1\. \*\*Who are the biggest winners and losers in this market?\*\*\
> 2\. \*\*What is the PnL distribution across traders?\*\*\
> 3\. \*\*How much unrealized value exists in open positions?\*\*

```json
{"openapi":"3.1.0","info":{"title":"Nansen API","version":"1.0.0"},"servers":[{"url":"https://api.nansen.ai"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"apiKey","description":"API key for authentication"}},"schemas":{"PnlByMarketRequest":{"properties":{"market_id":{"type":"string","maxLength":100,"minLength":1,"title":"Market Id","description":"Polymarket market ID"},"pagination":{"$ref":"#/components/schemas/PaginationRequest"},"order_by":{"anyOf":[{"items":{"$ref":"#/components/schemas/SortOrder_PnlByMarketSortField_"},"type":"array"}],"title":"Order By","description":"Sort order"}},"additionalProperties":false,"type":"object","required":["market_id"],"title":"PnlByMarketRequest","description":"Request for PnL by market endpoint."},"PaginationRequest":{"properties":{"page":{"type":"integer","minimum":1,"title":"Page","description":"Page number (1-based)","default":1},"per_page":{"type":"integer","maximum":1000,"minimum":1,"title":"Per Page","description":"Number of records per page (max 1000)","default":10}},"type":"object","title":"PaginationRequest","description":"Pagination parameters for API requests."},"SortOrder_PnlByMarketSortField_":{"properties":{"field":{"$ref":"#/components/schemas/PnlByMarketSortField","description":"Field to sort by"},"direction":{"$ref":"#/components/schemas/SortDirection","description":"Sort direction (ASC or DESC)"}},"type":"object","required":["field","direction"],"title":"SortOrder[PnlByMarketSortField]"},"PnlByMarketSortField":{"type":"string","enum":["total_pnl_usd"],"title":"PnlByMarketSortField","description":"Sortable fields for PnL by market endpoint."},"SortDirection":{"type":"string","enum":["ASC","DESC"],"title":"SortDirection","description":"Enum for sort directions."},"PnlByMarketResponse":{"properties":{"pagination":{"$ref":"#/components/schemas/PaginationInfo"},"data":{"items":{"$ref":"#/components/schemas/PnlByMarketItem"},"type":"array","title":"Data","description":"List of PnL by market records"}},"type":"object","required":["data"],"title":"PnlByMarketResponse","description":"Response for PnL by market endpoint."},"PaginationInfo":{"properties":{"page":{"type":"integer","minimum":1,"title":"Page","description":"Current page number","default":1},"per_page":{"type":"integer","maximum":1000,"minimum":1,"title":"Per Page","description":"Number of records per page","default":10},"is_last_page":{"type":"boolean","title":"Is Last Page","description":"Whether this is the last page","default":true}},"type":"object","title":"PaginationInfo","description":"Pagination information for API responses."},"PnlByMarketItem":{"properties":{"address":{"anyOf":[{"type":"string"}],"title":"Address","description":"Trader address (hex)"},"owner_address":{"anyOf":[{"type":"string"}],"title":"Owner Address","description":"SAFE proxy owner address (hex)"},"side_held":{"anyOf":[{"type":"string"}],"title":"Side Held","description":"Side held: Yes, No, or Both. Reflects last known position even if fully exited (unrealized_value_usd = 0). Null only if no buy activity on record."},"net_buy_cost_usd":{"anyOf":[{"type":"number"}],"title":"Net Buy Cost Usd","description":"Net buy cost in USD"},"net_sell_proceeds_usd":{"anyOf":[{"type":"number"}],"title":"Net Sell Proceeds Usd","description":"Net sell proceeds in USD"},"redemption_value_usd":{"anyOf":[{"type":"number"}],"title":"Redemption Value Usd","description":"Redemption value in USD"},"unrealized_value_usd":{"anyOf":[{"type":"number"}],"title":"Unrealized Value Usd","description":"Unrealized value in USD"},"total_pnl_usd":{"anyOf":[{"type":"number"}],"title":"Total Pnl Usd","description":"Total PnL in USD"},"question":{"anyOf":[{"type":"string"}],"title":"Question","description":"Market question"},"event_id":{"anyOf":[{"type":"string"}],"title":"Event Id","description":"Parent event ID"},"event_title":{"anyOf":[{"type":"string"}],"title":"Event Title","description":"Parent event title"},"market_resolved":{"anyOf":[{"type":"boolean"}],"title":"Market Resolved","description":"Whether market is resolved"},"market_id":{"type":"string","title":"Market Id","description":"Market ID"}},"type":"object","required":["market_id"],"title":"PnlByMarketItem","description":"PnL by market data from ch_api_pm_pnl_by_market."}},"headers":{"XNansenCreditsUsed":{"description":"Number of credits consumed by this API request","schema":{"type":"string"}},"XNansenCreditsRemaining":{"description":"Total credits remaining in the user's account after this request","schema":{"type":"string"}},"RateLimitLimit":{"description":"Combined rate limit across all configured time windows","schema":{"type":"string"}},"RateLimitRemaining":{"description":"Number of requests remaining in the current limiting window","schema":{"type":"string"}},"RateLimitReset":{"description":"Time in seconds until the rate limit window resets","schema":{"type":"string"}},"XRateLimitLimitSecond":{"description":"Maximum requests allowed per second","schema":{"type":"string"}},"XRateLimitRemainingSecond":{"description":"Requests remaining in the current second","schema":{"type":"string"}},"XRateLimitLimitMinute":{"description":"Maximum requests allowed per minute","schema":{"type":"string"}},"XRateLimitRemainingMinute":{"description":"Requests remaining in the current minute","schema":{"type":"string"}},"RetryAfter":{"description":"Number of seconds to wait before making a new request","schema":{"type":"string"}}},"responses":{"BadRequestError":{"description":"Bad Request - Invalid request parameters or malformed request","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"UnauthorizedError":{"description":"Authentication error - No API key found in request","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"PaymentRequiredError":{"description":"Payment Required - This endpoint supports pay-per-request via the x402 protocol. The `Payment-Required` response header contains a base64-encoded JSON object describing accepted payment options (scheme, network, asset, amount, recipient). To pay, include a `Payment-Signature` header with a base64-encoded signed payment payload. See https://www.x402.org for protocol details.","headers":{"Payment-Required":{"description":"Base64-encoded JSON describing accepted payment options","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","description":"Empty object. Payment details are in the Payment-Required header."}}}},"ForbiddenError":{"description":"Forbidden - User does not have required subscription tier or has exceeded credit limit","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"NotFoundError":{"description":"Not Found - The requested resource was not found","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"ValidationError":{"description":"Validation error - Invalid request parameters","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"array","items":{"type":"object","properties":{"loc":{"type":"array","items":{"type":"string"}},"msg":{"type":"string"},"type":{"type":"string"}}}}}}}}},"TooManyRequestsError":{"description":"Too Many Requests - Rate limit exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"},"retry_after":{"type":"integer","description":"Seconds to wait before retrying"}}}}},"headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}}},"InternalServerError":{"description":"Internal Server Error - An unexpected error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}}}},"paths":{"/api/v1/prediction-market/pnl-by-market":{"post":{"tags":["Prediction Markets"],"summary":"Get Prediction Market PnL by Market","description":"Get profit and loss breakdown for all traders in a specific prediction market.\nIncludes buy cost, sell proceeds, redemption values, and unrealized positions.\n\n**What it helps to answer:**\n\n1. **Who are the biggest winners and losers in this market?**\n2. **What is the PnL distribution across traders?**\n3. **How much unrealized value exists in open positions?**","operationId":"get_prediction_market_pnl_by_market_api_v1_prediction_market_pnl_by_market_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PnlByMarketRequest"}}},"required":true},"responses":{"200":{"description":"PnL by market data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PnlByMarketResponse"}}},"headers":{"X-Nansen-Credits-Used":{"$ref":"#/components/headers/XNansenCreditsUsed"},"X-Nansen-Credits-Remaining":{"$ref":"#/components/headers/XNansenCreditsRemaining"},"RateLimit-Limit":{"$ref":"#/components/headers/RateLimitLimit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimitReset"},"X-RateLimit-Limit-Second":{"$ref":"#/components/headers/XRateLimitLimitSecond"},"X-RateLimit-Remaining-Second":{"$ref":"#/components/headers/XRateLimitRemainingSecond"},"X-RateLimit-Limit-Minute":{"$ref":"#/components/headers/XRateLimitLimitMinute"},"X-RateLimit-Remaining-Minute":{"$ref":"#/components/headers/XRateLimitRemainingMinute"}}},"400":{"description":"Bad Request","$ref":"#/components/responses/BadRequestError"},"401":{"description":"Unauthorized","$ref":"#/components/responses/UnauthorizedError"},"402":{"description":"Payment Required","$ref":"#/components/responses/PaymentRequiredError"},"403":{"description":"Forbidden","$ref":"#/components/responses/ForbiddenError"},"404":{"description":"Not Found","$ref":"#/components/responses/NotFoundError"},"422":{"description":"Unprocessable Content","$ref":"#/components/responses/ValidationError"},"429":{"description":"Too Many Requests","$ref":"#/components/responses/TooManyRequestsError"},"500":{"description":"Internal Server Error","$ref":"#/components/responses/InternalServerError"}}}}}}
```
