> For the complete documentation index, see [llms.txt](https://exdocs.gitbook.io/v/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://exdocs.gitbook.io/v/spot.md).

# 币币交易

## 公共

### 安全类型: [None](/v/general-info.md#jie-kou-jian-quan-lei-xing)

公共下方的接口不需要API-key或者签名就能自由访问

## &#x20;测试连接

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/ping`

&#x20;测试REST API的连通性\
\
**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/TestConnectivity.java`

{% tabs %}
{% tab title="200  连接正常" %}

```
{}
```

{% endtab %}
{% endtabs %}

## &#x20;服务器时间

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/time`

&#x20;服务器时间\
\
**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/CheckServerTime.java`

{% tabs %}
{% tab title="200  获取服务器时间成功" %}

```java
{
    "timezone": "GMT+08:00",
    "serverTime": 1595563624731
}
```

{% endtab %}
{% endtabs %}

## 币对列表&#x20;

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/symbols`

&#x20;市场支持的币对集合\
\
**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/PairsList.java`

{% tabs %}
{% tab title="200 获取币对列表成功" %}

```java
{
    "symbols": [
        {
            "quantityPrecision": 3,
            "symbol": "sccadai",
            "pricePrecision": 6,
            "baseAsset": "SCCA",
            "quoteAsset": "DAI"
        },
        {
            "quantityPrecision": 8,
            "symbol": "btcusdt",
            "pricePrecision": 2,
            "baseAsset": "BTC",
            "quoteAsset": "USDT"
        },
        {
            "quantityPrecision": 3,
            "symbol": "bchusdt",
            "pricePrecision": 2,
            "baseAsset": "BCH",
            "quoteAsset": "USDT"
        },
        {
            "quantityPrecision": 2,
            "symbol": "etcusdt",
            "pricePrecision": 2,
            "baseAsset": "ETC",
            "quoteAsset": "USDT"
        },
        {
            "quantityPrecision": 2,
            "symbol": "ltcbtc",
            "pricePrecision": 6,
            "baseAsset": "LTC",
            "quoteAsset": "BTC"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Response:

| 名称                | 类型      | 例子        | 描述     |
| ----------------- | ------- | --------- | ------ |
| symbol            | string  | `BTCUSDT` | 币对名称   |
| baseAsset         | string  | `BTC`     | base货币 |
| quoteAsset        | string  | `USDT`    | 计价货币   |
| pricePrecision    | integer | `2`       | 价格精度   |
| quantityPrecision | integer | `6`       | 数量精度   |

## 行情

### 安全类型: [None](/v/general-info.md#jie-kou-jian-quan-lei-xing)

行情下方的接口不需要API-Key或者签名就能自由访问

## &#x20;订单薄

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/depth`

&#x20;市场订单薄深度信息\
\
**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/Depth.java`

#### Query Parameters

| Name                                     | Type    | Description       |
| ---------------------------------------- | ------- | ----------------- |
| limit<mark style="color:red;">\*</mark>  | integer | 默认100; 最大100      |
| symbol<mark style="color:red;">\*</mark> | string  | 币对名称 E.g. BTCUSDT |

{% tabs %}
{% tab title="200  成功获取深度信息" %}

```java
{
  "bids": [
    [
      "3.90000000",   // 价格
      "431.00000000"  // 数量
    ],
    [
      "4.00000000",
      "431.00000000"
    ]
  ],
  "asks": [
    [
      "4.00000200",  // 价格
      "12.00000000"  // 数量
    ],
    [
      "5.10000000",
      "28.00000000"
    ]
  ]
}
```

{% endtab %}
{% endtabs %}

#### Response:

| 名称   | 类型   | 例子              | 描述                         |
| ---- | ---- | --------------- | -------------------------- |
| time | long | `1595563624731` | 当前时间(Unix Timestamp, 毫秒ms) |
| bids | list | 如下              | 订单薄买盘信息                    |
| asks | list | 如下              | 订单薄卖盘信息                    |

bids和asks所对应的信息代表了订单薄的所有价格以及价格对应的数量的信息, 由最优价格从上倒下排列

| 名称  | 类型    | 例子      | 描述        |
| --- | ----- | ------- | --------- |
| ' ' | float | `131.1` | 价格        |
| ' ' | float | `2.3`   | 当前价格对应的数量 |

## &#x20;行情ticker

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/ticker`

24小时价格变化数据\
\
**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/Ticker.java`

#### Query Parameters

| Name                                     | Type   | Description         |
| ---------------------------------------- | ------ | ------------------- |
| symbol<mark style="color:red;">\*</mark> | string | 币对名称 E.g. `BTCUSDT` |

{% tabs %}
{% tab title="200  成功获取ticker信息" %}

```java
{
    "high": "9279.0301",
    "vol": "1302",
    "last": "9200",
    "low": "9279.0301",
    "rose": "0",
    "time": 1595563624731
}
```

{% endtab %}
{% endtabs %}

#### Response:

| 名称   | 类型    | 例子              | 描述  |
| ---- | ----- | --------------- | --- |
| time | long  | `1595563624731` | 时间戳 |
| high | float | `9900`          | 最高价 |
| low  | float | `8800.34`       | 最低价 |
| last | float | `8900`          | 最新价 |
| vol  | float | `4999`          | 交易量 |
| open | float | `5000`          | 开盘价 |

## &#x20;最近成交

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/trades`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/RecentTradesList.java`<br>

#### Query Parameters

| Name                                     | Type   | Description         |
| ---------------------------------------- | ------ | ------------------- |
| symbol<mark style="color:red;">\*</mark> | string | 币对名称 E.g. `BTCUSDT` |
| limit<mark style="color:red;">\*</mark>  | string | 默认100; 最大1000       |

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

```java
{
    "list":[
        {
            "price":"3.00000100",
            "qty":"11.00000000",
            "time":1499865549590,
            "side":"BUY"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称      | 类型     | 例子              | 描述               |
| ------- | ------ | --------------- | ---------------- |
| `price` | float  | `0.055`         | 交易价格             |
| `time`  | long   | `1537797044116` | 当前Unix时间戳，毫秒(ms) |
| `qty`   | float  | `5`             | 数量（张数）           |
| `side`  | string | `BUY/SELL`      | 主动单方向            |

## K线/蜡烛图数据

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/klines`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/KlineCandlestickData.java`<br>

#### Query Parameters

| Name                                       | Type    | Description                                                                                                       |
| ------------------------------------------ | ------- | ----------------------------------------------------------------------------------------------------------------- |
| symbol<mark style="color:red;">\*</mark>   | string  | 币对名称 E.g. `BTCUSDT`                                                                                               |
| interval<mark style="color:red;">\*</mark> | string  | k线图区间, 可识别发送的值为： `1min`,`5min`,`15min`,`30min`,`60min`,`1day`,`1week`,`1month`（min=分钟，h=小时,day=天，week=星期，month=月） |
| limit<mark style="color:red;">\*</mark>    | integer | 默认100; 最大300                                                                                                      |

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

```java
[
    {
        "high": "6228.77",
        "vol": "111",
        "low": "6228.77",
        "idx": 1594640340,
        "close": "6228.77",
        "open": "6228.77"
    },
    {
        "high": "6228.77",
        "vol": "222",
        "low": "6228.77",
        "idx": 1587632160,
        "close": "6228.77",
        "open": "6228.77"
    },
    {
        "high": "6228.77",
        "vol": "333",
        "low": "6228.77",
        "idx": 1587632100,
        "close": "6228.77",
        "open": "6228.77"
    }
]
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称      | 类型    | 例子              | 描述           |
| ------- | ----- | --------------- | ------------ |
| `idx`   | long  | `1538728740000` | 开始时间戳，毫秒（ms） |
| `open`  | float | `36.00000`      | 开盘价          |
| `close` | float | `33.00000`      | 收盘价          |
| `high`  | float | `36.00000`      | 最高价          |
| `low`   | float | `30.00000`      | 最低价          |
| `vol`   | float | `2456.111`      | 成交量          |

## 交易

### 安全类型: [TRADE](/v/general-info.md#jie-kou-jian-quan-lei-xing)

交易下方的接口都需要[签名和API-key验证](/v/general-info.md#xu-yao-qian-ming-de-jie-kou-trade-yu-userdata)

## &#x20;创建新订单

<mark style="color:green;">`POST`</mark> `https://openapi.xxx.com/sapi/v1/order`

**Demo:**\
**`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/NewOrder.java`**\
\
**限速规则: 100次/2s**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                     | Type    | Description           |
| ---------------------------------------- | ------- | --------------------- |
| symbol<mark style="color:red;">\*</mark> | string  | 币对名称 E.g. `BTCUSDT`   |
| volume<mark style="color:red;">\*</mark> | number  | 订单数量                  |
| side<mark style="color:red;">\*</mark>   | string  | 订单方向, `BUY/SELL`      |
| type<mark style="color:red;">\*</mark>   | string  | 订单类型, `LIMIT/MARKET`  |
| price                                    | number  | 订单价格, 对于`LIMIT`订单必须发送 |
| newClientOrderId                         | string  | 客户端订单标识               |
| recvWindow                               | integer | 时间窗口                  |

{% tabs %}
{% tab title="200  发送新订单成功" %}

```java
{
    'symbol': 'LXTUSDT', 
    'orderId': '150695552109032492', 
    'clientOrderId': '157371322565051',
    'transactTime': '1573713225668', 
    'price': '0.005452', 
    'origQty': '110', 
    'executedQty': '0', 
    'status': 'NEW',
    'type': 'LIMIT', 
    'side': 'SELL'
}
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称              | 类型      | 例子                   | 描述                                                                                                     |
| --------------- | ------- | -------------------- | ------------------------------------------------------------------------------------------------------ |
| `orderId`       | long    | `150695552109032492` | 订单ID（系统生成）                                                                                             |
| `clientOrderId` | string  | `213443`             | 订单ID（自己发送的）                                                                                            |
| `symbol`        | string  | `BTCUSDT`            | 币对名称                                                                                                   |
| `transactTime`  | integer | `1273774892913`      | 订单创建时间                                                                                                 |
| `price`         | float   | `4765.29`            | 订单价格                                                                                                   |
| `origQty`       | float   | `1.01`               | 订单数量                                                                                                   |
| `executedQty`   | float   | `1.01`               | 已经成交订单数量                                                                                               |
| `type`          | string  | `LIMIT`              | 订单类型`LIMIT`(限价)`MARKET`（市价）                                                                            |
| `side`          | string  | `BUY`                | 订单方向。可能出现的值只能为：`BUY`（买入做多） 和 `SELL`（卖出做空）                                                              |
| `status`        | string  | `NEW`                | 订单状态。可能出现的值为：`NEW`(新订单，无成交)、`PARTIALLY_FILLED`（部分成交）、`FILLED`（全部成交）、`CANCELED`（已取消）和`REJECTED`（订单被拒绝）. |

## &#x20;创建测试订单

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

**Demo:** \
**`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/TestNewOrder.java`**\
\
创建和验证新订单, 但不会送入撮合引擎

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                     | Type    | Description           |
| ---------------------------------------- | ------- | --------------------- |
| recvWindow                               | integer | 时间窗口                  |
| symbol<mark style="color:red;">\*</mark> | string  | 币对名称 E.g. `BTCUSDT`   |
| volume<mark style="color:red;">\*</mark> | number  | 订单数量                  |
| side<mark style="color:red;">\*</mark>   | string  | 订单方向, `BUY/SELL`      |
| type<mark style="color:red;">\*</mark>   | string  | 订单类型, `LIMIT/MARKET`  |
| price                                    | number  | 订单价格, 对于`LIMIT`订单必须发送 |
| newClientOrderId                         | string  | 客户端订单标识               |

{% tabs %}
{% tab title="200  创建测试订单成功" %}

```
{}
```

{% endtab %}
{% endtabs %}

## &#x20;批量下单

<mark style="color:green;">`POST`</mark> `https://openapi.xxx.com/sapi/v1/batchOrders`

**Demo:** \
**`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/BatchOrders.java`**\
\
**限速规则: 50次/2s 一个批量最多10个订单**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                     | Type   | Description         |
| ---------------------------------------- | ------ | ------------------- |
| orders<mark style="color:red;">\*</mark> | array  | 批量订单信息  最多10条       |
| symbol<mark style="color:red;">\*</mark> | string | 币对名称 E.g. `BTCUSDT` |

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

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

{% endtab %}
{% endtabs %}

#### Resquest `orders` field:

| 名称          | 类型     | 例子             | 描述 |
| ----------- | ------ | -------------- | -- |
| `price`     | folat  | 1000           | 价格 |
| `volume`    | folat  | 20.1           | 数量 |
| `side`      | string | `BUY/SELL`     | 方向 |
| `batchType` | string | `LIMIT/MARKET` | 类型 |

## &#x20;订单查询

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/order`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/QueryOrder.java` \
\
**限速规则: 20次/2s**

#### Query Parameters

| Name                                      | Type   | Description         |
| ----------------------------------------- | ------ | ------------------- |
| orderId<mark style="color:red;">\*</mark> | string | 订单id                |
| newClientOrderId                          | string | 客户端订单标识             |
| symbol<mark style="color:red;">\*</mark>  | string | 币对名称 E.g. `BTCUSDT` |

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

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

```java
{
    'orderId': '499890200602846976', 
    'clientOrderId': '157432755564968', 
    'symbol': 'BHTUSDT', 
    'price': '0.01', 
    'origQty': '50', 
    'executedQty': '0', 
    'avgPrice': '0', 
    'status': 'NEW', 
    'type': 'LIMIT', 
    'side': 'BUY', 
    'transactTime': '1574327555669'
}
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称              | 类型     | 例子                   | 描述                                                                                                     |
| --------------- | ------ | -------------------- | ------------------------------------------------------------------------------------------------------ |
| `orderId`       | long   | `150695552109032492` | 订单ID（系统生成）                                                                                             |
| `clientOrderId` | string | `213443`             | 订单ID（自己发送的）                                                                                            |
| `symbol`        | string | `BTCUSDT`            | 币对名称                                                                                                   |
| `price`         | float  | `4765.29`            | 订单价格                                                                                                   |
| `origQty`       | float  | `1.01`               | 订单数量                                                                                                   |
| `executedQty`   | float  | `1.01`               | 已经成交订单数量                                                                                               |
| `avgPrice`      | float  | `4754.24`            | 订单已经成交的平均价格                                                                                            |
| `type`          | string | `LIMIT`              | 订单类型。可能出现的值只能为:`LIMIT`(限价)和`MARKET`（市价）                                                                |
| `side`          | string | `BUY`                | 订单方向。可能出现的值只能为：`BUY`（买入做多） 和 `SELL`（卖出做空）                                                              |
| `status`        | string | `NEW`                | 订单状态。可能出现的值为：`NEW`(新订单，无成交)、`PARTIALLY_FILLED`（部分成交）、`FILLED`（全部成交）、`CANCELED`（已取消）和`REJECTED`（订单被拒绝）. |

## &#x20;撤销订单

<mark style="color:green;">`POST`</mark> `https://openapi.xxx.com/sapi/v1/cancel`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/CancelOrder.java` \
\
**限速规则: 100次/2s**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                      | Type   | Description         |
| ----------------------------------------- | ------ | ------------------- |
| orderId<mark style="color:red;">\*</mark> | string | 订单id                |
| newClientOrderId                          | string | 客户端订单标识             |
| symbol<mark style="color:red;">\*</mark>  | string | 币对名称 E.g. `BTCUSDT` |

{% tabs %}
{% tab title="200  撤销订单成功" %}

```java
{
    'symbol': 'BHTUSDT', 
    'clientOrderId': '0', 
    'orderId': '499890200602846976', 
    'status': 'CANCELED'
}

```

{% endtab %}
{% endtabs %}

#### Response:

| 名称              | 类型     | 例子                   | 描述                                                                                                    |
| --------------- | ------ | -------------------- | ----------------------------------------------------------------------------------------------------- |
| `orderId`       | long   | `150695552109032492` | 订单ID（系统生成                                                                                             |
| `clientOrderId` | string | `213443`             | 订单ID（自己发送的）                                                                                           |
| `symbol`        | string | `BHTUSDT`            | 币对名称                                                                                                  |
| `status`        | string | `NEW`                | 订单状态。可能出现的值为：`NEW`(新订单，无成交)、`PARTIALLY_FILLED`（部分成交）、`FILLED`（全部成交）、`CANCELED`（已取消）和`REJECTED`（订单被拒绝） |

## &#x20;批量撤销订单

<mark style="color:green;">`POST`</mark> `https://openapi.xxx.com/sapi/v1/batchCancel`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/BatchCancelOrders.java`\
\
**限速规则: 50次/2s 一次批量最多10个订单**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                       | Type   | Description            |
| ------------------------------------------ | ------ | ---------------------- |
| symbol<mark style="color:red;">\*</mark>   | string | 币对名称 E.g. `BTCUSDT`    |
| orderIds<mark style="color:red;">\*</mark> | array  | 要取消的订单id集合 `[123,456]` |

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

```java
{
    "success": [
        165964665990709251,
        165964665990709252,
        165964665990709253
    ],
    "failed": [ //取消失败一般是因为订单不存在或订单状态已经到终态
        165964665990709250  
    ]
}
```

{% endtab %}
{% endtabs %}

## &#x20;当前订单

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/openOrders`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/CurrentOpenOrders.java` \
\
**限速规则: 20次/2s**

#### Query Parameters

| Name                                     | Type    | Description         |
| ---------------------------------------- | ------- | ------------------- |
| symbol<mark style="color:red;">\*</mark> | string  | 币对名称 E.g. `BTCUSDT` |
| limit<mark style="color:red;">\*</mark>  | integer | 默认100; 最大1000       |

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

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

```java
[
    {
        'orderId': '499902955766523648', 
        'symbol': 'BHTUSDT', 
        'price': '0.01', 
        'origQty': '50', 
        'executedQty': '0', 
        'avgPrice': '0', 
        'status': 'NEW', 
        'type': 'LIMIT', 
        'side': 'BUY', 
        'time': '1574329076202'
        },...
]
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称              | 类型     | 例子                   | 描述                                                                                                     |
| --------------- | ------ | -------------------- | ------------------------------------------------------------------------------------------------------ |
| `orderId`       | long   | `150695552109032492` | 订单ID（系统生成）                                                                                             |
| `clientOrderId` | string | `213443`             | 订单ID（自己发送的）                                                                                            |
| `symbol`        | string | `BTCUSDT`            | 币对名称                                                                                                   |
| `price`         | float  | `4765.29`            | 订单价格                                                                                                   |
| `origQty`       | float  | `1.01`               | 订单数量                                                                                                   |
| `executedQty`   | float  | `1.01`               | 已经成交订单数量                                                                                               |
| `avgPrice`      | float  | `4754.24`            | 订单已经成交的平均价格                                                                                            |
| `type`          | string | `LIMIT`              | 订单类型。可能出现的值只能为:`LIMIT`(限价)和`MARKET`（市价）                                                                |
| `side`          | string | `BUY`                | 订单方向。可能出现的值只能为：`BUY`（买入做多） 和 `SELL`（卖出做空）                                                              |
| `status`        | string | `NEW`                | 订单状态。可能出现的值为：`NEW`(新订单，无成交)、`PARTIALLY_FILLED`（部分成交）、`FILLED`（全部成交）、`CANCELED`（已取消）和`REJECTED`（订单被拒绝）. |

## &#x20;交易记录

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/myTrades`

**Demo:**\
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/Trades.java` \
\
**限速规则: 20次/2s**

#### Query Parameters

| Name                                     | Type    | Description         |
| ---------------------------------------- | ------- | ------------------- |
| symbol<mark style="color:red;">\*</mark> | string  | 币对名称 E.g. `BTCUSDT` |
| limit<mark style="color:red;">\*</mark>  | string  | 默认100; 最大1000       |
| fromId<mark style="color:red;">\*</mark> | integer | 从这个tradeId开始检索      |

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

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

```java
[
  {
    "symbol": "ETHBTC",
    "id": 100211,
    "bidId": 150695552109032492,
    "askId": 150695552109032493,
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyer": true,
    "isMaker": false,
    "feeCoin": "ETH",
    "fee":"0.001"
  },...
]
```

{% endtab %}
{% endtabs %}

#### **Response:**

| 名称        | 类型      | 例子                   | 描述                            |
| --------- | ------- | -------------------- | ----------------------------- |
| `symbol`  | string  | `ETHBTC`             | 币种名称(交易对)                     |
| `id`      | integer | `28457`              | 交易ID                          |
| `bidId`   | long    | `150695552109032492` | 买方订单ID                        |
| `askId`   | long    | `150695552109032493` | 卖方订单ID                        |
| `price`   | integer | `4.01`               | 交易时间戳                         |
| `qty`     | float   | `12`                 | 交易数量                          |
| `time`    | number  | `1499865549590`      | 交易时间戳                         |
| `isBuyer` | bool    | `true`               | `true`= Buyer `false`= Seller |
| `isMaker` | bool    | `false`              | `true`=Maker `false`=Taker    |
| `feeCoin` | string  | `ETH`                | 交易手续费币种                       |
| `fee`     | number  | `0.001`              | 交易手续费                         |

## 账户

### 安全类型:[ USER\_DATA](/v/general-info.md#jie-kou-jian-quan-lei-xing)

账户下方的接口都需要[签名和API-key验证](/v/general-info.md#xu-yao-qian-ming-de-jie-kou-trade-yu-userdata)

## &#x20;账户信息

<mark style="color:blue;">`GET`</mark> `https://openapi.xxx.com/sapi/v1/account`

**Demo:** \
`https://github.com/exchange2021/openapidemo/blob/master/src/main/java/com/spot/AccountInformation.java`\
\
**限速规则: 20次/2s**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

{% tabs %}
{% tab title="200  获取账户信息成功" %}

```java
{
    'balances': 
        [
            {
                'asset': 'BTC', 
                'free': '0', 
                'locked': '0'
                }, 
            {
                'asset': 'ETH', 
                'free': '0', 
                'locked': '0'
                },...
        ]
}
```

{% endtab %}
{% endtabs %}

#### Response:

| 名称         | 类型   | 描述   |
| ---------- | ---- | ---- |
| `balances` | `[]` | 余额集合 |

`balances` field:

| 名称       | 类型     | 例子      | 描述   |
| -------- | ------ | ------- | ---- |
| `asset`  | string | `USDT`  | 币种名称 |
| `free`   | float  | 1000.30 | 可用   |
| `locked` | float  | 400     | 冻结   |
