> For the complete documentation index, see [llms.txt](https://openapi-docs.nagaexchange.co.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openapi-docs.nagaexchange.co.id/rest-api-spot-trading/trading.md).

# Trading

{% hint style="info" %}
**Trade** section requires API-key and signature for access. See [Authentication](/authentication.md) for signing details.
{% endhint %}

***

## Create new order

<mark style="color:green;">`POST`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/order`

**Rate Limit**: 100 times/2s

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

#### Request Body

| Name                                     | Type   | Description                                                                                                                                                                                                                                                                                 |
| ---------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| symbol<mark style="color:red;">\*</mark> | string | Symbol name, case-insensitive, e.g. BTCUSDT or btcusdt                                                                                                                                                                                                                                      |
| volume<mark style="color:red;">\*</mark> | number | Order quantity. Precision-limited; the limit is configured by the administrator.                                                                                                                                                                                                            |
| side<mark style="color:red;">\*</mark>   | string | Order side, `BUY/SELL`                                                                                                                                                                                                                                                                      |
| type<mark style="color:red;">\*</mark>   | string | Order type, `LIMIT/MARKET`                                                                                                                                                                                                                                                                  |
| price                                    | number | Order price — required for LIMIT orders. Precision-limited; the limit is configured by the administrator.                                                                                                                                                                                   |
| newClientOrderId                         | string | The field is a third-party identifier and is not involved in the exchange's business logic or stored in the database. It is only returned as-is in the response. <mark style="color:red;">(Note: This field is not the exchange's business order ID, please distinguish accordingly)</mark> |

{% tabs %}
{% tab title="200  Successfully ordered" %}

```json
{
    "symbol": "ETHUSDT",
    "side": "BUY",
    "executedQty": 0,
    "orderId": [
        "2012274607240433332"
    ],
    "price": 0,
    "origQty": 0.01,
    "clientOrderId": "1212",
    "transactTime": 1704959985403,
    "type": "MARKET",
    "status": "NEW"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="186">Parameter</th><th width="111">Type</th><th width="191">Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>Order ID (system generated)</td></tr><tr><td><code>clientOrderId</code></td><td>string</td><td><code>213443</code></td><td>Order ID (sent by user)</td></tr><tr><td><code>symbol</code></td><td>string</td><td><code>BTCUSDT</code></td><td>Uppercase symbol name</td></tr><tr><td><code>transactTime</code></td><td>integer</td><td><code>1273774892913</code></td><td>Time the order was placed</td></tr><tr><td><code>price</code></td><td>float</td><td><code>4765.29</code></td><td>Order price</td></tr><tr><td><code>origQty</code></td><td>float</td><td><code>1.01</code></td><td>Order volume</td></tr><tr><td><code>executedQty</code></td><td>float</td><td><code>1.01</code></td><td>Quantity already filled</td></tr><tr><td><code>type</code></td><td>string</td><td><code>LIMIT</code></td><td>Order type: <code>LIMIT/MARKET</code></td></tr><tr><td><code>side</code></td><td>string</td><td><code>BUY</code></td><td>Order side: <code>BUY</code>/<code>SELL</code></td></tr><tr><td><code>status</code></td><td>string</td><td><code>NEW</code></td><td>This endpoint always returns exactly <code>NEW</code> for a freshly created order — see <a href="/appendix/enums.md">Enum Types</a> for how <code>status</code> differs across other Spot endpoints.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
`orderId` is returned here as a single-element array (e.g. `["2012274607240433332"]`), not a bare number.
{% endhint %}

***

## Test New Order

<mark style="color:green;">`POST`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/order/test`

Test new order creation and signature/recvWindow length. Creates and validates a new order but does not send the order into the matching engine.

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

#### Request Body

| Name                                     | Type   | Description                                                                                                                                                                                                                                                                                 |
| ---------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| symbol<mark style="color:red;">\*</mark> | string | Uppercase symbol name, e.g. BTCUSDT                                                                                                                                                                                                                                                         |
| volume<mark style="color:red;">\*</mark> | number | Order quantity. Precision-limited; the limit is configured by the administrator.                                                                                                                                                                                                            |
| side<mark style="color:red;">\*</mark>   | string | Order side, `BUY/SELL`                                                                                                                                                                                                                                                                      |
| type<mark style="color:red;">\*</mark>   | string | Order type, `LIMIT/MARKET`                                                                                                                                                                                                                                                                  |
| price                                    | number | Order price — required for LIMIT orders. Precision-limited; the limit is configured by the administrator.                                                                                                                                                                                   |
| newClientOrderId                         | string | The field is a third-party identifier and is not involved in the exchange's business logic or stored in the database. It is only returned as-is in the response. <mark style="color:red;">(Note: This field is not the exchange's business order ID, please distinguish accordingly)</mark> |

{% tabs %}
{% tab title="200  Successfully created test order" %}

```
{}
```

{% endtab %}
{% endtabs %}

***

## Batch Orders

<mark style="color:green;">`POST`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/batchOrders`

**Rate Limit**: 50 times/2s. Maximum 10 orders in one batch order request.

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

#### Request Body

| Name                                     | Type   | Description                           |
| ---------------------------------------- | ------ | ------------------------------------- |
| orders<mark style="color:red;">\*</mark> | array  | Batch order param, maximum 10 orders  |
| symbol<mark style="color:red;">\*</mark> | string | Uppercase symbol name, e.g. `BTCUSDT` |

{% tabs %}
{% tab title="200 " %}

```java
{
    "ids": [
        165964665990709251,
        165964665990709252,
        165964665990709253
    ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Order object fields (request)" %}

<table><thead><tr><th width="167">Parameter</th><th width="163">Type</th><th>Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>price</code></td><td>float</td><td>1000.00</td><td>Trade price</td></tr><tr><td><code>volume</code></td><td>float</td><td>20.10</td><td>Trade volume</td></tr><tr><td><code>side</code></td><td>string</td><td><code>BUY/SELL</code></td><td>Order side</td></tr><tr><td><code>batchType</code></td><td>string</td><td><code>LIMIT/MARKET</code></td><td>Order type</td></tr><tr><td>symbol</td><td>string</td><td>ETHUSDT</td><td>Uppercase symbol name</td></tr></tbody></table>
{% endtab %}

{% tab title="Example of request" %}
{% code title="Example of request" %}

```json
{"symbol":"ETHUSDT","orders":[{"side":"BUY","price":1980.00,"volume":1,"batchType":"MARKET"}]}
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

## Query Order

<mark style="color:blue;">`GET`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/order`

**Rate Limit**: 20 times/2s

#### Query Parameters

| Name                                      | Type   | Description                           |
| ----------------------------------------- | ------ | ------------------------------------- |
| orderId<mark style="color:red;">\*</mark> | string | Order id                              |
| symbol<mark style="color:red;">\*</mark>  | string | Lowercase symbol name, e.g. `ethusdt` |

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

{% tabs %}
{% tab title="200 " %}

```json
{
    "symbol": "ethusdt",
    "side": "BUY",
    "executedQty": 0E-16,
    "orderId": 53,
    "price": 20200.00,
    "origQty": 0.024,
    "avgPrice": 0E-16,
    "transactTime": 1672274311107,
    "type": "LIMIT",
    "status": "To be Cancelled"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="185">Parameter</th><th width="91">Type</th><th width="216">Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>Order ID (system generated)</td></tr><tr><td><code>clientOrderId</code></td><td>string</td><td><code>213443</code></td><td>Order ID (sent by user)</td></tr><tr><td><code>symbol</code></td><td>string</td><td>ethusdt</td><td>Lowercase symbol name</td></tr><tr><td><code>price</code></td><td>float</td><td><code>4765.29</code></td><td>Order price</td></tr><tr><td><code>origQty</code></td><td>float</td><td><code>1.01</code></td><td>Order volume</td></tr><tr><td><code>executedQty</code></td><td>float</td><td><code>1.01</code></td><td>Quantity already filled</td></tr><tr><td><code>avgPrice</code></td><td>float</td><td><code>4754.24</code></td><td>Average price of the filled portion</td></tr><tr><td><code>type</code></td><td>string</td><td><code>LIMIT</code></td><td>Order type: <code>LIMIT/MARKET</code></td></tr><tr><td>transactTime</td><td>long</td><td>1672274311107</td><td>Timestamp</td></tr><tr><td><code>side</code></td><td>string</td><td><code>BUY</code></td><td>Order side: <code>BUY/SELL</code></td></tr><tr><td><code>status</code></td><td>string</td><td><code>To be Cancelled</code></td><td>Order status: <code>New Order</code> (new order, no transaction), <code>Partially Filled</code> (partial transaction), <code>Filled</code> (full transaction), <code>Cancelled</code> (cancelled), <code>To be Cancelled</code> (pending cancellation), <code>Partially Filled/Cancelled</code> (partial transaction but order canceled), <code>Abnormal Order</code> (abnormal order state). See <a href="/appendix/enums.md">Enum Types</a> for how this vocabulary differs from other Spot endpoints.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
`orderId` is returned here as a bare integer (e.g. `53`), unlike Create new order and Cancel Order, which return it as a single-element array.
{% endhint %}

***

## Cancel Order

<mark style="color:green;">`POST`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/cancel`

**Rate Limit**: 100 times/2s

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

#### Request Body

| Name                                      | Type   | Description                         |
| ----------------------------------------- | ------ | ----------------------------------- |
| orderId<mark style="color:red;">\*</mark> | string | Order id                            |
| symbol<mark style="color:red;">\*</mark>  | string | Lowercase symbol name, e.g. ethusdt |

{% tabs %}
{% tab title="200  Successfully cancel order" %}

```json
{
    "symbol": "ethusdt",
    "orderId": [
        "1938321163093079425"
    ],
    "status": "PENDING_CANCEL"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="148">Parameter</th><th width="97">Type</th><th width="220">Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>Order ID (system generated)</td></tr><tr><td><code>symbol</code></td><td>string</td><td>ethusdt</td><td>Lowercase symbol name</td></tr><tr><td><code>status</code></td><td>string</td><td><code>PENDING_CANCEL</code></td><td>This endpoint always returns exactly <code>PENDING_CANCEL</code> — note this differs in casing/format from the descriptive status strings (e.g. <code>To be Cancelled</code>) returned by Query Order and Current Open Orders for the equivalent state. See <a href="/appendix/enums.md">Enum Types</a>.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
`orderId` is returned here as a single-element array (e.g. `["1938321163093079425"]`), matching Create new order.
{% endhint %}

***

## Batch Cancel Order

<mark style="color:green;">`POST`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/batchCancel`

**Rate Limit**: 50 times/2s. Every batch cancel request contains at most 10 orders.

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

#### Request Body

| Name                                       | Type   | Description                                                                                                                                           |
| ------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| symbol<mark style="color:red;">\*</mark>   | string | Uppercase symbol name, e.g. `BTCUSDT`                                                                                                                 |
| orderIds<mark style="color:red;">\*</mark> | array  | Collection of order IDs to be canceled. <mark style="color:red;">The order id must be of numeric type rather than String type.</mark> e.g.`[123,456]` |

{% tabs %}
{% tab title="200 " %}
{% code title="Return successful" %}

```java
{
    "success": [
        165964665990709251,
        165964665990709252,
        165964665990709253
    ],
    "failed": [ //Cancellation failure is usually because the order does not exist or the order status has reached the final state.
        165964665990709250  
    ]
}
```

{% endcode %}

{% code title="Return failed" %}

```json
{} //This is usually because one of the order IDs is incorrect — check the values in orderIds.
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

## Current Open Orders

<mark style="color:blue;">`GET`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/openOrders`

**Rate Limit**: 20 times/2s

#### Query Parameters

| Name                                     | Type    | Description                         |
| ---------------------------------------- | ------- | ----------------------------------- |
| symbol<mark style="color:red;">\*</mark> | string  | Lowercase symbol name, e.g. ethusdt |
| limit<mark style="color:red;">\*</mark>  | integer | Maximum 1000                        |

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "symbol": "ETHUSDT",
        "side": "BUY",
        "executedQty": "0",
        "orderId": 1938321163093077686,
        "price": "0",
        "origQty": "0.10",
        "avgPrice": "0",
        "time": 1701240367864,
        "type": "MARKET",
        "status": "New Order"
    },
    {
        "symbol": "ETHUSDT",
        "side": "BUY",
        "executedQty": "0",
        "orderId": 1938321163093078022,
        "price": "0",
        "origQty": "0.01",
        "avgPrice": "0",
        "time": 1701243281850,
        "type": "MARKET",
        "status": "New Order"
    }
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="168">Parameter</th><th width="87">Type</th><th width="219">Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>Order ID (system generated)</td></tr><tr><td><code>symbol</code></td><td>string</td><td><code>BTCUSDT</code></td><td>Uppercase symbol name</td></tr><tr><td><code>price</code></td><td>float</td><td><code>4765.29</code></td><td>Order price</td></tr><tr><td><code>origQty</code></td><td>float</td><td><code>1.01</code></td><td>Order volume</td></tr><tr><td><code>executedQty</code></td><td>float</td><td><code>1.01</code></td><td>Quantity already filled</td></tr><tr><td><code>avgPrice</code></td><td>float</td><td><code>4754.24</code></td><td>Average price of the filled portion</td></tr><tr><td><code>type</code></td><td>string</td><td><code>LIMIT</code></td><td>Order type: <code>LIMIT</code>/<code>MARKET</code></td></tr><tr><td>time</td><td>long</td><td>1701243281850</td><td>Timestamp</td></tr><tr><td><code>side</code></td><td>string</td><td><code>BUY</code></td><td>Order side: <code>BUY</code>/<code>SELL</code></td></tr><tr><td><code>status</code></td><td>string</td><td><code>New Order</code></td><td>This endpoint only ever returns open-order states: <code>New Order</code> (unfilled), <code>Partially Filled</code>, or <code>To be Cancelled</code>. Filled/fully-cancelled orders will not appear in this list at all.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## Trading records

<mark style="color:blue;">`GET`</mark> `https://openapi.nagaexchange.co.id/sapi/v1/myTrades`

**Rate Limit**: 20 times/2s

#### Query Parameters

| Name                                     | Type   | Description                           |
| ---------------------------------------- | ------ | ------------------------------------- |
| symbol<mark style="color:red;">\*</mark> | string | Uppercase symbol name, e.g. `BTCUSDT` |
| limit<mark style="color:red;">\*</mark>  | string | Default 100; Maximum 1000             |

#### Headers

| Name                                          | Type    | Description  |
| --------------------------------------------- | ------- | ------------ |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | Sign         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | User API-KEY |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | Timestamp    |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "symbol": "ETHUSDT",
        "side": "BUY",
        "fee": "0.00000000428",
        "isMaker": false,
        "isBuyer": true,
        "bidId": 1954603951049381893,
        "bidUserId": 10083,
        "feeCoin": "ETH",
        "price": "2334",
        "qty": "0.00000428",
        "askId": 1856176838352995447,
        "id": 159,
        "time": 1701623660989,
        "isSelf": false,
        "askUserId": 10671
    },
    {
        "symbol": "ETHUSDT",
        "side": "BUY",
        "fee": "0.00000004284",
        "isMaker": false,
        "isBuyer": true,
        "bidId": 1938321163093068889,
        "bidUserId": 10083,
        "feeCoin": "ETH",
        "price": "2334",
        "qty": "0.00004284",
        "askId": 1856176838352995447,
        "id": 158,
        "time": 1701165091964,
        "isSelf": false,
        "askUserId": 10671
    }
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="131">Parameter</th><th width="96">Type</th><th width="221">Example</th><th>Describe</th></tr></thead><tbody><tr><td><code>symbol</code></td><td>string</td><td><code>ETHBTC</code></td><td>Uppercase symbol name</td></tr><tr><td><code>id</code></td><td>integer</td><td><code>28457</code></td><td>Trade id</td></tr><tr><td><code>bidId</code></td><td>long</td><td><code>150695552109032492</code></td><td>Buy side order ID</td></tr><tr><td><code>askId</code></td><td>long</td><td><code>150695552109032493</code></td><td>Sell side order ID</td></tr><tr><td><code>price</code></td><td>number</td><td><code>4.01</code></td><td>Trade price</td></tr><tr><td><code>qty</code></td><td>float</td><td><code>12</code></td><td>Trade volume</td></tr><tr><td><code>time</code></td><td>number</td><td><code>1499865549590</code></td><td>Trade timestamp</td></tr><tr><td><code>isBuyer</code></td><td>boolean</td><td><code>true</code></td><td><code>true</code>= Buyer <code>false</code>= Seller</td></tr><tr><td><code>isMaker</code></td><td>boolean</td><td><code>false</code></td><td><code>true</code>=Maker <code>false</code>=Taker</td></tr><tr><td><code>feeCoin</code></td><td>string</td><td><code>ETH</code></td><td>Trade fee coin</td></tr><tr><td><code>fee</code></td><td>number</td><td><code>0.01</code></td><td>Trade fee</td></tr><tr><td>bidUserId</td><td>integer</td><td>10083</td><td>Buy side user id</td></tr><tr><td>askUserId</td><td>integer</td><td>10094</td><td>Sell side user id</td></tr><tr><td>isSelf</td><td>boolean</td><td>false</td><td>self deal status<br>true = is self deal<br>false = not self deal</td></tr><tr><td>side</td><td>string</td><td>BUY</td><td>Taker order side: BUY/SELL</td></tr></tbody></table>
{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://openapi-docs.nagaexchange.co.id/rest-api-spot-trading/trading.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
