> For the complete documentation index, see [llms.txt](https://docs.nekodex.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nekodex.org/nekodex-playground/docs-for-devs/api/subgraph.md).

# Subgraph

## Overview

Trading and other data is stored via The Graph. Query the subgraph using [GraphQL](https://thegraph.com/docs/en/querying/graphql-api/).

{% embed url="<https://subgraph.satsuma-prod.com/perp/lugia-optimism/playground>" %}

{% @github-files/github-code-block url="<https://github.com/perpetual-protocol/lugia-subgraph>" %}

## Examples

### `owedRealizedPnl`

Retrieve a trader's unrealized P\&L

```graphql
{
  traderProfiles(
    where: {
      trader:"0x6cf8aba4b2bc2cd9be2e78cf61ef617b02893502" // Lowercase only
      }
    )
  {
    owedRealizedPnl
    market {
      id
    }
  }
}
```
