> For the complete documentation index, see [llms.txt](https://docs.lighter.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lighter.xyz/api/orders/aggregatedtrades.md).

# aggregatedTrades

Returns an account's fills grouped by order, with separate entries for each trade type and maker/taker role. Each entry includes total filled size, notional, average price, fees, realized PnL and first/last fill details. Use `trades` for individual fills.

This guide covers Lighter mainnet. The endpoint does not require an authentication token.

`GET https://mainnet.zklighter.elliot.ai/api/v1/aggregatedTrades`

#### Query parameters

| Name              | Type       | Required | Default     | Description                                                                                                                 |
| ----------------- | ---------- | -------- | ----------- | --------------------------------------------------------------------------------------------------------------------------- |
| `account_index`   | int64      | yes      | –           | Account to query.                                                                                                           |
| `market_id`       | int64      | no       | `255` (all) | Filter by market.                                                                                                           |
| `market_type`     | string     | no       | all         | `perps`, `spot`, `bo`. Comma-separated for several, e.g. `perps,spot`.                                                      |
| `order_index_str` | string     | no       | –           | Return only this order (order index as a string).                                                                           |
| `ask_filter`      | int8       | no       | `-1`        | `-1` both sides, `0` buys only, `1` sells only.                                                                             |
| `role`            | string     | no       | both        | `maker` or `taker`.                                                                                                         |
| `type`            | string     | no       | all         | `trade`, `liquidation`, `deleverage`, `market_settlement`. Note the underscore here; the response uses `market-settlement`. |
| `start_timestamp` | int64 (ms) | no       | –           | **Inclusive** lower bound on the stored order aggregate's last fill time.                                                   |
| `end_timestamp`   | int64 (ms) | no       | –           | **Exclusive** upper bound on the stored order aggregate's last fill time.                                                   |
| `limit`           | int64      | no       | `100`       | Number of orders per page, `1`–`1000`.                                                                                      |
| `cursor`          | string     | no       | –           | `next_cursor` from the previous response.                                                                                   |

Timestamp rules:

* Both must be on or after the exchange start (Jan 17, 2025 UTC = `1737072000000`).
* If both are set, `start_timestamp` must be less than `end_timestamp`.
* Filtering selects stored order aggregates by their last fill time. It does not trim their individual fills to the requested window.
* Results are then split by trade type and maker/taker role. Each returned entry's `first_timestamp` and `last_timestamp` describe that subgroup, so they need not both fall inside the requested window.
* Omitting either timestamp leaves that side of the window unbounded.

#### Response

Illustrative response:

```json
{
  "code": 200,
  "next_cursor": "eyJ2ZXJzaW9uIjoxLCJ0cmFkZV9pZCI6MzgxODIxMDg1NTR9",
  "trades": [
    {
      "account_index": 281474976710654,
      "order_id": "36591746915350675",
      "grouping_id": "36591746915350675",
      "master_twap_id": null,
      "market_id": 128,
      "market_symbol": "SPY",
      "market_kind": "perps",
      "is_ask": false,
      "type": "trade",
      "role": "maker",
      "first_trade_id": "38173459320",
      "last_trade_id": "38182108554",
      "first_timestamp": 1793807287488,
      "last_timestamp": 1793808698879,
      "first_block_height": 374940593,
      "last_block_height": 374991730,
      "fill_count": 116,
      "size": "101.0104",
      "usd_amount": "77395.189111",
      "pnl": null,
      "average_price": "766.21",
      "fee": "2.438882286892",
      "integrator_fee": "0.000000000000",
      "fee_asset_id": 3,
      "position_size_before": "2314.8726",
      "entry_quote_before": "1778329.357642",
      "position_sign_changed": false,
      "initial_margin_fraction_before": 500,
      "allocated_margin_usdc_before": 0,
      "allocated_margin_usdc_after": 0
    }
  ]
}
```

| Field                                                         | Description                                                                                                                                                                                      |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `account_index`                                               | Queried account.                                                                                                                                                                                 |
| `order_id`                                                    | Order index as a string; `"0"` can represent a synthetic entry without a normal order ID.                                                                                                        |
| `grouping_id`                                                 | Stored grouping identifier returned by the indexer, or `null`. Treat it as opaque; use `order_id` to identify the order.                                                                         |
| `master_twap_id`                                              | Parent TWAP order id if the order is a TWAP child, else `null`.                                                                                                                                  |
| `market_id`, `market_symbol`                                  | Market.                                                                                                                                                                                          |
| `market_kind`                                                 | `perps`, `spot` or `bo`.                                                                                                                                                                         |
| `is_ask`                                                      | `true` = sell, `false` = buy.                                                                                                                                                                    |
| `type`                                                        | `trade`, `liquidation`, `deleverage`, `market-settlement`.                                                                                                                                       |
| `role`                                                        | `maker` or `taker`.                                                                                                                                                                              |
| `first_trade_id`, `last_trade_id`                             | First / last fill in this trade-type and role subgroup (strings).                                                                                                                                |
| `first_timestamp`, `last_timestamp`                           | First / last fill time in this subgroup, in Unix milliseconds.                                                                                                                                   |
| `first_block_height`, `last_block_height`                     | First / last fill block in this subgroup.                                                                                                                                                        |
| `fill_count`                                                  | Number of fills aggregated in this subgroup.                                                                                                                                                     |
| `size`                                                        | Total filled base size.                                                                                                                                                                          |
| `usd_amount`                                                  | Total filled notional, USDC.                                                                                                                                                                     |
| `average_price`                                               | Size-weighted average fill price.                                                                                                                                                                |
| `pnl`                                                         | Realized PnL from these fills, USDC; `null` if the fills didn't reduce a position.                                                                                                               |
| `fee`                                                         | Total fee paid, in `fee_asset_id` units (USDC, or the base asset for spot buys).                                                                                                                 |
| `integrator_fee`                                              | Total integrator fee, same units as `fee`.                                                                                                                                                       |
| `fee_asset_id`                                                | Asset the fee is charged in (`3` = USDC).                                                                                                                                                        |
| `position_size_before`, `entry_quote_before`                  | Position size and entry quote before the first fill in this subgroup; `null` when unavailable.                                                                                                   |
| `position_sign_changed`                                       | Whether the position sign before the first fill differs from the sign after the last fill in this subgroup, including opening from or closing to zero; `null` when position data is unavailable. |
| `initial_margin_fraction_before`                              | Initial margin fraction before the first fill (`500` = 5%).                                                                                                                                      |
| `allocated_margin_usdc_before`, `allocated_margin_usdc_after` | Isolated-margin allocation before the first / after the last fill (raw integer, same format as `*_allocated_margin_usdc_*` in `trades`).                                                         |

#### Pagination

* Stored order aggregates are selected by their overall last trade ID, newest first. Within each order, returned trade-type/role entries are sorted by their own last trade IDs. The flattened response is not necessarily globally sorted by each entry's `last_trade_id`.
* If more orders exist, the response includes `next_cursor`. Pass it as `cursor` with the same filters to get the next page. When `next_cursor` is missing, you've reached the end.
* `limit` counts **orders**. If one order has fills of different `role` or `type` (e.g. part maker, part taker), it comes back as one entry per role/type, so `trades` can contain more entries than `limit`.
* Orders still receiving fills can move between requests. A fixed `end_timestamp` bounds the query but does not freeze the aggregates or guarantee a stable snapshot. For exports, reconcile overlapping queries using order and fill identifiers. Synthetic entries can share order\_id 0, so do not deduplicate on order\_id alone.

#### Errors

| Code    | Message                                                                                | Cause                                                                              |
| ------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `20001` | `invalid param`                                                                        | Bad or out-of-range parameter (e.g. `limit` > 1000, unknown `type`/`market_type`). |
| `20001` | `invalid param : timestamps must be on or after exchange start (January 17, 2025 UTC)` | `start_timestamp` / `end_timestamp` before `1737072000000`.                        |
| `20001` | `invalid param : start_timestamp must be less than end_timestamp`                      | Empty or inverted window.                                                          |
| `20001` | `invalid param : invalid order_index_str`                                              | Non-numeric or ≤ 0 order index.                                                    |
| `20009` | `invalid cursor`                                                                       | Malformed cursor.                                                                  |
| `21100` | `account not found: <index>`                                                           | Unknown `account_index`.                                                           |

#### Examples

A one-hour window for one account, maximum page size:

```
GET /api/v1/aggregatedTrades?account_index=220807&start_timestamp=1793805000000&end_timestamp=1793808600000&limit=1000
```

Perps + spot taker fills on one market:

```
GET /api/v1/aggregatedTrades?account_index=220807&market_id=1&market_type=perps,spot&role=taker
```

Next page of the same one-hour query (keep both timestamp filters):

```
GET /api/v1/aggregatedTrades?account_index=220807&start_timestamp=1793805000000&end_timestamp=1793808600000&limit=1000&cursor=<URL-encoded next_cursor>
```

For the generated endpoint reference, see [aggregatedTrades](https://docs.lighter.xyz/api/orders/aggregatedtrades).

````json
{"openapi":"3.0.0","info":{"title":"Lighter API","version":"1.0.0"},"tags":[{"name":"orders"}],"servers":[{"url":"https://mainnet.zklighter.elliot.ai","description":"Lighter mainnet"}],"security":[],"paths":{"/api/v1/aggregatedTrades":{"get":{"summary":"aggregatedTrades","operationId":"aggregatedTrades","tags":["orders"],"description":"Returns an account's fills grouped by order, with separate entries for each trade type and maker/taker role. Each entry includes total filled size, notional, average price, fees, realized PnL and first/last fill details. Use `trades` for individual fills.\n\nThis guide covers Lighter mainnet. The endpoint does not require an authentication token.\n\n`GET https://mainnet.zklighter.elliot.ai/api/v1/aggregatedTrades`\n\n### Query parameters\n\n| Name | Type | Required | Default | Description |\n|---|---|---|---|---|\n| `account_index` | int64 | yes | – | Account to query. |\n| `market_id` | int64 | no | `255` (all) | Filter by market. |\n| `market_type` | string | no | all | `perps`, `spot`, `bo`. Comma-separated for several, e.g. `perps,spot`. |\n| `order_index_str` | string | no | – | Return only this order (order index as a string). |\n| `ask_filter` | int8 | no | `-1` | `-1` both sides, `0` buys only, `1` sells only. |\n| `role` | string | no | both | `maker` or `taker`. |\n| `type` | string | no | all | `trade`, `liquidation`, `deleverage`, `market_settlement`. Note the underscore here; the response uses `market-settlement`. |\n| `start_timestamp` | int64 (ms) | no | – | **Inclusive** lower bound on the stored order aggregate's last fill time. |\n| `end_timestamp` | int64 (ms) | no | – | **Exclusive** upper bound on the stored order aggregate's last fill time. |\n| `limit` | int64 | no | `100` | Number of orders per page, `1`–`1000`. |\n| `cursor` | string | no | – | `next_cursor` from the previous response. |\n\nTimestamp rules:\n- Both must be on or after the exchange start (Jan 17, 2025 UTC = `1737072000000`).\n- If both are set, `start_timestamp` must be less than `end_timestamp`.\n- Filtering selects stored order aggregates by their last fill time. It does not trim their individual fills to the requested window.\n- Results are then split by trade type and maker/taker role. Each returned entry's `first_timestamp` and `last_timestamp` describe that subgroup, so they need not both fall inside the requested window.\n- Omitting either timestamp leaves that side of the window unbounded.\n\n### Response\n\nIllustrative response:\n\n```json\n{\n  \"code\": 200,\n  \"next_cursor\": \"eyJ2ZXJzaW9uIjoxLCJ0cmFkZV9pZCI6MzgxODIxMDg1NTR9\",\n  \"trades\": [\n    {\n      \"account_index\": 281474976710654,\n      \"order_id\": \"36591746915350675\",\n      \"grouping_id\": \"36591746915350675\",\n      \"master_twap_id\": null,\n      \"market_id\": 128,\n      \"market_symbol\": \"SPY\",\n      \"market_kind\": \"perps\",\n      \"is_ask\": false,\n      \"type\": \"trade\",\n      \"role\": \"maker\",\n      \"first_trade_id\": \"38173459320\",\n      \"last_trade_id\": \"38182108554\",\n      \"first_timestamp\": 1793807287488,\n      \"last_timestamp\": 1793808698879,\n      \"first_block_height\": 374940593,\n      \"last_block_height\": 374991730,\n      \"fill_count\": 116,\n      \"size\": \"101.0104\",\n      \"usd_amount\": \"77395.189111\",\n      \"pnl\": null,\n      \"average_price\": \"766.21\",\n      \"fee\": \"2.438882286892\",\n      \"integrator_fee\": \"0.000000000000\",\n      \"fee_asset_id\": 3,\n      \"position_size_before\": \"2314.8726\",\n      \"entry_quote_before\": \"1778329.357642\",\n      \"position_sign_changed\": false,\n      \"initial_margin_fraction_before\": 500,\n      \"allocated_margin_usdc_before\": 0,\n      \"allocated_margin_usdc_after\": 0\n    }\n  ]\n}\n```\n\n| Field | Description |\n|---|---|\n| `account_index` | Queried account. |\n| `order_id` | Order index as a string; `\"0\"` can represent a synthetic entry without a normal order ID. |\n| `grouping_id` | Stored grouping identifier returned by the indexer, or `null`. Treat it as opaque; use `order_id` to identify the order. |\n| `master_twap_id` | Parent TWAP order id if the order is a TWAP child, else `null`. |\n| `market_id`, `market_symbol` | Market. |\n| `market_kind` | `perps`, `spot` or `bo`. |\n| `is_ask` | `true` = sell, `false` = buy. |\n| `type` | `trade`, `liquidation`, `deleverage`, `market-settlement`. |\n| `role` | `maker` or `taker`. |\n| `first_trade_id`, `last_trade_id` | First / last fill in this trade-type and role subgroup (strings). |\n| `first_timestamp`, `last_timestamp` | First / last fill time in this subgroup, in Unix milliseconds. |\n| `first_block_height`, `last_block_height` | First / last fill block in this subgroup. |\n| `fill_count` | Number of fills aggregated in this subgroup. |\n| `size` | Total filled base size. |\n| `usd_amount` | Total filled notional, USDC. |\n| `average_price` | Size-weighted average fill price. |\n| `pnl` | Realized PnL from these fills, USDC; `null` if the fills didn't reduce a position. |\n| `fee` | Total fee paid, in `fee_asset_id` units (USDC, or the base asset for spot buys). |\n| `integrator_fee` | Total integrator fee, same units as `fee`. |\n| `fee_asset_id` | Asset the fee is charged in (`3` = USDC). |\n| `position_size_before`, `entry_quote_before` | Position size and entry quote before the first fill in this subgroup; `null` when unavailable. |\n| `position_sign_changed` | Whether the position sign before the first fill differs from the sign after the last fill in this subgroup, including opening from or closing to zero; `null` when position data is unavailable. |\n| `initial_margin_fraction_before` | Initial margin fraction before the first fill (`500` = 5%). |\n| `allocated_margin_usdc_before`, `allocated_margin_usdc_after` | Isolated-margin allocation before the first / after the last fill (raw integer, same format as `*_allocated_margin_usdc_*` in `trades`). |\n\n### Pagination\n\n- Stored order aggregates are selected by their overall last trade ID, newest first. Within each order, returned trade-type/role entries are sorted by their own last trade IDs. The flattened response is not necessarily globally sorted by each entry's `last_trade_id`.\n- If more orders exist, the response includes `next_cursor`. Pass it as `cursor` with the same filters to get the next page. When `next_cursor` is missing, you've reached the end.\n- `limit` counts **orders**. If one order has fills of different `role` or `type` (e.g. part maker, part taker), it comes back as one entry per role/type, so `trades` can contain more entries than `limit`.\n- Orders still receiving fills can move between requests. A fixed `end_timestamp` bounds the query but does not freeze the aggregates or guarantee a stable snapshot. For exports, reconcile overlapping queries using order and fill identifiers. Synthetic entries can share order_id 0, so do not deduplicate on order_id alone.\n\n### Errors\n\n| Code | Message | Cause |\n|---|---|---|\n| `20001` | `invalid param` | Bad or out-of-range parameter (e.g. `limit` > 1000, unknown `type`/`market_type`). |\n| `20001` | `invalid param : timestamps must be on or after exchange start (January 17, 2025 UTC)` | `start_timestamp` / `end_timestamp` before `1737072000000`. |\n| `20001` | `invalid param : start_timestamp must be less than end_timestamp` | Empty or inverted window. |\n| `20001` | `invalid param : invalid order_index_str` | Non-numeric or ≤ 0 order index. |\n| `20009` | `invalid cursor` | Malformed cursor. |\n| `21100` | `account not found: <index>` | Unknown `account_index`. |\n\n### Examples\n\nA one-hour window for one account, maximum page size:\n```\nGET /api/v1/aggregatedTrades?account_index=220807&start_timestamp=1793805000000&end_timestamp=1793808600000&limit=1000\n```\n\nPerps + spot taker fills on one market:\n```\nGET /api/v1/aggregatedTrades?account_index=220807&market_id=1&market_type=perps,spot&role=taker\n```\n\nNext page of the same one-hour query (keep both timestamp filters):\n```\nGET /api/v1/aggregatedTrades?account_index=220807&start_timestamp=1793805000000&end_timestamp=1793808600000&limit=1000&cursor=<URL-encoded next_cursor>\n```\n\nFor the generated endpoint reference, see [aggregatedTrades](https://docs.lighter.xyz/api/orders/aggregatedtrades).","parameters":[{"name":"account_index","in":"query","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"description":"Account to query."},{"name":"market_id","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":255,"minimum":0},"description":"Filter by market."},{"name":"market_type","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","enum":["spot","perps","bo"]}},"description":"`perps`, `spot`, `bo`. Comma-separated for several, e.g. `perps,spot`.","style":"form","explode":false},{"name":"order_index_str","in":"query","required":false,"schema":{"type":"string"},"description":"Return only this order (order index as a string). Must parse as a positive signed 64-bit integer."},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"`next_cursor` from the previous response."},{"name":"ask_filter","in":"query","required":false,"schema":{"type":"integer","format":"int8","default":-1,"minimum":-1,"maximum":1},"description":"`-1` both sides, `0` buys only, `1` sells only."},{"name":"role","in":"query","required":false,"schema":{"type":"string","enum":["maker","taker"]},"description":"`maker` or `taker`."},{"name":"type","in":"query","required":false,"schema":{"type":"string","enum":["trade","liquidation","deleverage","market_settlement"]},"description":"`trade`, `liquidation`, `deleverage`, `market_settlement`. Note the underscore here; the response uses `market-settlement`."},{"name":"start_timestamp","in":"query","required":false,"schema":{"type":"integer","format":"int64","minimum":1737072000000},"description":"**Inclusive** lower bound on the stored order aggregate's last fill time."},{"name":"end_timestamp","in":"query","required":false,"schema":{"type":"integer","format":"int64","minimum":1737072000000},"description":"**Exclusive** upper bound on the stored order aggregate's last fill time."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","format":"int64","default":100,"minimum":1,"maximum":1000},"description":"Number of orders per page, `1`–`1000`."}],"responses":{"200":{"description":"Successful response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregatedTrades"}}}},"400":{"description":"Invalid query or cursor, or account not found; see the error table.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultCode"}}}}}}}},"components":{"schemas":{"AggregatedTrades":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"},"next_cursor":{"type":"string","description":"Opaque cursor for the next page; absent at the end. Keep all filters unchanged and URL-encode it."},"trades":{"type":"array","items":{"$ref":"#/components/schemas/AggregatedTrade"}}},"title":"AggregatedTrades","required":["code","trades"]},"AggregatedTrade":{"type":"object","properties":{"account_index":{"type":"integer","format":"int64","description":"Queried account."},"order_id":{"type":"string","description":"Order index as a string; `\"0\"` can represent a synthetic entry without a normal order ID."},"grouping_id":{"type":"string","description":"Stored grouping identifier returned by the indexer, or `null`. Treat it as opaque; use `order_id` to identify the order.","nullable":true},"master_twap_id":{"type":"string","description":"Parent TWAP order id if the order is a TWAP child, else `null`.","nullable":true},"market_id":{"type":"integer","format":"int64","description":"Market."},"market_symbol":{"type":"string","description":"Market."},"market_kind":{"type":"string","enum":["spot","bo","perps"],"description":"`perps`, `spot` or `bo`."},"is_ask":{"type":"boolean","description":"`true` = sell, `false` = buy."},"type":{"type":"string","enum":["trade","liquidation","deleverage","market-settlement"],"description":"`trade`, `liquidation`, `deleverage`, `market-settlement`."},"role":{"type":"string","enum":["maker","taker"],"description":"`maker` or `taker`."},"first_trade_id":{"type":"string","description":"First / last fill in this trade-type and role subgroup (strings)."},"last_trade_id":{"type":"string","description":"First / last fill in this trade-type and role subgroup (strings)."},"first_timestamp":{"type":"integer","format":"int64","description":"First / last fill time in this subgroup, in Unix milliseconds."},"last_timestamp":{"type":"integer","format":"int64","description":"First / last fill time in this subgroup, in Unix milliseconds."},"first_block_height":{"type":"integer","format":"int64","description":"First / last fill block in this subgroup."},"last_block_height":{"type":"integer","format":"int64","description":"First / last fill block in this subgroup."},"fill_count":{"type":"integer","format":"int64","description":"Number of fills aggregated in this subgroup."},"size":{"type":"string","description":"Total filled base size."},"usd_amount":{"type":"string","description":"Total filled notional, USDC."},"pnl":{"type":"string","description":"Realized PnL from these fills, USDC; `null` if the fills didn't reduce a position.","nullable":true},"average_price":{"type":"string","description":"Size-weighted average fill price."},"fee":{"type":"string","description":"Total fee paid, in `fee_asset_id` units (USDC, or the base asset for spot buys)."},"integrator_fee":{"type":"string","description":"Total integrator fee, same units as `fee`."},"fee_asset_id":{"type":"integer","format":"int16","description":"Asset the fee is charged in (`3` = USDC)."},"position_size_before":{"type":"string","description":"Position size and entry quote before the first fill in this subgroup; `null` when unavailable.","nullable":true},"entry_quote_before":{"type":"string","description":"Position size and entry quote before the first fill in this subgroup; `null` when unavailable.","nullable":true},"position_sign_changed":{"type":"boolean","description":"Whether the position sign before the first fill differs from the sign after the last fill in this subgroup, including opening from or closing to zero; `null` when position data is unavailable.","nullable":true},"initial_margin_fraction_before":{"type":"integer","format":"int32","description":"Initial margin fraction before the first fill (`500` = 5%)."},"allocated_margin_usdc_before":{"type":"integer","format":"int64","description":"Isolated-margin allocation before the first / after the last fill (raw integer, same format as `*_allocated_margin_usdc_*` in `trades`)."},"allocated_margin_usdc_after":{"type":"integer","format":"int64","description":"Isolated-margin allocation before the first / after the last fill (raw integer, same format as `*_allocated_margin_usdc_*` in `trades`)."}},"title":"AggregatedTrade","required":["account_index","order_id","grouping_id","master_twap_id","market_id","market_symbol","market_kind","is_ask","type","role","first_trade_id","last_trade_id","first_timestamp","last_timestamp","first_block_height","last_block_height","fill_count","size","usd_amount","pnl","average_price","fee","integrator_fee","fee_asset_id","position_size_before","entry_quote_before","position_sign_changed","initial_margin_fraction_before","allocated_margin_usdc_before","allocated_margin_usdc_after"]},"ResultCode":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}},"title":"ResultCode","required":["code"]}}}}
````


---

# 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.lighter.xyz/api/orders/aggregatedtrades.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.
