# Spot

## Public

### Test Connectivity

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/ping`

**Description:**

This endpoint checks connectivity to the host.

**Response:**

* `200: OK` - Connection normal

***

### Check Server Time

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/time`

**Description:**

This endpoint checks connectivity to the server and retrieves server timestamp.

**Response:**

* `200: OK` - Successfully retrieved server time

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

***

### Pairs List

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/symbols`

**Description:**

Retrieve a list of trading pairs.

**Response:**

* `200: OK`

```json
{
    "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"
        }
    ]
}
```

#### Response Fields

* **symbol**: string - Name of the symbol (e.g., BTCUSDT)
* **baseAsset**: string - Underlying asset for the symbol (e.g., BTC)
* **quoteAsset**: string - Quote asset for the symbol (e.g., USDT)
* **pricePrecision**: integer - Precision of the price
* **quantityPrecision**: integer - Precision of the quantity

***

## Market

### Depth

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/depth`

**Description:**

Retrieve market depth data.

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **limit**: integer (default 100; max 100)

**Response:**

* `200: OK` - Successfully retrieved market depth data

```json
{
  "bids": [
    [
      "3.90000000",   // price
      "431.00000000"  // volume
    ],
    [
      "4.00000000",
      "431.00000000"
    ]
  ],
  "asks": [
    [
      "4.00000200",  // price
      "12.00000000"  // volume
    ],
    [
      "5.10000000",
      "28.00000000"
    ]
  ]
}
```

#### Response Fields

* **time**: long - Current timestamp (ms)
* **bids**: list - List of all bids, best bids first
* **asks**: list - List of all asks, best asks first

***

### 24hrs Ticker

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/ticker`

**Description:**

Retrieve 24-hour price change statistics.

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)

**Response:**

* `200: OK` - Successfully retrieved ticker data

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

#### Response Fields

* **time**: long - Open Time
* **high**: float - High Price
* **low**: float - Low Price
* **open**: float - Open Price
* **last**: float - Last Price
* **vol**: float - Trade Volume
* **rose**: float - Price increase or Price rise

***

### Recent Trades List

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/trades`

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **limit**: string (default 100; max 1000)

**Response:**

* `200: OK`

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

#### Response Fields

* **price**: float - The price of the trade
* **time**: long - Current timestamp (ms)
* **qty**: float - The quantity traded
* **side**: string - BUY/SELL (Taker side)

***

### Kline/Candlestick Data

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/klines`

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **interval**: string (required) - Interval of the Kline. Possible values include: 1min, 5min, 15min, 30min, 60min, 1day, 1week, 1month
* **startTime**: long - Start time (e.g., 1538728740000)
* **endTime**: long - End time (e.g., 1538728740000)
* **limit**: string (default 100; max 300)

**Response:**

* `200: OK`

```json
[
    {
        "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"
    }
]
```

#### Response Fields

* **idx**: long - Open time
* **open**: float - Open price
* **close**: float - Close price
* **high**: float - High price
* **low**: float - Low price
* **vol**: float - Volume

***

## Trade

### New Order

**Endpoint:**

`POST https://openapi.fokawa.com/sapi/v1/order`

**Rate Limit:**

100 times/2s

**Headers:**

* **X-CH-SIGN**: string - Sign
* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: integer - Timestamp

**Request Body:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **volume**: number (required) - Order volume. For MARKET BUY orders, volume = amount.
* **side**: string (required) - Side of the order, BUY/SELL
* **type**: string (required) - Type of the order, LIMIT/MARKET
* **price**: number - Order price, REQUIRED for LIMIT orders
* **newClientOrderId**: string - Unique order ID generated by users to mark their orders
* **recvwindow**: integer - Time window

**Response:**

* `200: OK` - Successfully posted new order

```json
{
    "symbol": "LXTUSDT",
    "orderId": 150695552109032492,
    "orderIdString": "150695552109032492", // Character String Type Order ID (Recommended)
    "clientOrderId": "157371322565051",
    "transactTime": "1573713225668",
    "price": "0.005452",
    "origQty": "110",
    "executedQty": "0",
    "status": "NEW",
    "type": "LIMIT",
    "side": "SELL"
}
```

#### Response Fields

* **orderId**: long - ID of the order
* **clientorderId**: string - Unique ID of the order
* **symbol**: string - Symbol Name (e.g., BTCUSDT)
* **transactTime**:

integer - Time the order is placed

* **price**: float - Order price
* **origQty**: float - Quantity ordered
* **executedQty**: float - Quantity of orders that have been executed
* **type**: string - Order type (LIMIT, MARKET)
* **side**: string - Order side (BUY, SELL)
* **status**: string - Order status (NEW, PARTIALLY\_FILLED, FILLED, CANCELED, REJECTED)

***

### Test New Order

**Endpoint:**

`POST https://openapi.fokawa.com/sapi/v1/order/test`

**Description:**

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:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Request Body:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **volume**: number (required) - Order volume. For MARKET BUY orders, volume = amount.
* **side**: string (required) - Side of the order, BUY/SELL
* **type**: string (required) - Type of the order, LIMIT/MARKET
* **price**: number - Order price, REQUIRED for LIMIT orders
* **recvwindow**: integer - Time window
* **newClientOrderId**: string - Unique order ID generated by users to mark their orders

**Response:**

* `200: OK` - Successfully tested new order

```json
{
    // Response
}
```

***

### Batch Orders

**Endpoint:**

`POST https://openapi.fokawa.com/sapi/v1/batchOrders`

**Description:**

Batch contains at most 10 orders.

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Request Body:**

