📈Contract
Swap Contracts Trading API Documentation
side
side
The side of the trade.
BUY_OPEN
: open a long position.
SELL_CLOSE
: close a long position.
SELL_OPEN
: open a short position.
BUY_CLOSE
: close a short position.
priceType
priceType
Price types.
INPUT
: The system will use the price you entered exactly to fill the orders.
OPPONENT
: Orders will be filled using the opposite side's best quote.
For example, if you are opening 10 contracts long, the best buy price is 10 and the best sell price is 11. You will send an order buying 10 contracts at 11. If the order, is not fully filled, the rest will be left on the orderbook.
QUEUE
: Order will be send using the same side's best quote.
For example, if you are opening 10 contracts long, the best buy price is 10 and the best sell price is 11. You will be send an order buying 10 contracts at 10.
OVER
: The price will be the best opposite quote + overPrice(not a fixed value).
For example, if you are opening 10 contracts long, the best buy price is 10 and the best sell price is 11, you set the overPrice at 3. You will be send an order buying 10 contracts at (11+3)=14.
MARKET
: The price will be newest price * (1 ± 5%).
For example, if you are opening 10 contracts long, the latest price is 10. Then you will be sending out an order buying 10 contracts at (10 * 1.05)=10.5.
timeInForce
timeInForce
Time in force.
GTC
: Good till canceled. Meaning the order will stand unless otherwise cancelled.
IOC
: Immediate or cancel. Meaning the order will be cancelled if not executed immediately. Recommended if you want to fill the entire order immediately.
FOK
: Fill or kill. Meaning the order will be canceled if not immediately filled. Recommended if you want to fill as much as possible, but not necessarily all of, the order immediately.
LIMIT_MAKER
: Order will be cancelled if executed immediately.
orderType
orderType
Order type.
LIMIT
: Orders to be executed given a specified price or better.
STOP
: Order that will be triggered once it reaches the triggerPrice
.
For detailed request limit information, see brokerInfo.
Rate limiters (rateLimitType)
REQUESTS_WEIGHT
ORDERS
Rate limit intervals
SECOND
MINUTE
DAY
For example:
Public
Security Type: None
Endpoints under Public section can be accessed freely without requiring any API-key or signatures.
Get Broker Trading information (Contracts)
GET
https://api.bitflex.com/openapi/v1/brokerInfo
Get current contract trading rules.
Query Parameters
Name | Type | Description |
---|---|---|
type | string | Trade section information. Possible values include |
Response:
name | type | example | description |
---|---|---|---|
| string |
| Timezone of timestamp |
| long |
| Retrieves the current time on server (in ms). |
In the rateLimits
field: Order api request limit will be displayed.
name | type | example | description |
---|---|---|---|
| string |
| Rate Limit type |
| string |
| Rate Limit interval |
| string |
| Rate Limit value within the interval. |
In the contracts
field: All actively trading contracts will be displayed.
name | type | example | description |
---|---|---|---|
| string |
| Name of the contract. |
| string |
| Status of the contract. |
| string |
| Base Asset of the trading pair. In the case with contracts, the contract itself is the base asset. |
| float |
| Precision of the contract quantity (baseAsset). |
| string |
| Quote asset for the contract. Meaning the contract is quoted in that currency. |
| float |
| Precision of the contract price (quoteAsset). |
| string |
| Token used to settle funding and calculate PNL(profit and loss) |
| float |
| Precision of users' position margin. |
| bool |
| Whether the contract is inverse. |
| string |
| Index symbol of the underlying asset. Index price can be accessed at the |
| string |
| The multiplier of contract. |
| string |
| Whether iceberg orders are allowed. |
For filters
in contracts
field:
name | type | example | description |
---|---|---|---|
| string |
| Type of the filter. |
| float |
| Minimum price allowed |
| float |
| Maximum price allowed |
| float |
| Precision of the contract price. |
| float |
| Minimum quantity allowed |
| float |
| Maximum quantity allowed |
| float |
| Precision of the contract quantity |
| float |
| Minimum trade size (quantity * price) |
In the riskLimits
filed:
name | type | example | description |
---|---|---|---|
| float |
| Positions below this amount follows the following requirement. |
| float |
| Initial margin rate requirement. |
| float |
| Minimum maintenance margin rate requirement. |
Weight: 0
Get Contract Infomation
GET
https://api.bitflex.com/openapi/v1/contracts
Return all information regarding contracts
Insurance (PENDING)
GET
https://api.bitflex.com/openapi/contract/v1/insurance
Get current insurance funding
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Input specific symbol to return the corresponding records. If not entered, records for all symbols will be returned. E.g. |
fromId | number | Pagination, return records which id < fromId |
toId | number | Pagination, return records which id > toId. If toId is given, toId cannot be 0. |
limit | integer | Number of entries returned. Default to 20. |
Response:
name | type | example | description |
---|---|---|---|
| long |
| The ID of the record. |
| long |
| current server timestamp. |
| float |
| Balance of the insurance fund. |
| string |
| Unit of the balance.. |
Weight: 0
Funding Rate (PENDING)
GET
https://api.bitflex.com/openapi/contract/v1/fundingRate
Get current funding rate.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | The contract to be returned, If not send, records for all symbols will be returned. E.g. |
state | string | Get |
from | number | Timestamp to start |
endTime | number | Timestamp to end |
limit | integer | Number of entries returned. Default to 20. |
Response:
name | type | example | description |
---|---|---|---|
| string |
| Name of the contracts |
| long |
| Timestamp when the interval started. |
| long |
| Timestamp when the interval ended. |
| float |
| The funding rate of this interval. |
| float |
| Index price at the time of settlement. |
Weight: 0
Market
Security Type: None
Endpoints under Market section can be accessed freely without requiring any API-key or signatures.
Index
GET
https://api.bitflex.com/openapi/quote/v1/contract/index
Underlying asset index price.
Query Parameters
Name | Type | Description |
---|---|---|
symbols | string | Underlying asset symbol. If this parameter is not sent, all symbols will be returned. E.g. |
Response:
name | type | example | description |
---|---|---|---|
| float |
| The index price of the instrument. |
| float |
| The EDP (estimated delivery price of the contract). The average price of the index in the last 10 minutes. This will be the price on which the contract is going to be settled. |
Depth
GET
https://api.bitflex.com/openapi/quote/v1/contract/depth
This endpoint retrieve contract market depth data. This endpoint updates every 3s.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | The contract name for which to retrieve the order book.. E.g. |
limit | integer | The number of entries to return for bids and asks. Default 100; Max 100. |
Response:
name | type | example | description |
---|---|---|---|
| long |
| Current timestamp (ms) |
| list | (see below) | List of all bids, best bids first. See below for entry details. |
| list | (see below) | List of all asks, best asks first. See below for entry details. |
The fields bids
and asks
are lists of orderbook price level entries, sorted from best to worst.
name | type | example | description |
---|---|---|---|
| float |
| price level |
| float |
| The total quantity of orders for this price level |
Merged Depth (Recommended)
GET
https://api.bitflex.com/openapi/quote/v1/contract/depth/merged
This endpoint retrieve contract market depth data. This endpoint updates every 0.5s.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | The contract name for which to retrieve the order book.. E.g. |
limit | integer | The number of entries to return for bids and asks. Default 40; Max 40. |
Response:
name | type | example | description |
---|---|---|---|
| long |
| Current timestamp (ms) |
| list | (see below) | List of all bids, best bids first. See below for entry details. |
| list | (see below) | List of all asks, best asks first. See below for entry details. |
The fields bids
and asks
are lists of orderbook price level entries, sorted from best to worst.
name | type | example | description |
---|---|---|---|
| float |
| price level |
| float |
| The total quantity of orders for this price level |
Recent Trades List
GET
https://api.bitflex.com/openapi/quote/v1/contract/trades
Get the latest trades that have occurred for a specific contract.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Symbol Name. E.g. |
limit | integer | Number of trades returned. Default 500; Max 1000 |
Response:
name | type | example | description |
---|---|---|---|
| float |
| The price of the trade |
| long |
| Current timestamp (ms) |
| float |
| The quantity traded |
| string |
|
|
Kline/candlestick data
GET
https://api.bitflex.com/openapi/quote/v1/klines
This endpoint retrieves kline data
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Symbol Name. E.g. |
interval | string | Interval of the Kline. Possible values include: |
endTime | number | Timestamp to the last datapoint. |
limit | integer | Default 500; Max 1000 |
Response:
name | type | example | description |
---|---|---|---|
| long |
| Open Time |
| float |
| Open |
| float |
| High |
| float |
| Low |
| float |
| Close |
| float |
| Trade volume amount |
| long |
| Close time |
| float |
| Quote asset volume |
| integer |
| Number of trades |
| float |
| Taker buy base asset volume |
| float |
| Taker buy quote asset volume |
If startTime and endTime are not sent, the most recent klines are returned.
If the symbol is not sent, tickers for all symbols will be returned in an array.
base asset
means the quantity is expressed as the amount of contracts that were received by the buyer.quote asset
means the amount of tokens paid to acquire the contracts.
24hrs ticker price change statistics
GET
https://api.bitflex.com/openapi/quote/v1/contract/ticker/24hr
24 hour price change statistics. Careful when accessing this no symbol.
Path Parameters
Name | Type | Description |
---|---|---|
symbol | string | Symbol Name. E.g. |
Response:
name | type | example | description |
---|---|---|---|
| long |
| Open Time |
| string |
| Contract Name |
| float |
| Best Bid Price |
| float |
| Best Ask Price |
| float |
| Last Price |
| float |
| Open Price |
| float |
| High Price |
| float |
| Low Price |
| float |
| Trade Volume |
| float |
| Open Interets |
If the symbol is not sent, tickers for all symbols will be returned in an array.
Trade
Security Type: USER_DATA/TRADE
Endpoints under Trade require an API-key and a signature.
New Order
POST
https://api.bitflex.com/openapi/contract/v1/order
Places order for a contract. This API endpoint requires your request to be signed.
Query Parameters
Name | Type | Description |
---|---|---|
clientOrderId | string | A unique ID of the order (user defined) |
symbol | string | Name of the contract |
side | string | Direction of the order. Possible values include |
orderType | string | The order type, possible type include: |
quantity | number | The number of contracts trading. For |
price | number | Price of the order. REQUIRED for ( |
priceType | string | The price type, possible types include: |
triggerPrice | number | The price at which the trigger order will be executed. |
timeInForce | string | Time in force for |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contract. |
| float |
| Price of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| Fees incurred for this order. |
Notes:
For Market Orders, you need to set
orderType
asLIMIT
ANDpriceType
asMARKET
.You can get contracts' price, quantity precision configuration data in the
brokerInfo
endpoint.If your balance does not meet the margin requirement (which is the minimum margin requirement + open position fee + close position fee), "insufficient balance" error message will be returned.
For detailed information regarding various price types and order types. Please refer to the explanation section in the end.
Weight: 1
Query Order
GET
https://api.bitflex.com/openapi/contract/v1/getOrder
Get details on a specific order, regardless of order state.
Query Parameters
Name | Type | Description |
---|---|---|
orderType | string | The order type, possible types: |
orderId | string | Order Id. E.g. |
clientOrderId | string | Client Order Id. A unique ID of the order (user defined). E.g. |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| Fees incurred for this order. |
Weight: 1
Either
orderId
orclientOrderId
must be sentFor some historical orders
cummulativeQuoteQty
will be < 0, meaning the data is not available at this time.
Cancel Order
DELETE
https://api.bitflex.com/openapi/contract/v1/order/cancel
Cancel an active order
Query Parameters
Name | Type | Description |
---|---|---|
orderType | string | The order type, possible types: |
orderId | string | Order Id. E.g. |
clientOrderId | string | Client Order Id. A unique ID of the order (user defined). E.g. |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contract. |
| float |
| Price of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| Fees incurred for this order. |
In the fees
field:
Name | type | example | description |
---|---|---|---|
| string |
| Fee token kind. |
| float |
| Actual transaction fees occurred. |
Weight: 1
Either
orderId
orclientOrderId
must be sent
Batch Cancel
DELETE
https://api.bitflex.com/openapi/contract/v1/order/batchCancel
Cancel orders en masse. (PENDING: batch cancel for STOP orders)
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Contract Name. E.g. |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| string |
| The message response of the cancel request. |
| long |
| The timestamp when the response is returned. |
Current Open Orders
GET
https://api.bitflex.com/openapi/contract/v1/openOrders
Get all open orders on a symbol. Careful when accessing this with no symbols.
Query Parameters
Name | Type | Description |
---|---|---|
orderType | string | The order type, possible types: |
symbol | string | Symbol to return open orders for. If not sent, orders of all contracts will be returned. |
orderId | string | Order Id |
limit | integer | Default 20; Max 1000 |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| Fees incurred for this order. |
Weight: 1
If
orderId
is set, it will get orders < thatorderId
. Otherwise most recent orders are returned.
History Orders
GET
https://api.bitflex.com/openapi/contract/v1/historyOrders
Get all history orders. Careful when accessing this with no symbol.
Query Parameters
Name | Type | Description |
---|---|---|
orderType | string | The order type, possible types: |
symbol | string | Symbol Name. E.g. |
orderId | integer | Order Id. E.g. |
limit | integer | Default 500; Max 1000 |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| Fees incurred for this order. |
Weight: 5
If
orderId
is set, it will get orders < thatorderId
. Otherwise most recent orders are returned.
Trades
GET
https://api.bitflex.com/openapi/contract/v1/myTrades
Get historical trades.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Symbol Name. E.g. |
fromId | integer | Trade Id to fetch from |
toId | integer | Trade Id to fetch to |
limit | integer | Default 20; Max 1000 |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| long |
| Timestamp when the order is created. |
| long |
| The ID for the trade |
| integer |
| ID of the order. |
| string |
| Name of the contract. |
| float |
| Price of the trade. |
| float |
| Quantity of the trade. |
| string |
| Fee token name. |
| Fee of the trade. | ||
| string |
| Direction of the order. Possible values include |
| string |
| The order type, possible types: LIMIT, MARKET |
Weight: 5
If only
fromId
is set,it will get orders < thatfromId
in descending order.If only
toId
is set, it will get orders > thattoId
in ascending order.If
fromId
is set andtoId
is set, it will get orders < thatfromId
and > thattoId
in descending order.If
fromId
is not set andtoId
it not set, most recent order are returned in descending order.
Positions
GET
https://api.bitflex.com/openapi/contract/v1/positions
Retrieve current positions.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | Name of the contract. If not sent, positions for all contracts will be returned. E.g. |
side | string |
|
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| string |
| Name of the contract. |
| string |
| Position side. |
| float |
| Average price for opening the position. |
| float |
| Amount of contracts opened |
| float |
| Amount of contracts available to close. |
| float |
| Leverage of the position |
| float |
| Last trade price of the symbol. |
| float |
| Current position value. |
| float |
| Forced liquidation price. |
| float |
| Margin for this position. |
| float |
| Margin rate for current position. |
| float |
| Unrealized profit and loss for current position held. |
| float |
| Rate of return for the position. |
| float |
| Cumulative realized profit and loss for this |
Weight: 1
Modify Margin
POST
https://api.bitflex.com/openapi/contract/v1/modifyMargin
Modify margin for a specific symbol.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | The symbol's margin to be modified. E.g. |
side | string |
|
amount | number | Amount of margin to be added (Positive Value) or removed (Negative Value). Please note that this amount refers to the underlying quote asset of the asset. |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| string |
| The name of the contract. |
| float |
| Updated margin for the symbol. |
| long |
| Updated timestamp |
Weight: 1
Modify Leverage
POST
https://api.bitflex.com/openapi/contract/v1/modifyLeverage
Modify leverage for a specific symbol and position.
Query Parameters
Name | Type | Description |
---|---|---|
symbol | string | The symbol's margin to be modified. E.g. |
side | string |
|
leverage | number | Position/Symbol leverage |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| string |
| The name of the contract. |
| float |
| Updated leverage for the symbol. |
| long |
| Updated timestamp |
Account
Security Type: USER_DATA/TRADE
Endpoints under Account require an API-key and a signature.
Account Information
GET
https://api.bitflex.com/openapi/contract/v1/account
Get current contract account information (balances)
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Response:
Name | type | example | description |
---|---|---|---|
| float |
| Total balance. |
| float |
| Available margin for use. |
| float |
| Margin for positions. |
| float |
| Margin locked for open orders. |
Weight: 5
Transfer (PENDING)
POST
https://api.bitflex.com/openapi/v1/transfer
This endpoint is used to transfer funds across different accounts.
Query Parameters
Name | Type | Description |
---|---|---|
from | string | Currently supports transferring assets across |
to | string | Same as above. |
currency | string | The intended currency to transfer. ( |
amount | number | Amount of currency to transfer. |
Headers
Name | Type | Description |
---|---|---|
X-BH-APIKEY | string | Your API key |
Request Body
Name | Type | Description |
---|---|---|
signature | string | Authentication is needed for this endpoint |
timestamp | integer | Current unix timestamp(ms) |
recvWindow | integer | RecvWindow for this request. |
Weight: 1
Last updated