> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agg.market/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Portfolio

> Read the signed-in user's activity feed and the app leaderboard. Positions and orders are on Order lifecycle.

Activity is the signed-in user (`x-app-id` and `Authorization: Bearer`). The leaderboard is the app (`x-app-id` only).

Positions and orders are poll targets on [Order lifecycle](/concepts/order-lifecycle): `GET /execution/positions` and `GET /execution/orders`. The UI is [Leaderboard](/components/pages/leaderboard-page).

For a profile screen, add [user avatars](/recipes/avatar-upload). For backend reporting across
all users in your app, use [Partner admin](/recipes/partner-admin) with a server API key.

## Activity

`type` is `trade`, `withdrawal`, `bridge`, `deposit`, `user_op`, or `redeem`.

<CodeGroup>
  ```ts SDK theme={null}
  const activity = await client.getUserActivity({ type: "trade", limit: 20 });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-id: $APP_ID" -H "Authorization: Bearer $ACCESS_TOKEN" \
    "$API/users/activity?type=trade&limit=20"
  ```
</CodeGroup>

Full shape on [Get user activity feed](/api-reference/portfolio/get-user-activity-feed).

## Leaderboard

`metric` is `realizedPnl` (default) or `volume`. `rank` is exact inside the top 100 and null after that. Pass exactly one of `userId`, `externalId`, `username`, or `walletAddress` to look up one user.

<CodeGroup>
  ```ts SDK theme={null}
  const board = await client.getLeaderboard({ metric: "realizedPnl", limit: 20 });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-id: $APP_ID" \
    "$API/leaderboard?metric=realizedPnl&limit=20"
  ```
</CodeGroup>

Full shape on [Trader leaderboard](/api-reference/portfolio/trader-leaderboard).

## One user's P\&L over time

`GET /leaderboard/series` returns one user's daily `orders`, `volume`, `spent`, `realizedPnl`, and a running `cumulativeRealizedPnl`, oldest first. Pass exactly one of `userId`, `externalId`, `username`, or `walletAddress`. The default range is the last 30 days, and the maximum is 366. Days with no activity return `0`. Unrealized P\&L on open positions is not included.

<CodeGroup>
  ```ts SDK theme={null}
  const series = await client.getLeaderboardSeries({ externalId, from: "2026-09-01" });
  ```

  ```bash cURL theme={null}
  curl -s -H "x-app-id: $APP_ID" \
    "$API/leaderboard/series?externalId=$EXTERNAL_ID&from=2026-09-01"
  ```
</CodeGroup>

Full shape on [Trader leaderboard series](/api-reference/portfolio/trader-leaderboard-series).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.