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

# Get TWAP Order History by ID

> This endpoint allows users to get every event of one TWAP order.

```http theme={null}
GET /api/v1/orders/twap/history_by_id
```

Returns one row per event of the TWAP order, newest first. Each row shows the order's state after that event.

#### Query Parameters

<table><thead><tr><th width="176">Field</th><th width="98">Type</th><th width="95">Need</th><th width="189">Description</th><th>Example</th></tr></thead><tbody><tr><td>`"order_id"`</td><td>integer</td><td>required</td><td>TWAP order ID to retrieve history for</td><td>`13753364`</td></tr></tbody></table>

```http theme={null}
/api/v1/orders/twap/history_by_id?order_id=13753364
```

#### Response

* Status 200: Successfully retrieved TWAP order history

```json theme={null}
{
  "success": true,
  "data": [
    {
      "history_id": 26698518,
      "order_id": 13753364,
      "client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
      "symbol": "BTC",
      "side": "bid",
      "initial_amount": "0.121",
      "filled_amount": "0.04",
      "average_price_of_last_filled_sub_order": "87420",
      "value_of_last_filled_sub_order": "87.42",
      "event_type": "sub_order_executed",
      "order_status": "in_execution",
      "reduce_only": false,
      "slippage_percent": "0.500000000000",
      "planned_sub_order_amount": "0.001",
      "planned_sub_order_count": 121,
      "past_sub_order_count": 40,
      "created_at": 1716201200000
    },
    {
      "history_id": 26690012,
      "order_id": 13753364,
      "client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
      "symbol": "BTC",
      "side": "bid",
      "initial_amount": "0.121",
      "filled_amount": "0",
      "average_price_of_last_filled_sub_order": "0",
      "value_of_last_filled_sub_order": "0",
      "event_type": "twap_created",
      "order_status": "open",
      "reduce_only": false,
      "slippage_percent": "0.500000000000",
      "planned_sub_order_amount": "0.001",
      "planned_sub_order_count": 121,
      "past_sub_order_count": 0,
      "created_at": 1716200000000
    }
  ],
  "error": null,
  "code": null
}
```

<table><thead><tr><th width="208">Field</th><th width="186">Type</th><th>Description</th></tr></thead><tbody><tr><td>`"history_id"`</td><td>integer</td><td>History ID of the event</td></tr><tr><td>`"order_id"`</td><td>integer</td><td>TWAP order ID</td></tr><tr><td>`"client_order_id"`</td><td>UUID or null</td><td>CLOID of the TWAP order if assigned by user</td></tr><tr><td>`"symbol"`</td><td>string</td><td>Trading pair symbol</td></tr><tr><td>`"side"`</td><td>string</td><td>Whether the order is a bid or an ask</td></tr><tr><td>`"initial_amount"`</td><td>decimal string</td><td>Total amount (in token denomination) of the TWAP order</td></tr><tr><td>`"filled_amount"`</td><td>decimal string</td><td>Amount (in token denomination) filled after this event</td></tr><tr><td>`"average_price_of_last_filled_sub_order"`</td><td>decimal string</td><td>Average fill price of the sub-order in this event. `0` if the event has no fill</td></tr><tr><td>`"value_of_last_filled_sub_order"`</td><td>decimal string</td><td>Filled value (price × amount) of the sub-order in this event. `0` if the event has no fill</td></tr><tr><td>`"event_type"`</td><td>string</td><td>`"twap_created"`: order created\
`"sub_order_executed"`: a sub-order was placed\
`"sub_order_failed"`: the engine rejected a sub-order\
`"cancel"`: order cancelled\
`"reject_sub_order_failure"`: order stopped after a rejected sub-order\
`"expiration"`: order expired with part of the amount unfilled\
`"completion"`: the full amount filled</td></tr><tr><td>`"order_status"`</td><td>string</td><td>`"open"`\
`"in_execution"`\
`"completed"`\
`"cancelled"`\
`"expired"`\
`"rejected_due_to_sub_order"`\
See [Get TWAP order history](https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-twap-order-history.md)</td></tr><tr><td>`"reduce_only"`</td><td>boolean</td><td>If each sub-order is reduce only</td></tr><tr><td>`"slippage_percent"`</td><td>decimal string</td><td>Maximum slippage for each sub-order, in percent</td></tr><tr><td>`"planned_sub_order_amount"`</td><td>decimal string</td><td>Planned amount (in token denomination) of each sub-order, set at creation</td></tr><tr><td>`"planned_sub_order_count"`</td><td>integer</td><td>Number of planned sub-orders</td></tr><tr><td>`"past_sub_order_count"`</td><td>integer</td><td>Number of planned sub-orders processed after this event</td></tr><tr><td>`"created_at"`</td><td>integer</td><td>Timestamp in milliseconds when the event occurred</td></tr></tbody></table>

* Status 400: Invalid request parameters
* Status 404: No history for this TWAP order ID
* Status 500: Internal server error

#### Code Example (Python)

```python theme={null}
import requests

response = requests.get(
    "/api/v1/orders/twap/history_by_id?order_id=13753364",
    headers={"Accept": "*/*"},
)

data = response.json()
```


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