# Futures

**Public** Security: None Endpoints under the Public section can be accessed freely without requiring any API-key or signatures.

#### Test Connectivity

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/ping`

This endpoint checks connectivity to the host.

**Response Example:**

```json
{}
```

#### Check Server Time

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/time`

**Response Example:**

```json
{
    "serverTime": 1607702400000,
    "timezone": "China standard time"
}
```

#### Contract List

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/contracts`

**Response Example:**

```json
[
    {
        "symbol": "H-HT-USDT",
        "pricePrecision": 8,
        "side": 1,
        "maxMarketVolume": 100000,
        "multiplier": 6,
        "minOrderVolume": 1,
        "maxMarketMoney": 10000000,
        "type": "H",
        "maxLimitVolume": 1000000,
        "maxValidOrder": 20,
        "multiplierCoin": "HT",
        "minOrderMoney": 0.001,
        "maxLimitMoney": 1000000,
        "status": 1
    }
]
```

#### Market

Security: None Market section can be accessed freely without requiring any API-key or signatures.

**Depth**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/depth`

**Query Parameters:**

* `limit`: Integer (Default 100, Max 100)
* `contractName`: String (Contract Name, e.g., E-BTC-USDT)

**Response Example:**

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

**24hrs Ticker**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/ticker`

**Query Parameters:**

* `contractName`: String (Contract Name, e.g., E-BTC-USDT)

**Response Example:**

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

**Get Index/Marked Price**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/index`

**Query Parameters:**

* `contractName`: String (Contract Name, e.g., E-BTC-USDT)
* `limit`: String (Default 100, Max 100)

**Response Example:**

```json
{
    "markPrice": 581.5,
    "indexPrice": 646.3933333333333,
    "lastFundingRate": 0.001,
    "contractName": "E-ETH-USDT",
    "time": 1608273554063
}
```

**Kline/Charts Data**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/klines`

**Query Parameters:**

* `contractName`: String (Contract Name, e.g., E-BTC-USDT)
* `interval`: String (K-line interval, e.g., 1min, 5min, 15min, 30min, 1h, 1day, 1week, 1month)
* `limit`: Integer (Default 100, Max 300)

**Response Example:**

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

**Trading** Security: TRADE All interfaces under the transaction require signature and API-key verification.

**Order Creation**

**POST**\
`https://futuresopenapi.fokawa.com/fapi/v1/order`

Creation of single new orders.

**Headers:**

* `X-CH-TS`: String (Timestamp)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-SIGN`: String (Signature)

**Request Body:**

* `volume`: Number (Order quantity)
* `price`: Number (Order price)
* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `type`: String (Order type, LIMIT/MARKET)
* `side`: String (Trade direction, BUY/SELL)
* `open`: String (Open balancing direction, OPEN/CLOSE)
* `positionType`: Number (Hold-up position, 1 full position, 2 restrictive position)
* `clientOrderId`: String (Client order identity, a string with length less than 32 characters)
* `timeInForce`: String (IOC, FOK, POST\_ONLY)

**Response Example:**

```json
{
    "orderId": 256609229205684228
}
```

**Condition Order Creation**

**POST**\
`https://futuresopenapi.fokawa.com/fapi/v1/conditionOrder`

**Headers:**

* `X-CH-TS`: String (Timestamp)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-SIGN`: String (Signature)

**Request Body:**

* `volume`: Number (Order quantity)
* `triggerType`: String (Trigger type 3UP/4DOWN)
* `triggerPrice`: String (Trigger price)
* `positionType`: Number (Hold-up position, 1 full position, 2 restrictive position)
* `open`: String (Open balancing direction, OPEN/CLOSE)
* `side`: String (Trade direction, BUY/SELL)
* `type`: String (Order type, LIMIT/MARKET)
* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `price`: Number (Order price)

**Response Example:**

```json
{
     "orderId": 256609229205684228
}
```

**Cancel Order**

**POST**\
`https://futuresopenapi.fokawa.com/fapi/v1/cancel`

**Speed Limit Rules:** 20 times/2s

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: Integer (Timestamp)

**Request Body:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `orderId`: String (Order ID)

**Response Example:**

```json
{
    "orderId": 256609229205684228
}
```

**Order Details**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/order`

**Query Parameters:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)

**Response Example:**

```json
[
    {
       "side": "BUY",
       "executedQty": 0,
       "orderId": 259396989397942275,
       "price": 10000.0000000000000000,
       "origQty": 1.0000000000000000,
       "avgPrice": 0E-8,
       "transactTime": "1607702400000",
       "action": "OPEN",
       "contractName": "E-BTC-USDT",
       "type": "LIMIT",
       "status": "INIT"
    }
]
```

**Open Order**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/openOrders`

**Speed Limit Rules:** Obtain open contract, the user's current order.

**Query Parameters:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: Integer (Timestamp)

**Response Example:**

