> For the complete documentation index, see [llms.txt](https://docs.tokenbot.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokenbot.com/home/api-docs/graphql-api/queries.md).

# Queries

The GraphQL schema is **CLI-first and canonical**: the active query fields use `snake_case` `get_*` names. The camelCase, organization, passkey, onboarding, and metrics queries from the old web-dashboard era are still present in the executable schema but are **`@deprecated`** (dashboard sunset) and slated for removal in v2.0 — they are listed at the bottom of this page.

> Explore the live schema and every field with GraphiQL at `https://gql-api.tokenbot.com/graphql`.

Most `get_*` queries return a `success` / `data` / `error` envelope.

## Auth & User

### `me`

Get the authenticated user's profile.

```graphql
query {
  me {
    success
    data {
      id
      email
      email_verified
      is_active
      provider
      referral_code
      created_at
    }
  }
}
```

## Exchange Accounts

### `get_exchange_accounts`

List the caller's connected exchange accounts.

```graphql
query {
  get_exchange_accounts {
    success
    data {
      id
      exchange_name
      account_name
      trading_type
      is_active
      balance
      last_sync_at
    }
  }
}
```

### `get_exchange_account`

```graphql
query {
  get_exchange_account(id: "exc_123") {
    success
    data {
      id
      exchange_name
      permissions
      perpetual_capabilities
    }
  }
}
```

## Strategies

### `get_strategies`

```graphql
query {
  get_strategies {
    success
    data {
      id
      name
      exchange
      status
      is_active
      copiers { id name }
      totalTrades
      currentBalanceUSD
      balanceChange24h
    }
  }
}
```

## Copiers

### `get_copiers`

```graphql
query {
  get_copiers {
    success
    data {
      id
      name
      exchange
      status
      is_active
      strategy { id name }
      totalTrades
      currentBalanceUSD
    }
  }
}
```

## Trades

### `get_trades`

Accepts optional `filters`, `pagination`, `sortBy` (default `EXECUTED_AT`), and `sortOrder` (default `DESC`).

```graphql
query {
  get_trades {
    success
    data {
      id
      side
      type
      price
      amount
      fee
      status
      created_at
    }
  }
}
```

### `get_trade`

```graphql
query {
  get_trade(id: "trd_123") {
    success
    data {
      id
      side
      type
      price
      amount
      status
    }
  }
}
```

### `search_trades`

Full-text search across trades.

```graphql
query {
  search_trades(query: "BTC/USDT") {
    success
    data { id side price amount status }
  }
}
```

## Analytics

Aggregation queries backed by the trade partition store. Date ranges default to `MONTH`, grouping to `DAY`.

| Query                      | Args                                           | Returns                   |
| -------------------------- | ---------------------------------------------- | ------------------------- |
| `get_trade_analytics`      | `dateRange`, `groupBy`, `filters`              | `TradeAnalyticsResponse!` |
| `get_trade_summary`        | `dateRange`, `strategyId`, `exchangeAccountId` | `TradeSummaryResponse!`   |
| `get_strategy_performance` | `dateRange`, `strategyIds`                     | `[StrategyPerformance!]!` |
| `get_exchange_performance` | `dateRange`, `exchangeAccountIds`              | `[ExchangePerformance!]!` |
| `get_pnl_over_time`        | `dateRange`, `groupBy`, `strategyId`           | `[DailyPnL!]!`            |
| `get_trade_correlation`    | `strategyIds!`, `dateRange`                    | `JSON`                    |

```graphql
query {
  get_trade_summary(dateRange: MONTH) {
    success
    data { totalTrades winRate realizedPnlUSD }
  }
}
```

## Trade Pairs

### `get_trade_pairs`

```graphql
query {
  get_trade_pairs {
    success
    data { id symbol exchange }
  }
}
```

## Supported Exchanges

### `get_supported_exchanges`

```graphql
query {
  get_supported_exchanges {
    success
    data { id name }
  }
}
```

## Reward Types

### `get_reward_types`

```graphql
query {
  get_reward_types {
    success
    data { id name }
  }
}
```

## User Settings

### `get_user_setting`

```graphql
query {
  get_user_setting {
    success
    data { key value }
  }
}
```

## Withdrawals

### `get_withdraws` / `get_withdraw`

```graphql
query {
  get_withdraws {
    success
    data { id amount wallet_address status }
  }
}
```

```graphql
query {
  get_withdraw(id: "wd_123") {
    success
    data { id amount status }
  }
}
```

## API Keys & CLI Identity

| Query                    | Args                  | Returns                   |
| ------------------------ | --------------------- | ------------------------- |
| `validate_api_key`       | `key_hash: String!`   | `ValidateApiKeyResponse!` |
| `list_api_keys`          | —                     | `ApiKeyListResponse!`     |
| `cli_challenge`          | —                     | `CliChallenge!`           |
| `cli_identity_by_pubkey` | `public_key: String!` | `CliIdentity`             |

`cli_challenge` and `register_cli_identity` (mutation) back the `tokenbot init` registration flow; `cli_identity_by_pubkey` resolves a signed-request public key to its account.

## Admin

Admin queries require a system-admin identity (`is_system_admin`, or an active `admin` organization role). They are authorized per-resolver via `requireAdmin`.

### `adminGetDashboard`

System overview stats.

### `adminGetUsers`

```graphql
query {
  adminGetUsers(page: 1, limit: 20, search: "john") {
    id
    email
    is_active
    is_system_admin
  }
}
```

### `adminGetUser`

Detailed user info (`user_id: String!`).

### `adminGetAuditLogs`

Query the admin audit log (`admin_id`, `target_user_id`, `action`, `start_date`, `end_date`, `page`, `limit`).

### `tokenbot-admin` CLI surface (`admin_extended`)

These four queries (plus the `adminUpdateUser` / `adminBanUser` / `adminBulkUserAction` mutations) are the operations the internal `tokenbot-admin` CLI drives:

| Query                 | Args            | Returns                       |
| --------------------- | --------------- | ----------------------------- |
| `adminGetActivityLog` | `page`, `limit` | `ActivityLogResponse!`        |
| `adminGetStrategies`  | `page`, `limit` | `[Strategy!]!`                |
| `adminGetCopiers`     | `page`, `limit` | `[Copier!]!`                  |
| `adminGetLinks`       | —               | `[AdminStrategyCopierLink!]!` |

***

## Deprecated (dashboard-era) queries

These remain resolvable for backward compatibility but are `@deprecated` (web dashboard sunset, no active consumer) and will be removed in v2.0. Do not build new integrations on them:

* **Organizations:** `get_organizations`, `get_organization`, `get_user_organizations`, `get_organization_members`
* **Passkeys:** `userPasskeys`, `checkWebAuthnSupport`
* **Onboarding:** `getOnboardingStatus`, `shouldShowOnboarding`
* **Rewards / Notifications:** `get_user_reward`, `get_notification`
* **System / Metrics:** `systemVersion`, `adminGetApiKeys`, `adminGetSystemHealth`, `adminGetMetricsSummary`, `adminGetMetricsTimeSeries`, `adminGetSecurityAlerts`, `adminGetUsageTrends`, `adminGetMetricsBufferStats`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tokenbot.com/home/api-docs/graphql-api/queries.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