* **orders**: number - The batch order information can contain a maximum of 10 records
* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)

**Response:**

* `200: OK`

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

#### Request Fields

* **price**: float - Price
* **volume**: float - Quantity
* **side**: string - BUY/SELL (Direction)
* **batchType**: string - LIMIT/MARKET (Type)
* **idsString**: string - Collection of order numbers of type String
* **ids**: integer - Collection of order numbers

***

### Query Order

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/order`

**Query Parameters:**

* **orderId**: string (required) - Order ID
* **newClientOrderId**: string - Client Order Id, Unique order ID generated by users to mark their orders (e.g., 354444heihieddada)
* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Response:**

* `200: OK`

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

#### Response Fields

* **orderId**: long - Order ID (system generated)
* **clientOrderId**: string - Order ID (sent by yourself)
* **symbol**: string - Currency Pair Name
* **price**: float - Order Price
* **origQty**: float - Number of orders
* **executedQty**: float - Number of orders already filled
* **avgPrice**: float - Average price of filled orders
* **type**: string - Order type (LIMIT, MARKET)
* **side**: string - Order direction (BUY, SELL)
* **status**: string - Order status (NEW, PARTIALLY\_FILLED, FILLED, CANCELED, REJECTED)
* **transactTime**: string - Order Creation Time

***

### Cancel Order

**Endpoint:**

`POST https://openapi.fokawa.com/sapi/v1/cancel`

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Request Body:**

* **newClientOrderId**: string - Client Order Id, Unique order ID generated by users to mark their orders (e.g., 354444heihieddada)
* **orderId**: string (required) - Order ID
* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)

**Response:**

* `200: OK`

```json
{
    "symbol": "BHTUSDT",
    "clientOrderId": "0",
    "orderId": "499890200602846976",
    "status": "CANCELED"
}
```

#### Response Fields

* **orderId**: long - ID of the order
* **clientOrderId**: string - Unique ID of the order
* **symbol**: string - Name of the symbol
* **status**: string - The state of the order (NEW, PARTIALLY\_FILLED, FILLED, CANCELED, REJECTED)

***

### Batch Cancel Orders

**Endpoint:**

`POST https://openapi.fokawa.com/sapi/v1/batchCancel`

**Description:**

Batch contains at most 10 orders.

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Request Body:**

* **orderIds**: string - Order ID collection \[123,456]
* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)

**Response:**

* `200: OK`

```json
{
    "success": [
        165964665990709251,
        165964665990709252,
        165964665990709253
    ],
    "failed": [
        165964665990709250
    ]
}
```

***

### Current Open Orders

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/openOrders`

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTCUSDT)
* **limit**: string (default 100; max 1000)

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Response:**

* `200: OK`

```json
[
    {
        "orderId": 499902955766523648,
        "orderIdString": "499902955766523648", // Character String Type Order ID (Recommended)
        "symbol": "BHTUSDT",
        "price": "0.01",
        "origQty": "50",
        "executedQty": "0",
        "avgPrice": "0",
        "status": "NEW",
        "type": "LIMIT",
        "side": "BUY",
        "time": "1574329076202"
    }
]
```

#### Response Fields

* **orderId**: long - ID of the order
* **orderIdString**: string - Character String Type Order ID (Recommended)
* **clientOrderId**: string - Unique ID of the order
* **symbol**: string - Name of the symbol
* **price**: float - Price of the order
* **origQty**: float - Quantity ordered
* **executedQty**: float - Quantity of orders that have been executed
* **avgPrice**: float - Average price of filled orders
* **type**: string - Order type (LIMIT, MARKET)
* **side**: string - Order side (BUY, SELL)
* **status**: string - Order status (NEW, PARTIALLY\_FILLED, FILLED, CANCELED, REJECTED)
* **time**: string - Creation Time

***

### Trades

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/myTrades`

**Query Parameters:**

* **symbol**: string (required) - Symbol Name (e.g., BTC

USDT)

* **limit**: string (default 100; max 1000)
* **fromId**: string - Trade Id to fetch from

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Response:**

* `200: OK`

```json
[
  {
    "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",
    "bidUserId": 23334,
    "askUserId": 44112
  }
]
```

#### Response Fields

* **symbol**: string - Name of the symbol (e.g., BTCUSDT)
* **id**: integer - Trade ID
* **bidId**: long - Bid Order ID
* **askId**: long - Ask Order ID
* **price**: float - Price of the trade
* **qty**: float - Quantity of the trade
* **time**: long - Timestamp of the trade
* **isBuyer**: bool - true = Buyer, false = Seller
* **isMaker**: bool - true = Maker, false = Taker
* **feeCoin**: string - Trading fee coin
* **fee**: float - Trading fee
* **bidUserId**: long - Buyer UID
* **askUserId**: long - Seller UID
* **isSelf**: bool - true = Self-dealt

***

## Account

### Account Information

**Endpoint:**

`GET https://openapi.fokawa.com/sapi/v1/account`

**Headers:**

* **X-CH-APIKEY**: string - Your API-key
* **X-CH-TS**: string - Timestamp
* **X-CH-SIGN**: string - Sign

**Response:**

* `200: OK` - Successfully retrieved account information

```json
{
    "balances": [
        {
            "asset": "BTC",
            "free": "0",
            "locked": "0"
        },
        {
            "asset": "ETH",
            "free": "0",
            "locked": "0"
        }
    ]
}
```

#### Response Fields

* **balances**: list - Show balance details
  * **asset**: string - Name of the asset (e.g., USDT)
  * **free**: float - Amount available for use
  * **locked**: float - Amount locked (for open orders)