```json
[
    {
       "side": "BUY",
       "executedQty": 0,
       "orderId": 259396989397942275,
       "price": 10000.0000000000000000,
       "origQty":

 1.0000000000000000,
       "avgPrice": 0E-8,
       "transactTime": "1607702400000",
       "action": "OPEN",
       "contractName": "E-BTC-USDT",
       "type": "LIMIT",
       "status": "INIT"
    }
]
```

**Order History**

**POST**\
`https://futuresopenapi.fokawa.com/fapi/v1/orderHistorical`

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: String (Timestamp)

**Request Body:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `limit`: String (Lines per page, default 100, max 1000)
* `fromId`: Long (Start retrieving from this Id)

**Response Example:**

```json
[
    {
        "side":"BUY",
        "clientId":"0",
        "ctimeMs":1632903411000,
        "positionType":2,
        "orderId":777293886968070157,
        "avgPrice":41000,
        "openOrClose":"OPEN",
        "leverageLevel":26,
        "type":4,
        "closeTakerFeeRate":0.00065,
        "volume":2,
        "openMakerFeeRate":0.00025,
        "dealVolume":1,
        "price":41000,
        "closeMakerFeeRate":0.00025,
        "contractId":1,
        "ctime":"2021-09-29T16:16:51",
        "contractName":"E-BTC-USDT",
        "openTakerFeeRate":0.00065,
        "dealMoney":4.1,
        "status":4
    }
]
```

**Profit History**

**POST**\
`https://futuresopenapi.fokawa.com/fapi/v1/profitHistorical`

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: String (Timestamp)

**Request Body:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `limit`: String (Lines per page, default 100, max 1000)
* `fromId`: Long (Start retrieving from this Id)

**Response Example:**

```json
[
    {
        "side":"SELL",
        "positionType":2,
        "tradeFee":-5.23575,
        "realizedAmount":0,
        "leverageLevel":26,
        "openPrice":44500,
        "settleProfit":0,
        "mtime":1632882739000,
        "shareAmount":0,
        "openEndPrice":44500,
        "closeProfit":-45,
        "volume":900,
        "contractId":1,
        "historyRealizedAmount":-50.23575,
        "ctime":1632882691000,
        "id":8764,
        "capitalFee":0
    }
]
```

**Order Record**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/myTrades`

**Query Parameters:**

* `contractName`: String (Contract name, e.g., E-BTC-USDT)
* `limit`: String (Lines per page, default 100, max 1000)
* `fromId`: Long (Start retrieving from this tradeId)

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: String (Timestamp)

**Response Example:**

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

#### Account

Security: USER\_DATA All interfaces under the account require signature and API-key verification.

**Account Info**

**GET**\
`https://futuresopenapi.fokawa.com/fapi/v1/account`

**Headers:**

* `X-CH-SIGN`: String (Signature)
* `X-CH-APIKEY`: String (Your API-key)
* `X-CH-TS`: Integer (Timestamp)

**Response Example:**

```json
{
    "account": [
        {
            "marginCoin": "USDT",
            "accountNormal": 999.5606,
            "accountLock": 23799.5017,
            "partPositionNormal": 9110.7294,
            "totalPositionNormal": 0,
            "achievedAmount": 4156.5072,
            "unrealizedAmount": 650.6385,
            "totalMarginRate": 0,
            "totalEquity": 99964804.560,
            "partEquity": 13917.8753,
            "totalCost": 0,
            "sumMarginRate": 873.4608,
            "positionVos": [
                {
                    "contractId": 1,
                    "contractName": "E-BTC-USDT",
                    "contractSymbol": "BTC-USDT",
                    "positions": [
                        {
                            "id": 13603,
                            "uid": 10023,
                            "contractId": 1,
                            "positionType": 2,
                            "side": "BUY",
                            "volume": 69642.0,
                            "openPrice": 11840.2394,
                            "avgPrice": 11840.3095,
                            "closePrice": 12155.3005,
                            "leverageLevel": 24,
                            "holdAmount": 7014.2111,
                            "closeVolume": 40502.0,
                            "pendingCloseVolume": 0,
                            "realizedAmount": 8115.9125,
                            "historyRealizedAmount": 1865.3985,
                            "tradeFee": -432.0072,
                            "capitalFee": 2891.2281,
                            "closeProfit": 8117.6903,
                            "shareAmount": 0.1112,
                            "freezeLock": 0,
                            "status": 1,
                            "ctime": "2020-12-11T17:42:10",
                            "mtime": "2020-12-18T20:35:43",
                            "brokerId": 21,
                            "marginRate": 0.2097,
                            "reducePrice": 9740.8083,
                            "returnRate": 0.3086,
                            "unRealizedAmount": 2164.5289,
                            "openRealizedAmount": 2165.0173,
                            "positionBalance": 82458.2839,
                            "settleProfit": 0.4883,
                            "indexPrice": 12151.1175,
                            "keepRate": 0.005,
                            "maxFeeRate": 0.0025
                        }
                    ]
                }
            ]
        }
    ]
}
```
