Spot trading
Spot web API V1
Introduction
- The base endpoint is: https://api.infinex.cc/spot
- All parameters should be encoded as JSON object and sent in request body using the POST method
- Some endpoints will require an API Key, which can be generated in the Infinex account settings
- Never share your API key to ANYONE
Error handling
Each API response contains a success
(boolean) field. When success
is false
, the error
(string) field with the error description is also included.
Example success response:
{ "success": true }
{ "success": false, "error": "Missing data" }
In addition, various HTTP errors may occur, e.g. 404
if the endpoint does not exist or 500
if API is unavailable due to some backend malfunction. If the status is not 200
, the contents of response body is unpredictable and should be ignored.
Endpoints list
Markets list and price tickers
POST /markets
POST /markets_ex
markets_ex
provide more detailed data. This endpoints returns a maximum of 50 records. Use the offset field to get the next part of data.Request parameters:
Parameter | Type | Description |
---|---|---|
pair |
string |
Optional. Provide pair symbol if you want to get informations only about single pair |
quote |
string |
Optional. Provide quote asset symbol if you want to get informations only about pair quoted to this asset |
search |
string |
Optional. Provide arbitrary string to search in markets list |
sort |
string |
Optional. Sort response items by: name , price , change or volume |
sort_dir |
string |
Optional. Sort direction: asc or desc |
offset |
int |
Optional. Number of rows to skip. |
offset
is required if nopair
is set- Only one of
pair
,quote
,search
can be specified in single request sort
can't be used ifpair
is specified
Response: markets
- array of market objects which contains following fields:
Field | Type | Description |
---|---|---|
pair |
string |
Pair symbol |
base |
string |
Base asset symbol |
quote |
string |
Quote asset symbol |
icon_url |
string |
Base asset icon URL |
price |
string |
Current market price |
change |
string |
Percentage price change in last 24 hours, can be negative |
previous |
string |
Previous market price, can be used to determinate color of displayed price |
markets_ex
endpoint includes additional data:
Field | Type | Description |
---|---|---|
base_name |
string |
Full name of base asset |
quote_name |
string |
Full name of quote asset |
base_precision |
int |
Number of decimal places of base asset |
quote_precision |
int |
Number of decimal places of quote asset |
high |
string |
Highest price for last 24 hours |
low |
string |
Lowest price for last 24 hours |
vol_base |
string |
24 hours trading volume in base asset |
vol_quote |
string |
24 hours trading volume in quote asset |
min_order |
string |
Minimal order quantity in quote asset |
Request example:
curl -X POST https://api.infinex.cc/spot/markets_ex -H 'Content-Type: application/json' -d '{"offset": 0}'
{
"success": true,
"markets": [
{
"pair": "BPX/USDT",
"base": "BPX",
"quote": "USDT",
"icon_url": "/ico/bpx.svg",
"price": "0.001",
"change": "0",
"previous": "0.001",
"base_name": "BPX",
"quote_name": "Tether",
"base_precision": 2,
"quote_precision": 6,
"high": "0.001",
"low": "0.001",
"vol_base": "0",
"vol_quote": "0",
"min_order": "3"
},
{
"pair": "BTC/BPX",
"base": "BTC",
"quote": "BPX",
"icon_url": "/ico/btc.svg",
"price": "2.34",
"change": "0",
"previous": "2.34",
"base_name": "Bitcoin",
"quote_name": "BPX",
"base_precision": 3,
"quote_precision": 1,
"high": "2.34",
"low": "2.34",
"vol_base": "0",
"vol_quote": "0",
"min_order": "10"
}
]
}
Aggregated order book
POST /orderbook
Request parameters:
Parameter | Type | Description |
---|---|---|
pair |
string |
Required. Trading pair symbol |
Response: bids
and asks
- arrays of orderbook row objects which contains following fields:
Field | Type | Description |
---|---|---|
price |
string |
Price level |
amount |
string |
Aggregated orders amount |
Request example:
curl -X POST https://api.infinex.cc/spot/orderbook -H 'Content-Type: application/json' -d '{"pair": "BPX/USDT"}'
{
"success": true,
"bids": [
{
"price": "0.05",
"amount": "474755.0000"
},
{
"price": "0.02",
"amount": "150.0000"
}
],
"asks": [
{
"price": "0.06",
"amount": "1890.1668"
},
{
"price": "0.07",
"amount": "2500.0000"
},
{
"price": "0.10",
"amount": "10000.0000"
}
]
}
Market trades
POST /trades
Request parameters:
Parameter | Type | Description |
---|---|---|
pair |
string |
Required. Trading pair symbol. |
offset |
int |
Required. Number of rows to skip. |
Response: trades
- array of trade objects which contains following fields:
Field | Type | Description |
---|---|---|
time |
string |
Unix timestamp |
price |
string |
Trade price |
amount |
string |
Trade amount in base asset |
total |
string |
Trade amount in quote asset |
side |
string |
BUY or SELL * |
*Each trade is both a sale and a purchase, but this field contains information about what type of order triggered this trade. This information is needed to set the proper color of the text.
Request example:
curl -X POST https://api.infinex.cc/spot/trades -H 'Content-Type: application/json' -d '{"pair": "BPX/USDT", "offset": 0}'
{
"success": true,
"trades": [
{
"time": "1653823541.689083",
"price": "0.06",
"amount": "166.6666",
"total": "10.00",
"side": "BUY"
},
{
"time": "1653780231.798744",
"price": "0.06",
"amount": "53.0000",
"total": "3.18",
"side": "BUY"
},
{
"time": "1653741501.810590",
"price": "0.06",
"amount": "69.1666",
"total": "4.15",
"side": "BUY"
}
]
}
Candlestick / K-Lines / OHLCV data
POST /candlestick
from
and to
fields to get next part of data.Request parameters:
Parameter | Type | Description |
---|---|---|
pair |
string |
Required. Trading pair symbol. |
res |
string |
Required. Time buckets resolution: 1 - 1 minute, 60 - 1 hour, 1D - 1 day. |
from |
int |
Required. Unix timestamp. Fetch the data from this point in time. |
to |
int |
Required. Unix timestamp. Fetch the data to this point in time. |
Response: candlestick
- array of candlestick objects which contains following fields:
Field | Type | Description |
---|---|---|
time |
string |
Time bucket unix timestamp |
open |
string |
Open price of time bucket |
high |
string |
Highest price in time bucket |
low |
string |
Lowest price in time bucket |
close |
string |
Close price of time bucket |
volume |
string |
Trading volume during time bucket |
Request example:
curl -X POST https://api.infinex.cc/spot/candlestick -H 'Content-Type: application/json' -d '{"pair": "BPX/USDT", "res": "1D", "from": 1641031490, "to": 1656673495}'
{
"success": true,
"candlestick": [
{
"time": "1653177600.000000",
"open": "20",
"high": "1515",
"low": "20",
"close": "125",
"volume": "8543.0098"
},
{
"time": "1653264000.000000",
"open": "147",
"high": "1514.9",
"low": "1.01",
"close": "1.01",
"volume": "967.8646"
}
]
}
My open orders
POST /spot/open_orders
offset
field to get next part of data.Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
offset |
int |
Required. Number of rows to skip. |
filter_pair |
string |
Optional. Provide pair symbol to filter only this pair orders. |
sort_pair |
string |
Optional. Provide pair symbol to push orders of this pair to the top of the list. |
filter_pair
andsort_pair
can't be used at once
Response: orders
- array of order objects which contains following fields:
Field | Type | Description |
---|---|---|
obid |
int |
Unique order ID |
pair |
string |
Pair symbol |
time |
string |
Unix timestamp |
side |
string |
BUY or SELL |
price |
string |
Order price |
amount |
string |
Order amount |
time_in_force |
string |
GTC , FOK or IOC - order time in force setting |
type |
string |
Order type: LIMIT , MARKET or STOP_LIMIT |
quote_prec |
string |
Number of decimal places of quote asset |
filled |
string |
Filled order amount. Optional: does not occur for a stop limit order that has not yet been triggered |
stop |
string |
Stop price. Optional: does not occur for orders other than stop limit |
Request example:
curl -X POST https://api.infinex.cc/spot/open_orders -H 'Content-Type: application/json' -d '{"api_key": "00000000000000000000", "offset": 0}'
{
"success": true,
"orders": [
{
"obid": 903,
"pair": "DASH/BTC",
"time": "1653821715.093741",
"side": "SELL",
"price": "0.0000000003",
"amount": "10",
"filled": "0",
"time_in_force": "GTC",
"type": "LIMIT",
"quote_prec": 10
}
]
}
My orders history
POST /orders_history
offset
field to get next part of data.Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
offset |
int |
Required. Number of rows to skip. |
filter_pair |
string |
Optional. Provide pair symbol to filter only this pair orders. |
Response: orders
- array of order objects which contains following fields:
Field | Type | Description |
---|---|---|
trades |
array<object> |
Trades related to this order. |
obid |
int |
Unique order ID |
pair |
string |
Pair symbol |
time |
string |
Unix timestamp |
side |
string |
BUY or SELL |
time_in_force |
string |
GTC , FOK or IOC - order time in force setting |
type |
string |
Order type: LIMIT , MARKET or STOP_LIMIT |
status |
string |
Order status: OPEN , FILLED , CANCELED or KILLED |
quote_prec |
string |
Number of decimal places of quote asset |
base |
string |
Base asset symbol |
quote |
string |
Quote asset symbol |
price |
string |
Order price. Optional: does not occur for market price orders |
amount |
string |
Order amount. Optional: does not occur for market orders, when the user has specified the total value he wants to receive instead of amount |
total |
string |
Order total value. Optional: only in market orders based on total value instead of amount |
filled |
string |
Filled order amount. Optional: does not occur for a stop limit order that has not yet been triggered |
stop |
string |
Stop price. Optional: does not occur for orders other than stop limit |
trades
is an array of trade objects which contains following fields:
Field | Type | Description |
---|---|---|
time |
string |
Unix timestamp |
fee |
string |
Maker/taker fee amount |
price |
string |
Trade price |
amount |
string |
Trade amount |
total |
string |
Trade total value |
role |
string |
MAKER or TAKER |
Request example:
curl -X POST https://api.infinex.cc/spot/orders_history -H 'Content-Type: application/json' -d '{"api_key": "00000000000000000000", "offset": 0}'
{
"success": true,
"orders": [
{
"trades": [
{
"time": "1653823558.258593",
"fee": "0.00000027",
"price": "25500",
"amount": "0.0003",
"total": "7.65",
"role": "TAKER"
}
],
"obid": 920,
"pair": "BTC/USDT",
"time": "1653823558.243453",
"side": "BUY",
"total": "10",
"filled": "0.0003",
"time_in_force": "FOK",
"type": "MARKET",
"status": "FILLED",
"quote_prec": 6,
"base": "BTC",
"quote": "USDT"
},
{
"trades": [],
"obid": 903,
"pair": "DASH/BTC",
"time": "1653821715.093741",
"side": "SELL",
"price": "0.0000000003",
"amount": "10",
"filled": "0",
"time_in_force": "GTC",
"type": "LIMIT",
"status": "OPEN",
"quote_prec": 10,
"base": "DASH",
"quote": "BTC"
}
]
}
My trades history
POST /trades_history
offset
field to get next part of data.Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
offset |
int |
Required. Number of rows to skip. |
filter_pair |
string |
Optional. Provide pair symbol to filter only this pair orders. |
Response: trades
- array of trade objects which contains following fields:
Field | Type | Description |
---|---|---|
time |
string |
Unix timestamp |
pair |
string |
Pair symbol |
fee |
string |
Maker/taker fee amount |
price |
string |
Trade price |
amount |
string |
Trade amount |
total |
string |
Trade total value |
role |
string |
MAKER or TAKER |
side |
string |
BUY or SELL |
Request example:
curl -X POST https://api.infinex.cc/spot/trades_history -H 'Content-Type: application/json' -d '{"api_key": "00000000000000000000", "offset": 0}'
{
"success": true,
"trades": [
{
"time": "1653823558.258593",
"pair": "BTC/USDT",
"fee": "0.00000027",
"price": "25500",
"amount": "0.0003",
"total": "7.65",
"role": "TAKER",
"side": "BUY"
},
{
"time": "1653823555.164274",
"pair": "BTC/USDT",
"fee": "0.00000027",
"price": "25500",
"amount": "0.0003",
"total": "7.65",
"role": "TAKER",
"side": "BUY"
},
{
"time": "1653823552.044859",
"pair": "BTC/USDT",
"fee": "0.00000027",
"price": "25500",
"amount": "0.0003",
"total": "7.65",
"role": "TAKER",
"side": "BUY"
}
]
}
Post new order
POST /spot/open_orders/new
Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
pair |
string |
Required. Pair symbol. |
side |
string |
Required. BUY or SELL |
type |
string |
Required. MARKET , LIMIT or STOP_LIMIT |
time_in_force |
string |
Required. GTC , FOK or IOC |
price |
string |
Optional. Order price. Not required for market price order. |
amount |
string |
Optional. Order amount. Not required for market price order if total was provided. |
total |
string |
Optional. Order total value. Not required for limit and stop limit orders, and for market order if amount was provided. |
stop |
string |
Optional. Order stop price. Not required for orders other than stop limit. |
resp_type |
string |
Optional. Response type. NONE , ACK or RESULT . Default NONE if not set |
Response: If resp_type
= NONE
or not set, this endpoint returns success if the order has been correctly sent to the Matching Engine. Any errors occured during order processing by the matching engine will not be included in the response of this function. Success response does not guarantee that the order was accepted. You should subscribe to the event stream from the matching engine for more details.
If resp_type
= ACK
, this endpoint is waiting for the accept/reject event from the matching engine and returns it. Success response guarantees that the order has been posted to the orderbook, but does not provide information that it has been filled partially / filled in total / canceled / killed etc. If your order is rejected, e.g. due to insufficient account balance, you will receive an error response. This response type also contains the obid
of the posted order.
If resp_type
= RESULT
, this endpoint is waiting for the execution result event from the matching engine and returns it. Success response guarantees that the order has been posted to the orderbook. Response also provides information that it has been filled partially / filled in total / canceled / killed etc. If your order is rejected, e.g. due to insufficient account balance, you will receive an error response. This response type also contains the obid
of the posted order.
Request example:
curl -X POST https://api.infinex.cc/spot/open_orders/new -H 'Content-Type: application/json' -d '{"api_key": "00000000000000000000", "pair": "BPX/USDT", "side": "BUY", "type": "MARKET", "time_in_force": "FOK", "amount": "100.50"}'
{
"success": true
}
{
"obid": 955,
"status": "OPEN",
"success": true
}
{
"obid": 956,
"status": "FILLED",
"filled": "150",
"success": true
}
Cancel order
POST /open_orders/cancel
Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
obid |
int |
Required. Unique order id. |
Response: This endpoint returns success if the order cancel request has been correctly sent to the Matching Engine. Any errors occured during order cancelation processing by the matching engine will not be included in the response of this function. Success response does not guarantee that the order was canceled. You should subscribe to the event stream from the matching engine.
Request example:
curl -X POST https://api.infinex.cc/spot/open_orders/cancel -H 'Content-Type: application/json' -d '{"api_key": "00000000000000000000", "obid": 20}'
{
"success": true
}
Spot WebSocket streams V1
Introduction
- The base endpoint is: wss://stream.infinex.cc
- Private streams will require an API Key, which can be generated in the Infinex account settings
- Never share your API key to ANYONE
Request/response
Each request sent to the WebSocket server must contain a type of operation (op
) and a unique request ID (id
). It's best to start with 1 and after each request increase this value by 1.
Sample request:
{ "op": "ping", "id": 220 }
class
=resp
, the same id
as previously sent in the request, and a success
(boolean) field. When success
is false
, the error
(string) field with the error description is also included.Sample response for success:
{ "class": "resp", "id": 220, "success": true }
{ "class": "resp", "id": 220, "success": false, "error": "Missing data" }
Available operations
The WebSocket server supports only 4 basic operations (op
):
Ping
Check if the connection is still alive.
Request parameters: None
Response: Only success/error.
Request example:
{ "op": "ping", "id": 1 }
{ "class": "resp", "id": 1, "success": true }
Auth
Log in to be able to subscribe to private streams.
Request parameters:
Parameter | Type | Description |
---|---|---|
api_key |
string |
Required. Account API key. |
Response: Only success/error.
Request example:
{ "op": "auth", "api_key": "00000000000000000000000000000", "id": 2 }
{ "class": "resp", "id": 2, "success": true }
Subscribe
Subscribe to the stream or many streams.
Request parameters:
Parameter | Type | Description |
---|---|---|
streams |
string /array<string> |
Required. Stream names. |
Response: Only success/error.
Request example:
{ "op": "sub", "streams": [ "BPX/USDT@tickerEx", "BTC/USDT@ticker" ], "id": 3 }
{ "class": "resp", "id": 3, "success": true }
Unsubscribe
Unsubscribe from the stream or many streams.
Request parameters:
Parameter | Type | Description |
---|---|---|
streams |
string /array<string> |
Required. Stream names. |
Response: Only success/error.
Request example:
{ "op": "unsub", "streams": "BPX/USDT@tickerEx", "id": 4 }
{ "class": "resp", "id": 4, "success": true }
Event streaming
When you subscribe to a stream, the WebSocket server will push updates to you when an event occurs on the stream you subscribed to.
Each such message contains class
=data
and the stream name (stream
).
Sample event message:
{ "class": "data", "stream": "BPX/USDT@ticker", "pair": "BPX/USDT", "price": "0.0123", "change": 10, "previous": "0.0122" }
Available streams
Market trade
<pair>@marketTrade
BPX/USDT@marketTrade
BTC/USDT@marketTrade
ETH/BTC@marketTrade
Message fields:
Field | Type | Description |
---|---|---|
time |
int |
UNIX timestamp of trade |
price |
string |
Trade price |
amount |
string |
Trade amount in base asset. |
total |
string |
Trade total value in quote asset. |
side |
string |
Taker BUY or SELL |
pair |
string |
Trading pair symbol. |
Example message:
{
"class": "data",
"stream": "BPX/USDT@marketTrade",
"time": 1677849500,
"price": "0.0123",
"amount": "100",
"total": "1.23",
"pair": "BPX/USDT"
}
Candlestick
<pair>@candleStick/<resolution>
BPX/USDT@candleStick/1
BTC/USDT@candleStick/60
ETH/BTC@candleStick/1D
1
- 1 minute, 60
- 1 hour or 1D
- 1 day.Message fields:
Field | Type | Description |
---|---|---|
time |
int |
UNIX timestamp of candle start |
pair |
string |
Trading pair symbol. |
open |
string |
Candle open price. |
high |
string |
Candle highest price. |
low |
string |
Candle lowest price. |
close |
string |
Candle close price. |
volume |
string |
Candle volume in base asset. |
Example message:
{
"class": "data",
"stream": "BPX/USDT@candleStick/1D",
"time": 1677849500,
"pair": "BPX/USDT",
"open": "0.0123",
"close": "0.0215",
"high": "0.03",
"low": "0.0123",
"volume": "15015.3",
}
Ticker
<pair>@ticker
BPX/USDT@ticker
BTC/USDT@ticker
ETH/BTC@ticker
Message fields:
Field | Type | Description |
---|---|---|
pair |
string |
Trading pair symbol. |
price |
string |
New market price |
change |
int |
Percentage price change in last 24 hours |
previous |
string |
Previous market price. |
Example message:
{
"class": "data",
"stream": "BPX/USDT@ticker",
"pair": "BPX/USDT",
"price": "0.0123",
"change": -50,
"previous": "0.022",
}
Extended ticker
<pair>@tickerEx
BPX/USDT@tickerEx
BTC/USDT@tickerEx
ETH/BTC@tickerEx
@ticker
stream + some extended informations.Message fields:
Field | Type | Description |
---|---|---|
pair |
string |
Trading pair symbol. |
price |
string |
New market price |
change |
int |
Percentage price change in last 24 hours |
previous |
string |
Previous market price. |
high |
string |
The highest price in last 24 hours. |
low |
string |
The lowest price in last 24 hours. |
vol_base |
string |
Last 24 hours volume in base asset. |
vol_quote |
string |
Last 24 hours volume in quote asset. |
Example message:
{
"class": "data",
"stream": "BPX/USDT@ticker",
"pair": "BPX/USDT",
"price": "0.0123",
"change": -50,
"previous": "0.022",
"high": "0.031",
"low": "0.0123",
"vol_base": "15000.55",
"vol_quote": "330.01"
}
Order book
<pair>@orderBook
BPX/USDT@orderBook
BTC/USDT@orderBook
ETH/BTC@orderBook
Message fields:
Field | Type | Description |
---|---|---|
pair |
string |
Trading pair symbol. |
amount |
string |
New amount for given price level. A value of zero means that the price level no longer exists. |
price |
string |
Price level |
side |
string |
Orderbook side: BUY or SELL |
Example message:
{
"class": "data",
"stream": "BPX/USDT@orderBook",
"pair": "BPX/USDT",
"amount": "0",
"price": "0.022",
"side": "SELL"
}
My orders
This stream is private. You cannot subscribe it before performing the auth
operation.
myOrders
Message fields:
Field | Type | Description |
---|---|---|
event |
string |
Event type: orderAccepted , orderRejected , orderUpdate . |
pair |
string |
Trading pair symbol. |
obid |
int |
Optional. Order unique ID. |
side |
string |
Optional. Order side: BUY or SELL |
type |
string |
Optional. Order type: MARKET , LIMIT , STOP_LIMIT |
time |
int |
Optional. UNIX timestamp of event. |
time_in_force |
string |
Optional. GTC , IOC or FOK |
base |
string |
Optional. Base asset symbol. |
quote |
string |
Optional. Quote asset symbol. |
price |
string |
Optional. Order price. |
amount |
string |
Optional. Order amount. |
total |
string |
Optional. Order total value. |
stop |
string |
Optional. Order stop price. |
status |
string |
Optional. Order status: OPEN , FILLED , KILLED , CANCELED . |
triggered |
bool |
Optional. True means that stop limit order was just triggered . |
filled |
string |
Optional. Filled amount. |
reason |
string |
Optional. Reason of order rejection. |
Example message:
{
amount: "1500",
class: "data",
event: "orderUpdate",
obid: 951,
pair: "BPX/USDT",
price: "0.04",
side: "BUY",
status: "CANCELED",
stream: "myOrders"
}
My trades
This stream is private. You cannot subscribe it before performing the auth
operation.
myTrades
Message fields:
Field | Type | Description |
---|---|---|
time |
int |
UNIX timestamp of the trade. |
price |
string |
Trade price. |
amount |
string |
Trade amount. |
total |
string |
Trade total value. |
side |
string |
Trade side: BUY or SELL |
pair |
string |
Trading pair symbol. |
obid |
int |
Order unique ID. |
role |
string |
MAKER or TAKER |
fee |
string |
Trade fee |
Example message:
{
amount: "30"
class: "data"
fee: "0"
obid: 957
pair: "BPX/USDT"
price: "0.1"
role: "TAKER"
side: "BUY"
stream: "myTrades"
time: "1677879562.317149"
total: "3"
}