---
title: "Get algo order"
description: "Get one algo order by `algo_order_id` or `client_order_id`."
---

Either `algo_order_id` or `client_order_id` must be provided.

| | |
|---|---|
| SDK | `client.get_algo_order(...)` |
| HTTP | `POST https://trades.<domain>/full/v1/get_algo_order`, or `/lite/v1/get_algo_order` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v1/get_algo_order` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Retries | Read: the SDKs retry retryable errors ([rules](../../guides/errors-and-retries.md)) |
| Contract id | `algo_order.get_algo_order` (`RPCGetAlgoOrderV1`) |

## Request

Body type `ApiGetAlgoOrderRequest`. Fields the server fills are left out.

- `sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID to filter by
- `algo_order_id` · lite `ao` · string (uint128) · one of `algo_order_id` / `client_order_id` required — Filter for `algo_order_id`
- `client_order_id` · lite `co` · string (uint64) · one of `algo_order_id` / `client_order_id` required — Filter for `client_order_id`

## Response

Body type `ApiGetAlgoOrderResponse` (the same object is the JSON-RPC `result` over WebSocket).

- `result` · lite `r` · object AlgoOrder · required — The algo order for the requested filter
- `result.algo_order_id` · lite `ao` · string (uint128) · optional, default `0` — Set by the server. The exchange's 128-bit id for the algo order.
- `result.sub_account_id` · lite `sa` · string (uint64) · required — The sub-account initiating the algo order
- `result.type` · lite `t` · enum AlgoOrderType · required — The type of the algo order
  Values: `CHASE` ([details](../enums.md#algoordertype)).
- `result.post_only` · lite `po` · bool · optional, default `false` — If True, every sub-order must be a maker order. Chase orders are always post-only
- `result.reduce_only` · lite `ro` · bool · optional, default `false` — If True, every sub-order must reduce the position size, or be cancelled
- `result.leg` · lite `l` · object AlgoOrderLeg · required — The single leg traded by this algo order
- `result.leg.instrument` · lite `i` · string (instrument name) · required — The instrument to trade
- `result.leg.size` · lite `s` · string · required — The total number of assets to trade across all sub-orders. Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
- `result.leg.is_buying_asset` · lite `ib` · bool · required — Specifies if the algo order is a buy or sell
- `result.metadata` · lite `m` · object AlgoOrderMetadata · required — Algo order metadata, including the type-specific parameters
- `result.metadata.client_order_id` · lite `co` · string (uint64) · required — Your own id for the algo order, unique among the sub-account's open algo orders. You can cancel the algo order by it.
- `result.metadata.create_time` · lite `ct` · string (int64 unix ns) · optional, default `0` — Set by the server. Time at which the algo order was received by Grvt in unix nanoseconds
- `result.metadata.trigger` · lite `t` · object TriggerOrderMetadata · optional — Trigger fields. If set, the algo order stays pending until the trigger price is crossed
- `result.metadata.trigger.trigger_type` · lite `tt` · enum TriggerType · required — Type of the trigger order. eg: Take Profit, Stop Loss, etc
  Values: `UNSPECIFIED`, `TAKE_PROFIT`, `STOP_LOSS` ([details](../enums.md#triggertype)).
- `result.metadata.trigger.tpsl` · lite `t` · object TPSLOrderMetadata · required — Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders.
  Fields: see [TPSLOrderMetadata](../types.md#tpslordermetadata).
- `result.metadata.broker` · lite `b` · enum BrokerTag · optional — Specifies the broker who brokered the algo order
  Values: `UNSPECIFIED`, `COIN_ROUTES`, `ALERTATRON`, `ORIGAMI` ([details](../enums.md#brokertag)).
- `result.metadata.expiry` · lite `e` · string (int64 unix ns) · optional, default `0` — Time at which the algo order expires, expressed in unix nanoseconds. Defaults to and must be capped at 90 days
- `result.metadata.chase` · lite `c` · object ChaseAlgoOrderMetadata · optional — Chase order parameters. Set only when the algo order type is CHASE
- `result.metadata.chase.chase_price_mode` · lite `cp` · enum ChasePriceMode · required — How the chase price is determined at each re-price tick
  Values: `BEST_BID_ASK` ([details](../enums.md#chasepricemode)).
- `result.metadata.chase.max_distance` · lite `md` · string · required — The maximum distance the chase price can move away from the reference price, as an absolute price distance in quote currency units. Decimal string, e.g. "65000.5"; up to 9 decimals.
  Always absolute: when the user picks a percentage, the client converts it and sends the result here.
- `result.metadata.chase.max_distance_bps` · lite `md1` · integer (uint32) · optional, default `0` — The max distance as a percentage in basis points (1 bp = 0.01%, 100% = 10000), as the user entered it. `0` if the user entered an absolute distance.
  Informational only, for display and history. `maxDistance` is what is enforced.
- `result.state` · lite `s` · object AlgoOrderState · optional — Set by the server. The current state of the algo order
- `result.state.status` · lite `s` · enum OrderStatus · required — The status of the algo order
  Values: `PENDING`, `OPEN`, `FILLED`, `REJECTED`, `CANCELLED` ([details](../enums.md#orderstatus)).
- `result.state.reject_reason` · lite `rr` · enum OrderRejectReason · required — The reason for rejection or cancellation
  Values: `UNSPECIFIED`, `CLIENT_CANCEL`, `CLIENT_BULK_CANCEL`, `CLIENT_SESSION_END`, `MARKET_CANCEL`, `IOC_CANCEL`, `AON_CANCEL`, `FOK_CANCEL`, `EXPIRED`, `FAIL_POST_ONLY`, `FAIL_REDUCE_ONLY`, `MM_PROTECTION`, `SELF_TRADE_PROTECTION`, `SELF_MATCHED_SUBACCOUNT`, `OVERLAPPING_CLIENT_ORDER_ID`, `BELOW_MARGIN`, `LIQUIDATION`, `INSTRUMENT_INVALID`, `INSTRUMENT_DEACTIVATED`, `SYSTEM_FAILOVER`, `UNAUTHORISED`, `SESSION_KEY_EXPIRED`, `SUB_ACCOUNT_NOT_FOUND`, `NO_TRADE_PERMISSION`, `UNSUPPORTED_TIME_IN_FORCE`, `MULTI_LEGGED_ORDER`, `EXCEED_MAX_POSITION_SIZE`, `EXCEED_MAX_SIGNATURE_EXPIRATION`, `MARKET_ORDER_WITH_LIMIT_PRICE`, `CLIENT_CANCEL_ON_DISCONNECT_TRIGGERED`, `OCO_COUNTER_PART_TRIGGERED`, `REDUCE_ONLY_LIMIT`, `CLIENT_REPLACE`, `DERISK_MUST_BE_IOC`, `DERISK_MUST_BE_REDUCE_ONLY`, `DERISK_NOT_SUPPORTED`, `INVALID_ORDER_TYPE`, `CURRENCY_NOT_DEFINED`, `INVALID_CHAIN_ID`, `BUILDER_ORDER_FEE_EXCEED`, `BUILDER_ORDER_FEE_NEGATIVE`, `BUILDER_ORDER_BUILDER_NOT_AUTHORIZED`, `BUILDER_ORDER_BUILDER_NOT_EXIST`, `TRADE_PRICE_WORSE_THAN_BANKRUPTCY_PRICE`, `TOO_MANY_MAKER_ORDERS`, `REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT_ORDER`, `TPSL_NOT_SUPPORTED_FOR_SPOT_ORDER`, `SPOT_ORDER_NOT_SUPPORTED`, `INSUFFICIENT_BALANCE`, `SPOT_TRADING_BLOCKED_DURING_SOCIALIZED_LOSS`, `BELOW_MARGIN_WITH_PENALTY_DEVIATION`, `CORPORATE_ACTION`, `NOT_QUALIFIED_MAKER`, `PRIVATE_QUOTE_REQUIRES_RFQ`, `STABLE_PERP_REQUIRES_PRICE_BOUND`, `UNSUPPORTED_TRIGGER_BY`, `RFQ_NOT_FOUND`, `RESTING_ORDER_WOULD_CROSS`, `SESSION_CLOSED`, `RFQ_TERMINATED`, `STABLE_PERP_REQUIRES_MULTI_ASSET_MODE`, `BORROW_LIMIT_EXCEEDED_AFTER_TRADE`, `UNDEPLOYED_LOAN_AUTO_EXCHANGE`, `LIQUIDATION_AUTO_EXCHANGE`, `USDC_COLLATERAL_DISABLED`, `SFP_POST_ONLY_NOT_ALLOWED`, `VAULT_NON_QUOTE_INVESTMENT_CURRENCY`, `RFQ_ID_REQUIRES_STABLE_PERP`, `RFQ_PRIVATE_POOL_NOT_SUPPORTED`, `RFQ_REQUIRES_IOC`, `RFQ_MISMATCH`, `RFQ_ALREADY_BOUND`, `RFQ_MAKER_MUST_BE_ECN`, `FOK_NOT_SUPPORTED`, `MARKET_ORDER_NOT_SUPPORTED`, `STABLE_PERP_ORDER_NOT_SUPPORTED` ([details](../enums.md#orderrejectreason)).
- `result.state.traded_size` · lite `ts` · string · required — The total number of assets traded across all sub-orders
- `result.state.avg_fill_price` · lite `af` · string · required — The average fill price across all sub-orders
- `result.state.trigger_time` · lite `tt` · string (int64 unix ns) · optional, default `0` — Time at which the algo order was triggered in unix nanoseconds, 0 if not triggered yet
- `result.state.update_time` · lite `ut` · string (int64 unix ns) · required — Time at which the algo order was updated by Grvt in unix nanoseconds
- `result.state.chase` · lite `c` · object ChaseOrderState · optional — Chase order state. Set only when the algo order type is CHASE
- `result.state.chase.reprice_count` · lite `rc` · integer (uint32) · required — The number of successful re-prices of this algo order's sub-orders
- `result.state.last_sub_order_id` · lite `ls` · string (uint128) · required — The latest sub-order placed for this algo order, 0 until the first sub-order is placed
- `result.builder` · lite `b` · string (0x address) · required — The main account ID of the builder
- `result.builder_fee` · lite `bf` · string · required — Builder fee charged for every sub-order, expressed as a percentage (e.g., 0.001 means 0.001%).

## Errors

Errors come back as `{"code", "message", "status"}` (lite `{"c", "m", "s"}`) with the HTTP status. Codes this call can return, as code, name (HTTP status) ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1003` InvalidRequest (400) · `1006` RateLimit (429, retryable) · `1008` IPNotWhitelisted (401)

## Example

```python
import os

from grvt import Grvt

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
) as client:
    resp = client.get_algo_order(
        sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
        client_order_id=os.environ["GRVT_CLIENT_ORDER_ID"],
    )
    print(resp)
```

Raw HTTP (set `GRVT_DOMAIN`, see [Environments](../../guides/environments.md); `GRVT_COOKIE` and `GRVT_ACCOUNT_ID` come from [login](../../guides/authentication.md)):

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v1/get_algo_order" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sub_account_id": "$GRVT_SUB_ACCOUNT_ID",
  "client_order_id": "$GRVT_CLIENT_ORDER_ID"
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v1/get_algo_order" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sa": "$GRVT_SUB_ACCOUNT_ID",
  "co": "$GRVT_CLIENT_ORDER_ID"
}
EOF
```
