Introduction
Apifiny Connect™ ’s institutional-grade REST, Websocket API and FIX API gives Traders, OTC desks, Brokers, and Market Makers faster access to trade and easier reallocation of assets among a multitude of global exchanges using one consistent set of APIs.
One onboarding, Global execution. Eliminating the need to onboard with multiple exchanges, trade via just one account.
Welcome to access Apifiny Connect SDK at Github, or use command pip3 install -U apifiny
.
Change log
08/02/2022
- Support Iceberg order, see order type.
07/14/2022
- Major launch, upgrade the authentication of how to make request, check new version of the Authentication. Old version is still supported, go to the Old version.
- Upgrade the login process for websocket private channels, Log In.
06/30/2022
- Update the sandbox information, check Sandbox.
06/22/2022
- Add a new endpoint to create sub-account for each exchange, see Create-an-Account.
05/31/2022
- Support target exchanges when sending SOR order, see Trading (Algo).
05/07/2022
- Support market order for more exchange, see Order Type.
04/29/2022
- Support Smart Routing Order (SOR), see Trading (Algo).
- Update Python demo package, see Download Demo.
- Add a new endpoint: query transaction fees.
03/22/2022
- Publish FIX demo package, see Download Demo.
03/02/2022
- Support stop order, both REST and Websocket APIs, see the description in the order type.
01/08/2022
- Add a new endpoint that provides best bid/ask quotations from all connected exchanges, both REST and Websocket APIs are supported: Consolidated Order Book.
12/10/21
- Add 1 more order type: Smart Order Router, go to Create new order.
11/09/21
- Add 1 more venue: OKcoin, go to Base URLs.
10/29/21
- Add a new endpoint: Query Instant Transfer Quota.
10/28/21
- Delete redundant description.
09/16/21
- Update WebSocket API Urls, see websocket urls.
08/25/21
- Add USD USDC conversion feature, see Create Conversion.
08/20/21
- WebSocket API provides real-time communication capacity for order management.
- Add 1 more venue: FTX.com, go to Base URLs.
08/03/21
- Apifiny API (v2) is an evolutionary step up from the previous version (v1). The names of endpoints and fields are still the same, any client stack which was working with v1 should also be able to work with v2. If you are still working with the previous version, please contact us if you need the old version of v1 document.
07/02/21
- Add Account Update to websocket Data Stream: Account Update.
- Market data API updated to public data interface.
- Unified method names. Old methods names are now compatible, we recommend you to update to new method names as soon as possible.
06/24/21
- Market Data
websocket
URL Update to:wss://api.apifiny.com/md/ws/v1
.
06/01/21
- Update two endpoints: Query All Completed Order and Query List Fills.
- Add a new endpoint: Cancell All.
- Update python demo.
04/28/21
- Update the response parameter for order status push notice, added
lastCommission
,lastCommissionCurrency
,isTaker
.
04/23/21
- Update the request parameter
currency
tocoin
for get deposit address and Create a Withdraw Request.
General API Information
Professional traders can easily execute their strategies across all crypto-to-crypto and other crypto-fiat pairs. With one deposit and KYC process, traders can reallocate assets among exchanges and start trading.
A legitimate request consists of following parts:
- The base URL, (e.g. api.apifiny.com)
- Request path, including leading slash and any URL parameters but not including the hostname (e.g. /account)
- All requests and responses are application/json content type
- Request timestamp, all time related fields are in UNIX epoch time in milliseconds, e.g. 1544657947759
- Signature: required for private endpoints, users generate the signature via
HMAC SHA256
and add the signature as a parameter to each request header. - API Access Key and Secret Key
Create API Key You could create API Key under menu API Management on Apifiny web GUI.
API Key consists of the following two parts.
- "API Key", on web GUI, displayed as "Access Key".
- "Secret Key", the Key used to do Signature authentication and verification (visible when you creating it).
The Base URLs:
We offer co-location services for the clients, for the venues we offer co-location service, the base URL is different individually, it is recommended to use the special URL of each co-located exchanges regarding the order related requests to reduce the network latency. Make sure to use the right base URL accordingly. We now support 8 exchanges, more will be coming soon.
For the rest venues, use a unified URL. e.g. api.apifiny.com
About Venue:
A “venue” is an target exchange. For example: “BINANCE” is accessed by setting venue parameter to BINANCE: "venue": "BINANCE"
. Get available "venues" at Apifiny by /listVenueInfo.
Base URLs
BINANCE
REST
: https://apibn.apifiny.com/ac/v2
FIX
: fixapibn.apifiny.com:1443
Server Location
: AWS ap-northeast-1c
BINANCEUS
REST
: https://apibnu.apifiny.com/ac/v2
FIX
: fixapibnu.apifiny.com:1443
Server Location
: AWS us-east-1a
COINBASEPRO
REST
: https://apicb.apifiny.com/ac/v2
FIX
: fixapicb.apifiny.com:1443
Server Location
: AWS us-east-1a
FTX
REST
: https://apiftx.apifiny.com/ac/v2
FIX
: fixapiftx.apifiny.com:1443
Server Location
: AWS ap-northeast-1a
HUOBI
REST
: https://apihb.apifiny.com/ac/v2
FIX
: fixapihb.apifiny.com:1443
Server Location
: AWS ap-northeast-1c
KUCOIN
REST
: https://apikc.apifiny.com/ac/v2
FIX
: fixapikc.apifiny.com:1443
Server Location
: AWS ap-northeast-1c
OKX
REST
: https://apiok.apifiny.com/ac/v2
FIX
: fixapiok.apifiny.com:1443
Server Location
: Ali Hong Kong, Ali B
OKCOIN
REST
: https://apiokc.apifiny.com/ac/v2
FIX
: fixapiokc.apifiny.com:1443
Server Location
: Ali Hong Kong, Ali B
Other Venues, unified URL
The base URL is: https://api.apifiny.com/ac/v2/{target venue}
FIX
: fix.api.apifiny.com:1443
Server Location
: AWS us-east-1
the target venue is the target exchange name, see /listVenueInfo.
Make Request
A request contains: HTTP method (e.g. GET
or POST
), Base URL, Endpoint(request path, e.g. /account
) and Request parameter.
For public requests, such as Market Data, base information, see an example:
RESR API Market Data Request Example:
curl -X GET "https://api.apifiny.com/md/orderbook/v1/BTCUSDT/BINANCE"
For authenticated requests, the following parameter should be sent with the request:
Parameter | Description |
---|---|
apiKey | Your API key, displayed as the Access key on web GUI |
signature | Hash value of the request body using HMAC SHA256 , see signature |
timestamp | A timestamp for your request, number of milliseconds since Unix epoch |
recvWindow | [Optional] An additional parameter, may be sent to specify the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000 |
Standard response
All requests will have a standard response consisting of the following:
The structure of the response:
{
"result": null,
"error": {
"code": 0x02002B,
"message": "Account doesn't exist, please verify account ID"
}
}
After making an API request, the server will send back a response in JSON format. The response includes:
Parameter | Description |
---|---|
result | when the request is successful, this key will include the result of the request. When the request is not successful, its value is null. |
error | when the request is not successful, the key will give the error message. Its value is null when the request is successful. |
code | Error code. Please refer to the error code explanation section. |
message | Error message. |
Authentication
Signature
Signature Generating Method:
// js
signature = CryptoJS.HmacSHA256(request_data, Your_secret_key);
# python3
import hashlib
import hmac
import json
def gen_signature(Your_secret_key, data) -> str:
message = data.encode("utf-8")
return hmac.new(Your_secret_key.encode("utf-8"), message, digestmod=hashlib.sha256).hexdigest()
// Java
public String hmacSha256(String secretKey, String body) {
try {
Mac mac = Mac.getInstance("HmacSHA256");
SecretKey secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
mac.init(secretKeySpec);
return Hex.encodeHexString(mac.doFinal(body.getBytes()));
} catch (Exception e) {
throw new IllegalArgumentException("Invalid key for hmac initialization.", e);
}
}
Every private endpoint must be signed, private endpoints are available for order management and account balances.
- Authenticated endpoints require an additional parameter
signature
to be sent in thequeryString
orrequestBody
. - Endpoints use
HMAC SA256
signatures. signature
: theHMAC SHA256
signature is a keyed HMAC SHA256 operation. Use your Secret Key as the key andqueryString
orrequestBody
as the value for the HMAC operation to generate.- The
signature
is not case sensitive.
Here is the detailed examples below:
Example 1:
GET requests example:
# curl command
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/account/queryAccountInfo?accountId=STA-00000001&recvWindow=5000×tamp=1499827319559"
- For
GET
requests, usequeryString
as the data to generate Signature, all query parameters need to be included in the request URL. For example:
accountId=STA-00000001
&venue=BINANCE
&recvWindow=500
&recvWindow=5000
×tamp=1499827319559
Example 2:
POST requests example:
# curl command
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/withdraw" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","coin": "USDT.ETH","amount": 100.00,"address": "0x3955fefd67w45p8v","ticket": "b21987ft568ij36f","recvWindow": 5000,"timestamp": 1499827319559}'
- For
POST
requests, userequestBody
as the data to generate Signature, all query parameters need to be included in the request body with JSON. For example:
{ "accountId": "STA-00000001", "venue": "BINANCE", "coin": "USDT.ETH", "amount": 100.00, "address": "0x3955fefd67w45p8v", "ticket": "b21987ft568ij36f", "recvWindow": 5000, "timestamp": 1499827319559 }
Time security
Networks can be unstable and unreliable, with recvWindow
, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.
Time security, the logic is as follows:
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow)
{
// process request
}
else
{
// reject request
}
Time Stamp
If you get the error:"Timestamp for this request is outside of the recvWindow", you can compare the client timestamp
with our server clock, or try +/- 1 second. This is the endpoint to query our server time: /currentTimeMillis.
Rate Limits
There are throttling limits for HTTPS requests, referred to as rate limits by Account ID. These are set at 20 requests per second and will result in an error message, “rate limit is exceeded”, if breached.
Sandbox
Sandbox is the test environment, Apifiny sandbox is available for testing API connectivity and web trading.
The sandbox hosts a subset of the connected exchanges and only the BTC/USDT market data, supports most of the functionality except query address. You can claim paper money for testing.
Note that login sessions and API keys are seperate from production. Log into the sandbox web GUI to create an API key, trading, etc.
Sandbox URLs
Use the following URLs to test your API connectivity.
API | URL |
---|---|
REST API | https://api-sandbox.apifiny.com |
Websocket | wss://api-sandbox.apifiny.com |
FIX API | fix-sandbox.apifiny.com:1443 |
REST API
Base Information
There is a further set of API’s to discover basic information about venues and assets that Apifiny Connect™ supports.
Query List Venues
# URL: /utils/listVenueInfo
curl -X GET "https://api.apifiny.com/ac/v2/APIFINY/utils/listVenueInfo"
Response:
{
"result": [{
"exchange": "VENUE1", //the exchane name, e.g. BINANCE
"status": "enabled",
"sptInstant": 1,
"isColo": true
},
{
"exchange": "VENUE2",
"status": "enabled",
"sptInstant": 1,
"isColo": true
},
// ... ...
{
"exchange": "VENUE28",
"status": "disabled",
"sptInstant": 0,
"isColo": true
}
],
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/utils/listVenueInfo
Response:
Parameter | Description |
---|---|
exchange | name of the exchange |
status | exchange status, enabled or disabled |
sptInstant | exchange supports instant transfer, 1 for support, 0 for non-support |
isColo | exchange supports co-location, true or false |
Query List Currencies
# Query the Assets supported at each exchange
# URL: /utils/listCurrency
# unified
curl -X GET "https://api.apifiny.com/ac/v2/BINANCE/utils/listCurrency"
# co-located
curl -X GET "https://apibn.apifiny.com/ac/v2/utils/listCurrency"
Response:
{
"result": [{
"currency": "BTC",
"currencyPrecision": 9,
"status": "NOT_DEPOSIT_WITHDRAW",
"withdrawMaxAmount": 1000000,
"withdrawMinAmount": 0.004,
"withdrawMinFee": 0.0005,
"instantFeeRate": 0.0000,
"nextStatus": null,
"nextStatusAt": null,
"coin": "BTC"
},
{
"currency": "USDT",
"currencyPrecision": 8,
"status": "NOT_DEPOSIT_WITHDRAW",
"withdrawMaxAmount": 10000,
"withdrawMinAmount": 2,
"withdrawMinFee": 0.001,
"instantFeeRate": 0.0000,
"nextStatus": null,
"nextStatusAt": null,
"coin": "USDT.TRX"
}
],
"error": null
}
List known currencies.
HTTP Request:
GET https://api.apifiny.com/ac/v2/{target venue}/utils/listCurrency
Response:
Parameter | Description |
---|---|
currency | currency |
currencyPrecision | currency precision |
status | current status, DEPOSIT_WITHDRAW or NOT_DEPOSIT_WITHDRAW or DEPOSIT_NOT_WITHDRAW or NOT_DEPOSIT_NOT_WITHDRAW |
withdrawMaxAmount | max withdraw amount |
withdrawMinAmount | min withdraw amount |
withdrawMinFee | min withdraw fee |
instantFeeRate | the extra transfer fee rate if the transaction is "Instant" |
nextStatus | next status |
nextStatusAt | next status time |
currency status:
status | explanation |
---|---|
DEPOSIT_WITHDRAW | deposit and withdrawal are both allowed |
NOT_DEPOSIT_WITHDRAW | deposit is not allowed, withdrawal is allowed |
DEPOSIT_NOT_WITHDRAW | deposit is allowed, but withdrawal is not allowed |
NOT_DEPOSIT_NOT_WITHDRAW | deposit and withdrawal are both not allowed |
Query List Symbols
# Query the Symbols supported at each exchange
# Path: /utils/listSymbolInfo
# unified
curl -X GET "https://api.apifiny.com/ac/v2/BINANCE/utils/listSymbolInfo"
# co-located
curl -X GET "https://apibn.apifiny.com/ac/v2/utils/listSymbolInfo"
Response:
{
"result": [{
"symbol": "EOSETH",
"baseAsset": "EOS",
"baseAssetPrecision": 8,
"quoteAsset": "ETH",
"quotePrecision": 8,
"minPrice": 0.01,
"maxPrice": 99999,
"minQuantity": 0.01,
"maxQuantity": 99999,
"tickSize": 0.01,
"stepSize": 0.0001,
"minNotional": 1,
"maxNotional": 1000,
"status": "enabled"
},
{
"symbol": "BCHUSDT",
"baseAsset": "BCH",
"baseAssetPrecision": 8,
"quoteAsset": "USDT",
"quotePrecision": 8,
"minPrice": 0.01,
"maxPrice": 99999,
"minQuantity": 0.01,
"maxQuantity": 99999,
"tickSize": 0.01,
"stepSize": 0.0001,
"minNotional": 1,
"maxNotional": 1000,
"status": "enabled"
}
],
"error": null
}
Get a list of available trading pairs supported in this venue.
HTTP Request:
GET https://api.apifiny.com/ac/v2/{Venue Name}/utils/listSymbolInfo
Response:
Parameter | Description |
---|---|
symbol | symbol |
baseAsset | base asset |
baseAssetPrecision | baseAsset precision |
quoteAsset | quote asset,the right side of the symbol |
quotePrecision | quote precision |
minPrice | min price for the symbol |
maxPrice | max price for the symbol |
minQuantity | min quantity for the symbol |
maxQuantity | max quantity for the symbol |
tickSize | min price increment for the symbol |
stepSize | min quantity increment for the symbol |
minNotional | minimum notional value allowed for an order on a symbol. An order's notional value is the price * quantity |
maxNotional | maximum notional value allowed for an order on a symbol. An order's notional value is the price * quantity |
status | enabled or disabled |
Query Current Timestamp of Server
# Query the current server timestamp at each exchange
# Path: /utils/currentTimeMillis
# unified
curl -X GET "https://api.apifiny.com/ac/v2/BINANCE/utils/currentTimeMillis"
# co-located
curl -X GET "https://apibn.apifiny.com/ac/v2/utils/currentTimeMillis"
Response:
{
"result": 1552112542263,
"error": null
}
Get the API server time.
HTTP Request:
GET https://api.apifiny.com/ac/v2/{target venue}/utils/currentTimeMillis
Response:
The server timestamp
Market Data
Rate Limit: We throttle public endpoints by IP address 1 request per second
.
Order book - REST API
The RESTFul interface endpoint is:
Request URL:
GET https://api.apifiny.com/md/orderbook/v1/{SYMBOL}/{VENUE}
curl -X GET "https://api.apifiny.com/md/orderbook/v1/BTCUSD/VENUE1"
The {SYMBOL}
is the trading pairs. For example, ETHBTC.
The {VENUE}
is the exchanges. For example, VENUE1.
Response:
{
"symbol": "BTCUSD",
"updatedAt": 1621840045855,
"asks": [
[36540.0700, 0.00466900]
// [price, size]
// ……
],
"bids": [
[36538.5700, 0.00000900],
[36521.7900, 0.27496400]
]
}
# python3
res = requests.get("https://api.apifiny.com/md/orderbook/v1/{SYMBOL}/{VENUE}")
print(res.json())
Trades - REST API
Trades that filled, executed data, also known as matched orders data or active data.
Request URL:
GET https://api.apifiny.com/md/trade/v1/{SYMBOL}/{VENUE1}
curl -X GET "https://api.apifiny.com/md/trade/v1/BTCUSD/VENUE1"
The {SYMBOL}
is the trading pairs. For example, BTCUSD.
The {VENUE}
is the exchanges. For example, VENUE1.
Response:
[{
"symbol": "BTCUSD",
"provider": "Venue1",
"price": 36523.4600,
"qty": 0.05913000,
"side": "BUY",
"tradeTime": 1621840043786,
"exchangeID": "14150317",
"updateTime": 1621840043788
}]
Response:
Parameter | Description |
---|---|
symbol | symbol |
price | filled price |
qty | filled size |
side | maker order side of this fill, BUY or SELL |
tradeTime | filled time |
updateTime | updated time |
The trade side
indicates the maker order side. The maker order is the order that was open on the order book. buy
side indicates a down-tick because the maker was a buy order and their order was removed. Conversely, sell
side indicates an up-tick.
OHLCV - REST API
OHLCV (Open, High, Low, Close, Volume) time series data, also know as Kline/candlestick data. Each data point of this time series represents several indicators calculated from transactions activity inside a time range (period).
Request URL:
GET https://api.apifiny.com/md/kline/v1/{VENUE}/{BASE}/{QUOTE}/{PERIOD}
curl -X GET "https://api.apifiny.com/md/kline/v1/{VENUE}/{BASE}/{QUOTE}/{PERIOD}?startTime=1616923800000&endTime=1616937900000"
Parameter | Description |
---|---|
VENUE | Venue name |
BASE | Base asset |
QUOTE | Quote Asset |
PERIOD | The period of each candle bar, 1m , 5m , 30m , 1h , 4h , 1d , 1w , 1M |
startTime | (Optional) The start time period |
endTime | (Optional) The end time period |
*If startTime
and endTime
are not sent, the most recent klines are returned.
Response:
[
{
"currencyPair":"BTC/USDT",
"period":"1m",
"open":58053.69,
"high":58053.69,
"low":58053.69,
"close":58053.69,
"vol":0.027921,
"count":1,
"timestamp":1616140260000,
"exchange":"Venue1"
},
{
"currencyPair":"BTC/USDT",
"period":"1m",
"open":57865.28,
"high":57885.08,
"low":57865.28,
"close":57885.08,
"vol":0.068214,
"count":2,
"timestamp":1616140860000,
"exchange":"Venue1"
}]
Response:
Parameter | Description |
---|---|
currencyPair | symbol |
period | The period of each candle, 1m , 5m , 30m , 1h , 4h , 1d , 1w , 1M |
open | The opening price |
high | The closing price |
low | lowest price |
close | close price |
vol | Accumulated trading volume, in base asset |
count | The number of completed trades |
timestamp | The UNIX timestamp in seconds |
exchange | Venue name |
Support a few exchange currently: BINANCE, BINANCEUS, BITMAX(AscendEx), BITTREX, COINBASEPRO, CRYPTO, EXMO, FTX, GATEIO, HUOBI, KUCOIN, OKX, OKCOIN. Others will result in an error message.
Ticker - REST API
24 hour rolling window price change statistics for the trading pairs. volume
is in base currency units. open
, high
, low
are in quote currency units.
Request URL:
GET https://api.apifiny.com/md/ticker/v1/{SYMBOL}/{VENUE1}/
curl -X GET -H "https://api.apifiny.com/md/ticker/v1/BTCUSD/VENUE1"
The {SYMBOL}
is the trading pairs. For example, BTCUSDT.
The {VENUE}
is the exchanges. For example, VENUE1.
Response:
{
"symbol": "BTCUSD",
"open": 36720.9300,
"high": 36815.0300,
"low": 31120.0000,
"close": 36501.1200,
"vol": 5296.13216200,
"amount": 180425575.4029,
"count": 0,
"provider": "Venue1",
"tickerTime": 1621840042096,
"updateAt": 1621840042192
}
Consolidated Order book - REST API
The Consolidated Order book is a real-time data feed that provides Quotes (best bid/ask quotations) for each symbols all-across Apifiny connected exchanges. The price, size and the source venue will be returned, default 50 price levels for each side.
Response:
{
"asks": [{
"price": 46840,
"qty": 0.00004784,
"source": "HUOBI"
},
// ……
{
"price": 47040,
"qty": 0.23653,
"source": "BINANCE"
}],
"bids": [{
"price": 47039.99,
"qty": 0.007,
"source": "GATEIO"
},
// ……
{
"price": 47038.62,
"qty": 0.0161,
"source": "KUCOIN"
}],
"symbol": "BTCUSDT",
"updateAt": 1640850556984
}
# python3
res = requests.get("https://api.apifiny.com/md/cob/v1/{SYMBOL}")
print(res.json())
The RESTFul interface endpoint is:
Request URL:
GET https://api.apifiny.com/md/cob/v1/{SYMBOL}
curl -X GET "https://api.apifiny.com/md/cob/v1/BTCUSDT"
The {SYMBOL}
is the trading pairs. For example, BTCUSDT.
Account
The Account API has a number of calls to enable the user to get information about the account, to deposit and withdraw crypto from the account and interrogate the balances in the account. Only RESTful queries are supported for this set of functions.
Create an Account(For each exchange)
Apifiny creates a sub-account for each target exchange within our system, clients manage funds and orders seperately for each sub-account.
Requires Authentication.
# Create an Account: /account/createSubAccount
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/account/createSubAccount?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
Response:
{
"result": {
"accountId": "STA-BINANCE_00000001",
"venue": "BINANCE",
"accountStatus": "OPENED",
"createdAt": 1584611383104,
"updatedAt": 1584611383104,
},
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/account/createSubAccount
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | venue name, the exchange name, see List Venues. |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | account ID |
venue | venue name |
accountStatus | account status |
createdAt | creation time |
updatedAt | update time |
Account Status:
Account Status | Explanation |
---|---|
OPENED | normal |
RESTRICTED | restricted. Cannot submit order or cancel order, but can query order. |
SUSPENDED | suspended, no operations are allowed |
*Apifiny now only support 1 sub-account for each exchange.
Query Account Info
Query Account Info, a list of the exchange sub-accounts opened will be returned.
Requires Authentication.
# Query Account Info: /account/queryAccountInfo
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/account/queryAccountInfo?accountId=STA-00000001×tamp=1499827319559"
Response:
{
"result": {
"accountId": "STA-00000001",
"accountStatus": "OPENED",
"createdAt": 1537857271784,
"updatedAt": 1551956476878,
"subAccountInfo": [{
"accountId": "STA-VENUE1_00000001",
"venue": "VENUE1",
"accountStatus": "OPENED",
"createdAt": 1584611383104,
"updatedAt": 1584611383104
},
// ...
{
"accountId": "STA-VENUE2_00000001",
"venue": "VENUE2",
"accountStatus": "OPENED",
"createdAt": 1584611383104,
"updatedAt": 1584611383104
}]
},
"error": null
}
HTTP Request:
GET $Base URL/account/queryAccountInfo
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | NO | venue name, all sub-account will be returned if not sent |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | account ID |
venue | venue name |
accountStatus | account status |
createdAt | creation time |
updatedAt | update time |
Account Status:
Account Status | Explanation |
---|---|
OPENED | normal |
RESTRICTED | restricted. Cannot submit order or cancel order, but can query order. |
SUSPENDED | suspended, no operations are allowed |
Query Account Balances
Query Account Balance at each exchange. Requires Authentication.
# Query Account Asset at each exchange: /asset/listBalance
# unified
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/BINANCE/asset/listBalance?accountId=STA-00000001&venue=BINANCE&recvWindow=5000×tamp=1499827319559"
# co-located
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://apibn.apifiny.com/ac/v2/asset/listBalance?accountId=STA-00000001&venue=BINANCE&recvWindow=5000×tamp=1499827319559"
Response:
{
"result": [{
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"currency": "BTC",
"amount": 51.95,
"available": 51.95,
"frozen": 0
},
{
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"currency": "USDT",
"amount": 101.95,
"available": 51.95,
"frozen": 50
}
],
"error": null
}
HTTP Request:
GET $Base URL/asset/listBalance
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | NO | venue name, all sub-account will be returned if not sent |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | account ID |
venue | venue name |
currency | symbol of asset |
coin | currency code in system, different from currency name if multiple chains are supported |
amount | amount |
available | available quantity |
frozen | frozen value |
updatedAt | update time |
Get Deposit Address
Get deposit address for a specific crypto currency of your Apifiny account. The corresponding chain need to be specified by parameter coin
.
Requires Authentication.
# Get Deposit Address: /asset/queryAddress
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/queryAddress?accountId=STA-00000001&coin=USDT.ETH&venue=APIFINY&recvWindow=5000×tamp=1499827319559"
Response:
{
"result": {
"venue": "APIFINY",
"currency": "USDT",
"coin": "USDT.ETH",
"address": "0x3Nwna****************fp8v",
"expiredAt": 1584606409507
},
"error": null
}
// EOS
{
"result": {
"venue": "APIFINY",
"currency": "EOS",
"coin": "EOS",
"address": "acc******bnw",
"memo": "10230001",
"expiredAt": 1584606409507
},
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/asset/queryAddress
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | APIFINY |
coin | YES | currency code in system, different from currency name if multiple chains are supported |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
currency | currency name |
coin | corresponding chain information |
address | deposits address |
memo | memo or tag information, some currencies are necessary, e.g. EOS |
expiredAt | expiration time |
Allocate the funds to the target exchange sub-account after funds arrived at Apifiny. There is **0 fee* for you to allocate to sub-account, using /asset/transferToVenue.*
*Getcoin
information using /utils/listCurrency.
Create a Withdraw Ticket
Create a Withdraw Ticket. Requires Authentication.
# Create a Withdraw Ticket: /asset/createWithdrawTicket
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/createWithdrawTicket?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
Response:
{
"result": {
"ticket": "b215282*************bbe436f",
"expiredAt": 1584633883235
},
"error": null
}
You need to get a ticket before then create a withdrawal request, use /asset/withdraw. Also if your ID verification has not been approved, you will get rejection error message.
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/asset/createWithdrawTicket
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | the exchange name you withdraw funds from, e.g. Binance sub-account |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
ticket | withdraw ticket |
expiredAt | expired time |
Create a Withdraw Request
Create a Withdraw Request. A withdrawal initiate from a sub-account (e.g. Binance) will trigger 2 steps:
Step 1: System transfers the funds back to Apifiny, this will trigger a blockchain transfer from that exchange back to Apfiny; (Withdraw directly out of the Apifiny account or HEX won't trigger a transfer)
Step 2: A withdrawal request at Apifiny, the amount is the net amount arrives at Apifiny.
Requires Authentication.
# Create a Withdraw Request: /asset/withdraw
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/withdraw" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","coin": "USDT.ETH","amount": 100.00,"address": "0x3***p8v","ticket": "b21***36f","timestamp": 1499827319559}'
Request:
{
"accountId": "STA-0000001",
"venue":"BINANCE",
"coin": "USDT.ETH",
"amount": 1000.0021,
"memo": "",
"address": "0x3***p8v",
"ticket": "b21***36f",
"timestamp": 1499827319559
}
Response:
{
"result": {
"accountId": "STA-APIFINY_00000001",
"venue": "Apifiny",
"currency": "USDT",
"status": "SUBMITTED",
"type": "OUTGOING",
"amount": 44.972,
"fee": 10.0,
"coin": "USDT.ETH",
"targetAddress": "0x7Df5f**FF07",
"txId": null,
"logId": "f96c2c5a55c640698a12748336d69cf6",
"logCreatedAt": 1651050140165,
"logUpdatedAt": 1651050140165,
"actionType": "ACCOUNT_CLIENT_WITHDRAW"
},
"error": null
}
HTTP Request:
POST https://api.apifiny.com/ac/v2/APIFINY/asset/withdraw
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | the exchange you withdraw funds from, e.g. Binance sub-account, default is APIFINY |
coin | YES | currency code in system, different from currency name if multiple chains are supported |
amount | YES | the amount to withdraw |
address | YES | a crypto address of the recipient |
memo | NO | memo(Optional), It is usually necessary for EOS |
ticket | YES | withdraw ticket |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | Account ID |
amount | the amount for this action. *transfer amount if it's transfer, withdrawal amount if it's withdraw |
fee | fee of this action; *transfer fee if the actionType is transfer, withdrawal fee if the actionType is withdraw |
instantFee | Extra transfer fee if the transfer is Intant. |
fromAddress | from address |
targetAddress | a crypto address of the recipient |
type | OUTGOING, INCOMING |
actionType | type of the request |
fromVenue | initiated exchange of this action |
toVenue | target exchange of this action |
logId | internal transfer ID |
txId | transaction ID in the blockchain |
status | SUBMITTED, COMPLETED, CANCELLED |
logCreatedAt | creation time |
logUpdatedAt | updated time |
*The venue
field in this request must match the one in the withdrawal ticket.
*If withdraw from an exchange sub-account, the fee returned will include the transfer fee from the exchange to Apifiny plus the withdrawal fee of Apifiny.
Transfer Funds
This endpoint allows user to transfer asset between exchang sub-accounts. Transfers between exchanges will trigger a blockchain transfer that moves funds from the origin exchange to the destination exchange. The transfer is carried out automatically by Apifiny.
Requires Authentication.
# Transfer Funds Between Exchanges: /asset/transferToVenue
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/transferToVenue" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","currency": "BTC","amount": 10.0,"targetVenue": "COINBASEPRO","timestamp": 1499827319559}'
Request:
{
"accountId": "STA-0000001",
"venue":"BINANCE",
"currency": "BTC",
"amount": 10.0,
"targetVenue": "COINBASEPRO",
"timestamp": 1499827319559
}
Response:
{
"result": {
"accountId": "STA-0000001",
"venue": "BINANCE",
"currency": "BTC",
"type": "OUTGOING",
"amount": 10.0,
"fee": 0.0005,
"instantFee": 0.00,
"fromVenue": "BINANCE",
"toVenue": "COINBASEPRO",
"logId": "STA-APIFINY_00000001.a93cd***5a7cba",
"actionType": "ACCOUNT_CLIENT_TRANSFER_OUTGOING",
"status": "SUBMITTED",
"logCreatedAt": 1584613315735,
"logUpdatedAt": 1584613839359
},
"error": null
}
HTTP Request:
POST https://api.apifiny.com/ac/v2/APIFINY/asset/transferToVenue
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | NO | from exchange, the default value is "APIFINY" if not sent |
currency | YES | currency name |
amount | YES | the amount to transfer |
targetVenue | NO | the target exchange the funds transferring to, the default value is "APIFINY" if it's null |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
*At least one of the two fields of venue
and targetVenue
should be sent, the default value is "APIFINY" if it's null. System will find all the matched networks between the two exchanges and go through the one with lowest fee automatically.
Response:
Parameter | Description |
---|---|
accountId | Account ID |
venue | from exchange |
currency | currency name |
amount | the amount to transfer |
fee | Transfer fees; *transfer fees include the withdrawal fee of the source exchange plus the deposit fee of the target exchange |
instantFee | Extra transfer fee if the transfer is Intant. |
fromVenue | source exchange the funds transferring from |
toVenue | target exchange the funds transferring to |
logId | internal transfer ID |
status | SUBMITTED, COMPLETED, CANCELLED |
logCreatedAt | creation time |
logUpdatedAt | updated time |
Query Funds History
Retrieve the account activity either increases or decreases your account balance, including deposit, withdrawal and transfer records according to the time range in reverse chronological order. deposits, withdrawals and transfers return their latest status.
Requires Authentication.
# Query Funds History: /asset/queryAssetActivityList
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/queryAssetActivityList?accountId=STA-00000001&startTimeDate=1584355090628&endTimeDate=1584614290628&limit=10&page=1×tamp=1499827319559"
Request:
{
"accountId": "STA-00000001",
"startTimeDate": "1584355090628",
"endTimeDate": "1584614290628",
"limit": "10",
"page": "1",
"timestamp": 1499827319559
}
Response:
{
"result": {
"records": [{
"accountId": "STA-VENUE1_00000001",
"currency": "BTC",
"status": "SUBMITTED",
"type": "OUTGOING",
"amount": 0.01,
"fee": 0.003,
"targetAddress": "",
"coin": "BTC",
"logId": "STA-VENUE1_00000001.8de7***951fb69",
"logCreatedAt": "1584355090628",
"logUpdatedAt": "1584614290628",
"actionType": "ACCOUNT_CLIENT_TRANSFER_OUTGOING",
"actionNote": "ACCOUNT_CLIENT_TRANSFER_OUTGOING",
"fromAccountId": "STA-VENUE1_00000001",
"toAccountId": "STA-VENUE2_00000001"
}, {
"accountId": "STA-VENUE1_00000001",
"currency": "BTC",
"status": "SUBMITTED",
"type": "OUTGOING",
"amount": 0.01,
"fee": 0.003,
"targetAddress": "",
"coin": "BTC",
"logId": "STA-VENUE1_00000001.fde9***080ce",
"logCreatedAt": "1584355090628",
"logUpdatedAt": "1584614290628",
"actionType": "ACCOUNT_CLIENT_TRANSFER_OUTGOING",
"actionNote": "ACCOUNT_CLIENT_TRANSFER_OUTGOING",
"fromAccountId": "STA-VENUE1_00000001",
"toAccountId": "STA-VENUE2_00000001"
}],
"total": 5,
"size": 2,
"current": 1,
"orders": [],
"hitCount": false,
"searchCount": true,
"pages": 3
},
"error": null
}
HTTP Request:
Get $Base URL/asset/queryAssetActivityList
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
startTimeDate | YES | start time |
endTimeDate | YES | end time |
limit | YES | records per page, max 500 |
page | YES | page number |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | Account ID |
currency | currency name |
status | status of this account activity, SUBMITTED, COMPLETED, CANCELLED |
type | IMCOMING for deposits, OUTGOING for withdrawals |
amount | amount of currency changed |
fee | fee occurs during this activity |
fromAddress | from address |
targetAddress | a crypto address of the recipient |
txId | transaction ID onchain |
coin | internal coin name |
logId | internal ID |
logCreatedAt | create time |
logUpdatedAt | update time |
actionType | source of request |
actionNote | note of request |
fromAccountId | the iniate sub-account transfer from |
toAccountId | the target sub-account transfer to |
count | total number of records |
limit | records per page |
page | page number |
pages | page count |
Query Transaction Fees
Retrieve the transaction fees of deposit, withdrawal and transfer.
# Query Transaction Fees: /utils/query-transaction-fee
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/utils/query-transaction-fee?type=withdraw¤cy=USDT&from=BINANCE×tamp=1499827319559"
Request:
// Query Deposit Fee
{
"type": "deposit",
"from": "",
"to": "",
"currency":"BTC",
"coin": "BTC"
}
// Query Withdrawal Fee
{
"type": "withdraw",
"from": "BINANCE",
"to": "",
"currency":"USDT",
"coin": ""
}
// Query Transfer Fee
{
"type": "transfer",
"from": "GBBO",
"to": "OKX",
"currency":"BTC",
"coin": "BTC"
}
Response:
// Deposit
{
"result": [
{
"fee": "0",
"coin": "BTC"
}
],
"error": null
}
// Withdrawal
{
"result": [
{
"fee": "1",
"coin": "USDT.TRON"
},
{
"fee": "0.8",
"coin": "USDT.BSC"
},
{
"fee": "100",
"coin": "USDT.BTC"
},
{
"fee": "25",
"coin": "USDT.ETH"
}
],
"error": null
}
// Transfer
{
"result": [
{
"fee": "0.8",
"coin": "USDT"
}
],
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/utils/query-transaction-fee
Request:
Parameter | Mandatory | Description |
---|---|---|
type | YES | deposit withdraw transfer |
currency | YES | currency name |
coin | NO | corresponding chain information; Invalid if the type is transfer |
from | NO | from exchange |
to | NO | target exchange the funds transferring to |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
fee | the according fee for the action in request. |
coin | special discount of trading fee |
*If withdraw from an exchange sub-account, the fee returned will include the transfer fee back to Apifiny plus the withdrawal fee of Apifiny.
Query Trading Fee Rate
Requires Authentication.
# Query Current Fee Rate: /asset/getCommissionRate
# unified
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/BINANCE/asset/getCommissionRate?accountId=STA-00000001&venue=BINANCE&symbol=BTCUSDT×tamp=1499827319559"
# co-located
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://apibn.apifiny.com/ac/v2/asset/getCommissionRate?accountId=STA-00000001&venue=BINANCE&symbol=BTCUSDT×tamp=1499827319559"
Response:
{
"result": {
"accountId": "STA-VENUE1_00000001",
"tradingVolume": 121.1001,
"takeFee": 0.003,
"makeFee": 0,
"specialRate": 0
},
"error": null
}
HTTP Request:
GET $Base URL/asset/getCommissionRate
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | VENUE1 |
symbol | YES | symbol |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Response:
Parameter | Description |
---|---|
accountId | account ID |
tradingVolume | cumulative trading volume within 30 days |
takeFee | taker fee |
makeFee | maker fee |
specialRate | special discount of trading fee |
Query Instant Transfer Quota
Requires Authentication.
# Query Current Fee Rate: /asset/query-max-instant-amount
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/asset/query-max-instant-amount?accountId=STA-00000001&venue=BINANCE&scurrency=USDT×tamp=1499827319559"
Response:
{
"result": "1.24437204",
"error": null
}
HTTP Request:
GET $Base URL/asset/query-max-instant-amount
signature={$signature}
Quota is the maximum amount for instant transfer at the moment. It's different for each asset, each target exchange, and varies over time. The result returns is the maximum amount. If the transfer amount initiating is larger than the maximum amount, it means this transfer is not instant and will trigger a blockchain transfer, balance will be added after the blockchain confirmations.
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | the target exchange transfer to |
currency | YES | the asset to transfer, for example: BTC |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000 |
Trading
Introduction
Clients will typically be using the Websocket API
to subscribe to the market data and RESTful API
to submit orders. Clients can use the websocket API
to subscribe to the order updates or use RESTful API
to get order updates. A typical trade flow would be as follows:
Step 1: Subscribe to market data. The websocket endpoint used to subscribe and unsubscribe for market data is wss://api.apifiny.com/md/ws/v1
. Request and reply are in JSON format.
The RESTful endpoint is GET https://api.apifiny.com/md/orderbook/v1/{SYMBOL}/{VENUE}
, where {SYMBOL}
denotes the currency pair of interest and the {VENUE}
denotes the exchange.
Step 2: Create order and send order using the RESTful API
.
The method for creating an order is order/newOrder, which enables an order to be created and submitted. Note that the orderId
is optional, if requested, it should be composed of: account number+random number+13 digit timestamp+3 digit random number. Up to 64 digits.
for example:xxxxxxxxxxxxxx1614254993065992
Step 3: Subscribe to the order updates using websocket /ws/trading
, the message is sent to notify the client that the order execution report changed.
A number of methods enable the querying of order(s) state: the URL endpoints are:
/order/queryOrderInfo to find the state of a single submitted order;
/order/listOpenOrder to get a list of all open orders;
/order/listCompletedOrder to get a list of all complete orders;
/order/listFilledOrder to get a list of fills.
Step 4: Cancel Order (as needed). When an order that was submitted and is open needs to be canceled, The URL endpoint is /order/cancelOrder. Any order that has a status of PENDING_SUBMIT or has already been canceled, cannot be canceled. In addition, cancelledUpdatedAt
must be null.
Further technical information and examples for all Trading API methods are as follows:
Create New Order
Requires Authentication.
# Create New Order: order/newOrder
# unified
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/BINANCE/order/newOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","orderId": "000000011584603011942221","orderInfo": {"symbol": "BTCUSDT","orderType": "LIMIT","timeInForce": 1,"orderSide": "BUY","limitPrice": "100","quantity": "1.12","timestamp": 1499827319559}
}'
# co-loactaed
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" \
"https://apibn.apifiny.com/ac/v2/order/newOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","orderId": "000000011584603011942221","orderInfo": {"symbol": "BTCUSDT","orderType": "LIMIT","timeInForce": 1,"orderSide": "BUY","limitPrice": "100","quantity": "1.12","timestamp": 1499827319559}
}'
Request:
{
"accountId": "STA-00000001",
"venue": "BINANCE",
"orderId": "000000011584603011942221",
"orderInfo": {
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"timeInForce": 1,
"orderSide": "BUY",
"limitPrice": "100",
"quantity": "1.12"
},
"timestamp": 1499827319559
}
Response:
{
"result": {
"orderType": "LIMIT",
"orderId": "000000011584603011942221",
"accountId": "STA-BINANCE_00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 100,
"quantity": 1.12,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"openQuantity": 1.12,
"orderStatus": "PENDING_SUBMIT",
"createdAt": 1644979126832,
"updatedAt": null,
"venue": "VENUE1",
"timeInForce": "1",
"total": null,
"stopType": null,
"triggerPrice": null,
"triggerTime": null
},
"error": null
}
Make a new order request:
HTTP Request:
POST $Base URL/order/newOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | venue name |
orderId | NO | order ID(Optional) |
symbol | YES | symbol |
orderType | YES | order type, LIMIT or MARKET (only some venues support) or STOP |
timeInForce | NO | specifies how long the order remains in effect, 1=GTC, 3=IOC=, 7=PostOnly |
orderSide | YES | order side, BUY or SELL |
limitPrice | NO | limit price |
quantity | NO | quantity, order size |
total | NO | Amount of quote asset to spend, required when orderSide is BUY , orderType = MARKET |
triggerPrice | NO | Trigger price at which when the last trade price changes to this value, the stop order will be triggered; Required if orderType = STOP |
stopType | NO | ENTRY or LOSS ; entry is for when price rises above triggerPrice, loss is for when price drops below triggerPrice; Required if orderType = STOP |
average | NO | Mandatory if orderType=ICEBERG , the average qty of the iceberg order. |
variance | NO | Mandatory if orderType=ICEBERG , range is [0,1], default is 0. |
timestamp | YES | Timestamp for your request |
recvWindow | NO | defaults to 5000, The value cannot be greater than 60000 |
*orderId
if requested, should be composed of: account number + random number + 13 digit timestamp+3 digit random number. Up to 64 digits.
for example:xxxxxxxxxxxxxx1614254993065992
Response:
Parameter | Description |
---|---|
accountId | sub account ID |
venue | venue name, the target exchange |
orderId | order ID |
symbol | symbol |
orderType | order type, LIMIT or MARKET or STOP or ICEBERG |
orderSide | order side, BUY or SELL |
triggerPrice | Trigger price |
stopType | ENTRY or LOSS |
triggerTime | stop order activated timestamp |
limitPrice | limit price, not available for market order |
quantity | quantity |
filledAveragePrice | average fill price |
filledCumulativeQuantity | accumulated fill quantity |
openQuantity | open quantity to be filled |
orderStatus | order status |
createdAt | order creation timestamp |
updatedAt | order update timestamp |
cancelledUpdatedAt | if it is cancelled, cancellation timestamp |
filledUpdatedAt | last filled timestamp |
Order Type:
Order Type | Description |
---|---|
LIMIT | Limit Order |
MARKET | Market Order* |
STOP | Stop Limit Order* with a pre-set Trigger price and Condition |
ICEBERG | Iceberg Order, an advanced order type. |
*Only 11 exchanges support market order now, they are Binance, Binance(US), Coinbase(pro), Coinbase Pro(UK), Crypto, Exmo, Huobi, Iitbit, Kucoin, OKX, Okcoin, others will be coming soon.
Stop Orders become active and wait to trigger based on the movement of the last trade price.
There are two types of stop orders, ENTRY
and LOSS
, allow a user to set a Trigger price and Condition: "If price rises to" or "If price drops to" the specified Trigger price.
stop ENTRY
: Triggers when the last trade price changes to a value at or above the triggerPrice.
stop LOSS
: Triggers when the last trade price changes to a value at or below the triggerPrice.
The last trade price is the last price at which an order was filled. Note that when stop orders are triggered, they execute as limit orders.
Iceberg Order :
average
: average size the size you expect the order size showing on the orderbook, the visible amount. (The visible size shall be greater than the minimum order size, or an error will occur.)
variance
: a variance range, within which the system will generate a random amount of added to or deducted from the visible amount each time placing the order, so the behavior of the algorithm will not be predictable.
Time In Force:
Time In Force | Description |
---|---|
1 | GTC (Good Till Canceled) |
2 | GTD (Good Till Date), temporarily not supported |
3 | IOC (Immediate Or Cancel) |
7 | Post Only (The order should only make liquidity) |
Order Side:
Order Side | Description |
---|---|
BUY | buy order |
SELL | sell order |
Order Status:
Order Status | Explanation |
---|---|
PENDING_SUBMIT | active status, order has been sent but not confirmed |
SUBMITTED | active status, order has been accepted and stay active |
PART_FILLED | final status, partially filled order |
FILLED | final status, completely filled order |
PENDING_CANCEL | cancel order request has been received, Cancel order in progress |
CANCELLED | final status, order has been canceled |
REJECTED | final status, order has been rejected |
Cancel an Order
Requires Authentication.
# Cancel an Order: /order/cancelOrder
# unified
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/BINANCE/order/cancelOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","orderId": "00000001152221","timestamp": 1499827319559}'
# co-located
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://apibn.apifiny.com/ac/v2/order/cancelOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","orderId": "00000001152221","timestamp": 1499827319559}'
Request:
{
"accountId": "STA-00000001",
"venue":"BINANCE",
"orderId": "000000011584603011942221",
"timestamp": 1499827319559
}
Response:
{
//Same as new order response
}
Request Cancel an Order via the order ID.
HTTP Request:
POST $Base URL/order/cancelOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | Venue Name, exchange sub-account, e.g. BINANCE |
orderId | YES | Order ID |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Cancel Reject:
If the order could not be canceled (still pending submit, already filled or previously canceled, etc), then an error response will indicate the reason in the message
field.
Cancel All
Requires Authentication.
# Cancel All: /order/cancelAccountVenueAllOrder
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/BINANCE/order/cancelAccountVenueAllOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","symbol": "BTCUSD","timestamp": 1499827319559}'
# co-located
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://apibn.apifiny.com/ac/v2/order/cancelAccountVenueAllOrder" \
-d '{"accountId": "STA-00000001","venue":"BINANCE","symbol": "BTCUSD","timestamp": 1499827319559}'
Request:
{
"accountId": "STA-00000001",
"venue":"BINANCE",
"symbol": "BTCUSDT",
"timestamp": 1499827319559
}
Response:
{
"result": [
"519e f355d9884e1f8e3d3ffc7caf13b5",
"519e f355d9884e1f8e3d3ffc7caf13b3",
"519e f355d9884e1f8e3d3ffc7caf14b5",
"519e f355d9884e1f8e3d3ffc7caf13b6"
],
"error": null
}
With best effort, Cancel all open orders. The response is a list of ids of the canceled orders.
HTTP Request:
POST $Base URL/order/cancelAccountVenueAllOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | Venue Name, exchange sub-account, e.g. BINANCE |
symbol | NO | Only cancel orders open for the specified trading pair |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Parameter | Description |
---|---|
orderId | Order ID, unique identifier of an order. |
Get an Order
Requires Authentication.
# Get an Order: /order/queryOrderInfo
# unified
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/BINANCE/order/queryOrderInfo?accountId=STA-00000001&venue=BINANCE&orderId=000000011584603011942221"
# co-located
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://apibn.apifiny.com/ac/v2/order/queryOrderInfo?accountId=STA-00000001&venue=BINANCE&orderId=000000011584603011942221×tamp=1499827319559"
Response:
{
//Same as new order response
}
HTTP Request:
GET $Base URL/order/queryOrderInfo
signature={$signature}
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | YES | venue name |
orderId | YES | order ID |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query Multiple Orders by IDs
Requires Authentication.
# Query Multiple Orders by IDs: /order/listMultipleOrderInfo
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/VENUE1/order/listMultipleOrderInfo?accountId=STA-00000001&orderIdList=000000121574697605570321,000000121574697754664817×tamp=1499827319559"
Response:
[
{
//Same as new order response
},
{
//Same as new order response
}
]
HTTP Request:
GET $Base URL/order/listMultipleOrderInfo
signature={$signature}
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
orderIdList | YES | the total number of order ID cannot exceed 500 |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query All Open Orders
Requires Authentication.
# Query All Open Orders: /order/listOpenOrder
# unified
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/BINANCE/order/listOpenOrder?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
# co-located
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://apibn.apifiny.com/ac/v2/order/listOpenOrder?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
Response:
{
"result": [{
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"orderId": "000000011584603011942221",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"orderSide": "BUY",
"limitPrice": 100,
"quantity": 1.12,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"timeInForce": 1,
"openQuantity": 1.12,
"orderStatus": "PENDING_SUBMIT",
"createdAt": 1584603012164,
"updatedAt": 1584603012164
},
{
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"orderId": "000000011584603011942227",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"orderSide": "SELL",
"limitPrice": 110,
"quantity": 1.12,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"timeInForce": 1,
"openQuantity": 1.12,
"orderStatus": "SUBMITTED",
"createdAt": 1584603012164,
"updatedAt": 1584603012164
}
],
"error": null
}
HTTP Request:
GET /order/listOpenOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | Venue Name |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query All Completed Orders
Requires Authentication.
# Query All Completed Orders: /order/listCompletedOrder
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/VENUE1/order/listCompletedOrder?accountId=STA-00000001&venue=VENUE1&startTime=1537857271784&endTime=1537857271784&limit=100×tamp=1499827319559"
Response:
[
{
//Same as new order response
},
{
//Same as new order response
}
]
Query all settled orders, including: filled, partially filled, canceled and rejected orders.
HTTP Request:
GET $Base URL/order/listCompletedOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
venue | NO | venue name, use GBBO |
startTime | NO | Start Time |
endTime | NO | End Time |
limit | NO | total number of orders, default is 500, Max 1000 |
orderStatus | NO | order status: PART_FILLED , FILLED , CANCELLED . |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query List Fills
Requires Authentication.
# Query List Fills: /order/listFilledOrder
# unified
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/BINANCE/order/listFilledOrder?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
# co-located
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://apibn.apifiny.com/ac/v2/order/listFilledOrder?accountId=STA-00000001&venue=BINANCE×tamp=1499827319559"
Response:
{
"result": [{
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"orderId": "000000011584603011942221",
"tradeId": "ioNE5KwqytFw8TzDy7l41IMdRBc=",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"timeInForce": 3,
"orderSide": "BUY",
"limitPrice": 9000,
"quantity": 0.01,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"openQuantity": 0,
"orderStatus": "FILLED",
"createdAt": 1584603012164,
"updatedAt": 1584603012164,
"cancelledUpdatedAt": null,
"filledUpdatedAt": null,
"lastCommission": 0.0450,
"lastCommissionCurrency": "USD",
"lastFilledQuantity": 0.01,
"lastFilledPrice": 9000,
"isTaker": true
}],
"error": null
}
HTTP Request:
GET $Base URL/order/listFilledOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
venue | YES | Venue name |
symbol | NO | Limit the list of fills to this symbol |
orderId | NO | Limit the list of fills to this order ID |
limit | NO | Default 500; max 1000 |
startTime | NO | Start Time |
endTime | NO | End Time |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Data time range
The system allows you to retrieve data up to three months (start from the last day by default). If you only specified the start time, the system will automatically calculate the end time (end time = start time + 3 months). On the contrary, if you only specified the end time, the system will calculate the start time (start time= end time - 3 months) the same way.
Response:
Same as new order response.
Parameter | Description |
---|---|
tradeId | the unique ID of this fill |
lastCommission | trading fees happen in this fill |
lastCommissionCurrency | the currency of the trading fee |
isTaker | this field indicates if the fill was the result of a liquidity provider or liquidity taker. TRUE indicates Taker and FALSE indicates Maker |
Trading (Algo)
Introduction
There is something you should know about the newly introduced smart routing order, they are as follows:
It routes your order for best execution based on the consolidated order book, meaning it will split the order up to send to multiple exchanges for the most optimum execution price.
When you want to make sure your order is completed as soon as possible, you should make sure you have sufficient balances at most liquidated exchanges. Allocate funds to exchange accounts, you can transfer funds to each sub-account using this endpoint: Transfer Funds.
This algorithm can be used for any size. It is suggested that the minimum notional of the SOR order should be over $10 value, otherwise the order might get rejected at most of the exchanges.
Terminate/Cancel a SOR order takes some time to process, because the system needs to clear all the orders that have been sent to the target exchanges before the order can be terminated completely.
Currently, the SOR order will stand for 24hrs, the system would terminate the order when times up no matter how much amount it's been filled.
Create SOR Order
Requires Authentication.
# Same as Create New Order: order/newOrder
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/APIFINY/order/newOrder" \
-d '{"accountId": "STA-00000001","orderId": "APIFINY_000000011584603011942221","venue": "BINANCE,KUCOIN,HUOBI,OKX,COINBASEPRO","orderInfo": {"symbol": "BTCUSDT","orderType": "SOR","orderSide": "BUY","limitPrice": "30000","quantity": "1","timestamp": 1499827319559}
Request:
{
"accountId": "STA-00000001",
"orderId": "APIFINY_000000011584603011942221",
"venue": "BINANCE,KUCOIN,HUOBI,OKX,COINBASEPRO",
"orderInfo": {
"symbol": "BTCUSDT",
"orderType": "SOR",
"orderSide": "BUY",
"limitPrice": "30000",
"quantity": "1"
},
"timestamp": 1499827319559
}
Response:
{
"result": {
"orderType": "SOR",
"orderId": "APIFINY_000000011584603011942221",
"accountId": "STA-APIFINY_00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 30000,
"quantity": 1,
"filledAveragePrice": null,
"filledCumulativeQuantity": null,
"openQuantity": 1,
"orderStatus": "PENDING_SUBMIT",
"createdAt": 1650772735012,
"updatedAt": 1650772735012,
"venue": null,
"timeInForce": "1",
"total": null,
"stopType": null,
"triggerPrice": null,
"triggerTime": null
},
"error": null
}
Make a new SOR order request:
HTTP Request:
POST https://api.apifiny.com/ac/v2/APIFINY/order/newOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
orderId | NO | order ID |
venue | NO | the target exchanges, up to 5, separate with commas. e.g. "BINANCE,KUCOIN" |
symbol | YES | symbol |
orderType | YES | SOR (smart order router) |
orderSide | YES | order side, BUY or SELL |
limitPrice | YES | the upper limit price of this order |
quantity | YES | quantity, order size |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
orderId
: If requested, should be composed of: **account number + random number + 13 digit timestamp+3 digit random number*. Up to 64 digits.
for example:xxxxxxxxxxxxxx1614254993065123
*venue
: If specified, the routing happens within those exchanges, otherwise all connected exchanges. It is recommended to specify the exchanges you have enough balances in, it can improves with the routing performance. The exchanges with better liquidity are recommended, such as Binance, Kucoin, Huobi, OKX, FTX etc.
Response:
Parameter | Description |
---|---|
accountId | Apifiny Account ID |
orderId | order ID |
symbol | symbol |
orderType | order type, SOR |
orderSide | order side, BUY or SELL |
limitPrice | limit price, the price when placing the order |
quantity | quantity, the size when placing the order |
filledAveragePrice | average filled price |
filledCumulativeQuantity | accumulated filled quantity |
openQuantity | open quantity to be filled |
orderStatus | order status |
createdAt | order creation timestamp |
updatedAt | order update timestamp |
cancelledUpdatedAt | if it is cancelled, cancellation timestamp |
filledUpdatedAt | last filled timestamp |
Order Type:
Order Type | Description |
---|---|
SOR | Smart Order Router: Routes the order for best execution, it will also split the order |
Order Side:
Order Side | Description |
---|---|
BUY | buy order |
SELL | sell order |
Order Status:
Order Status | Explanation |
---|---|
PENDING_SUBMIT | active status, order has been sent but not confirmed |
SUBMITTED | active status, order has been accepted and stay active |
PART_FILLED | final status, partially filled order |
FILLED | final status, completely filled order |
PENDING_CANCEL | cancel order request has been received, Cancel order in progress |
CANCELLED | final status, order has been canceled |
REJECTED | final status, order has been rejected |
Cancel SOR Order
Requires Authentication.
# Same as Cancel an Order: /order/cancelOrder
curl -X POST -H "Content-Type: application/json" -H "apiKey: hY***lY" -H "signature: eyJhY***nyheQs" "https://api.apifiny.com/ac/v2/APIFINY/order/cancelOrder" \
-d '{"accountId": "STA-00000001","orderId": "000000011584603011942221","timestamp": 1499827319559}'
Request:
{
"accountId": "STA-00000001",
"orderId": "STA-000000011584603011942221",
"timestamp": 1499827319559
}
Response:
{
"result": {
"orderType": "SOR",
"orderId": "APIFINY_000000011584603011942221",
"accountId": "STA-APIFINY_00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 30000,
"quantity": 1,
"filledAveragePrice": null,
"filledCumulativeQuantity": null,
"openQuantity": 1,
"orderStatus": "PENDING_CANCEL",
"createdAt": 1650772735012,
"updatedAt": 1650772735012,
"timeInForce": "1",
"total": null,
"stopType": null,
"triggerPrice": null,
"triggerTime": null
},
"error": null
}
Request Cancel a SOR Order via the order ID.
HTTP Request:
POST https://api.apifiny.com/ac/v2/APIFINY/order/cancelOrder
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
orderId | YES | Order ID |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new SOR order response.
Cancel Reject:
If the order could not be canceled (still pending submit, already filled or previously canceled, etc), then an error response will indicate the reason in the message
field.
Get a SOR Order
Requires Authentication.
# Get a SOR Order: /algo/query-order-info
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/algo/query-order-info?accountId=STA-00000001&orderId=APIFINY_000000011584603011942221×tamp=1499827319559"
Response:
{
"result": {
"orderType": "SOR",
"orderId": "APIFINY_000000011584603011942221",
"accountId": "STA-00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 41880.58,
"quantity": 0.002,
"filledAveragePrice": 0.9999,
"filledCumulativeQuantity": 0.001,
"openQuantity": 0.0,
"orderStatus": "PART_FILLED",
"createdAt": 1650532374000,
"updatedAt": 1650532462000,
"venue": null,
"timeInForce": "3",
"total": null
},
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/algo/query-order-info
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
orderId | YES | the master order ID |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query Open Orders
Query Open SOR Orders. Requires Authentication.
# Query Open SOR Orders: algo/list-open-order
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/algo/order/list-open-order?accountId=STA-00000001×tamp=1499827319559"
Response:
{
"result": [{
"accountId": "STA-VENUE1_00000001",
"orderId": "APIFINY_000000011584603011942221",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"orderSide": "BUY",
"limitPrice": 41500,
"quantity": 1.008,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"timeInForce": 1,
"openQuantity": 1.008,
"orderStatus": "SUBMITTED",
"createdAt": 1650532374000,
"updatedAt": 1650532374000
},
{
"accountId": "STA-VENUE1_00000001",
"orderId": "APIFINY_000000011584603011942227",
"symbol": "BTCUSD",
"orderType": "LIMIT",
"orderSide": "SELL",
"limitPrice": 41500,
"quantity": 1.12,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"timeInForce": 1,
"openQuantity": 1.12,
"orderStatus": "SUBMITTED",
"createdAt": 1650772735012,
"updatedAt": 1650772735012
}
],
"error": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/algo/list-open-order
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | Account ID |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query Completed Orders
Query Completed SOR Orders. This endpoint returns orders based on a specific searching criteria. Including: filled, partially filled, canceled and rejected orders.
Requires Authentication.
# Query Completed SOR Orders: /algo/list-order-history
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/algo/list-order-history?accountId=STA-00000001&symbol=BTCUSDT&startTime=1650532374000&endTime=1650532462000&limit=5×tamp=1499827319559"
Response:
{
"orderType": "SOR",
"orderId": "APIFINY_10000011650532372812612",
"stopType": null,
"triggerPrice": null,
"triggerTime": null,
"accountId": "STA-00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 41880.58,
"quantity": 0.002,
"filledAveragePrice": 0.9999,
"filledCumulativeQuantity": 0.001,
"openQuantity": 0.0,
"orderStatus": "PART_FILLED",
"createdAt": 1650532374000,
"updatedAt": 1650532462000,
"venue": null,
"timeInForce": "3",
"total": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/algo/list-order-history
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
symbol | NO | The trading pair in query |
side | NO | The order side of the order, BUY or SELL |
startTime | NO | Start Time |
endTime | NO | End Time |
limit | NO | total number of orders, default is 500, Max 1000 |
orderStatus | NO | order status: PART_FILLED , FILLED , CANCELLED . |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Same as new order response.
Query Routing Details by IDs
This endpoint returns a list of the routed orders splited from the master SOR order.
Requires Authentication.
# Query Routing Details of an Order: /algo/order-detail
curl -X GET -H "apiKey: hY***lY" -H "signature: eyJh***heQs" "https://api.apifiny.com/ac/v2/APIFINY/algo/order-detail?accountId=STA-00000001&orderId=APIFINY_10000011650532372812612×tamp=1499827319559"
Response:
{
"orderType": "SOR",
"orderId": "ALGO_011650532461633134",
"accountId": "STA-00000001",
"symbol": "BTCUSDT",
"orderSide": "BUY",
"limitPrice": 41880.58,
"quantity": 0.002,
"filledAveragePrice": 0.9999,
"filledCumulativeQuantity": 0.001,
"openQuantity": 0.0,
"orderStatus": "PART_FILLED",
"createdAt": 1650532374000,
"updatedAt": 1650532462000,
"venue": "BINANCE",
"timeInForce": "3",
"total": null
}
HTTP Request:
GET https://api.apifiny.com/ac/v2/APIFINY/algo/order-detail
Request:
Parameter | Mandatory | Description |
---|---|---|
accountId | YES | account ID |
orderId | YES | The SOR master order ID in query |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
Response:
Similar with other order endpoints response.
Parameter | Mandatory | Description |
---|---|---|
venue | YES | the target exchanges of the child order routs to |
timestamp | YES | |
recvWindow | NO | The value cannot be greater than 60000 |
The child order ID can be queried via non-algo endpoints.
Websocket API
Apifiny Websocket API can be used to subscribe for a feed of real time data, such as price evolution or market state data. Also updates for orders, trades and account balances.
In addition, the API can allow clients to create and cancel orders by reusing the same established websocket connection.
Connectivity
Heartbeat and Connection
Once the Websocket Client connected to the Websocket Server, the system will send a "SUCCESS" message.
{
"type": "auth",
"result": "Websocket connection succeeded",
"error": null
}
Websocket API supports two-way heartbeat. Both Server and Client can send ping message, which the opposite side can return with pong message. The Client side can send ping messages every pingInterval time to the server to keep alive the link.
Websocket Client sends heartbeat:
{“action”:“heartbeat”,“data”:“ping”}
When the Server receives this heartbeat message, it will respond with a matching "pong" message:
{"type":"heartbeat","result":"pong","error":null}
Connection lifecycle
Establish a websocket connection with
wss URLs
(Optional) Authenticate with
{"action":"auth","data":{"timestamp":1657681321343,"apiKey":your_API_key,"signature":sign}}
Send pings at regular intervals:
{"action":"heartbeat","data":"ping"}
. You will see an{"type":"heartbeat","result":"pong","error":null}
response.Subscribe to a channel with
{'action': 'sub', 'channel': 'cob', 'symbol': 'BTCUSDT', 'venue': 'BINANCE'}
Receive data
{'channel': 'trade', 'symbol': 'BTCUSDT', 'venue': 'BINANCE', 'trade': {'trades':[{'symbol': 'BTCUSDT', 'provider': 'BINANCE','price': 5231.0, 'size': 0.07, 'side': 'sell','tradetime': '1621839791084' }]}}
Unsubscribe
{'action': 'unsub', 'channel': 'cob', 'symbol': 'BTCUSDT'}}
Market Data
WebSocket endpoint provides real-time market data streaming which works in Subscribe-Publish communication model.
The base endpoint for Market Data is:
wss://api.apifiny.com/md/ws/v1
Subscribe/Unsubscribe to streams
The following data can be sent through the websocket instance in order to subscribe/unsubscribe from streams.
Subscribe to a stream
Request(Subscribe):
{
"channel":"ChannelName",
"symbol":"BTCUSDT",
"venues":["BINANCE"],
"action":"sub"
}
Unsubscribe to a stream
Request(Unsubscribe) :
{
"channel":"ChannelName",
"symbol":"BTCUSDT",
"venues":["BINANCE"],
"action":"unsub"
}
The request for subscribe/unsubscribe must be in JSON format.
Python sample
# python3
msg = {"channel": "trade", "symbol": 'symbol', "venues": 'VENUES', "action": "sub"}
# msg = {"channel": "symbol": 'BTCUSDT', "action": "sub"}
def sub_md(message):
from websocket import create_connection
import ssl
sslopt = {"cert_reqs": ssl.CERT_NONE}
con = create_connection('wss://api.apifiny.com/md/ws/v1', sslopt=sslopt)
con.send(json.dumps(message))
while True:
response = con.recv()
if 'ping' in response:
pong = response.replace('ping', 'pong')
con.send(pong)
print(response)
sub_md(msg)
Order Book Channel
Subscribe to order book stream:
{
"channel":"orderbook",
"symbol":"BTCUSDT",
"venues":["BINANCE","Exchange2"],
"action":"sub"
}
Order Book Payload:
{
"venues": ["BINANCE"],
"channel": "orderbook",
"symbol": "BTCUSDT",
"orderbook": {
"symbol": "BTCUSDT",
"updatedAt": 1621839607399,
"asks": [
[36179.76, 0.01311800],
// [price, size]
// ……
],
"bids": [
[36165.88, 0.014268],
[36153.40, 0.056410]
]
}
}
// ....
{
"venues":["BINANCE"],
"channel": "orderbook",
"symbol": "BTCUSDT",
"orderbook": {
"symbol": "BTCUSDT",
"updatedAt": 1621839607399,
"asks": [
[36179.76, 0.013118],
// [price, size]
// ……
],
"bids": [
[36165.88, 0.014268],
[36153.40, 0.056410]
]
}
}
Push the updates of the order book on a specific pair.
Parameter | Description |
---|---|
channel | channel name: orderbook |
Trades Channel
Subscribe to trades stream:
{
"channel":"trade",
"symbol":"BTCUSDT",
"venues":["BINANCE","Exchange2"],
"action":"sub"
}
Recent Trades Payload:
{
"venues": ["BINANCE"],
"channel": "trade",
"symbol": "BTCUSDT",
"trade": {
"trades": [{
"symbol": "BTCUSDT",
"provider": "BINANCE",
"price": 36271.52000000,
"qty": 0.00034500,
"side": "BUY",
"tradeTime": 1621839791084,
"exchangeID": "5093303",
"updateTime": 1621839791086
}, {
"symbol": "BTCUSDT",
"provider": "BINANCE",
"price": 36289.07000000,
"qty": 0.00000700,
"side": "SELL",
"tradeTime": 1621839787668,
"exchangeID": "5093301",
"updateTime": 1621839787671
}]
}
}
Push the most recent trades with the price, volume, and direction on a specific pair.
Parameter | Description |
---|---|
channel | channel name: trade |
OHLCV Channel
Subscribe to Kline stream:
{
"channel":"kline_1h",
"symbol":"BTC/USDT",
"venues":["BINANCE"],
"action":"sub"
}
OHLCV Payload:
{
"venues": ["VENUE1"],
"channel": "kline_1h",
"symbol": "BTC/USD",
"kline_1m": {
"currencyPair": "BTC/USDT",
"period": "1m",
"open": 36536.1900,
"high": 36536.1900,
"low": 36464.6200,
"close": 36464.6200,
"vol": 2.46849600,
"count": 65,
"timestamp": 1621841040000,
"exchange": "BINANCE"
}
}
Push the updates to the current klines/candlestick at a preset interval.
Parameter | Description |
---|---|
channel | channel name: kline_<period> |
Period, Kline/Candlestick chart intervals: 1m
, 5m
, 30m
, 1h
, 4h
, 1d
, 1w
, 1M
.
For kline_<period>
we support 9 venues currently: BINANCE, BINANCEUS, COINBASEPRO, FTX, HUOBI, KUCOIN, OKX, OKCOIN, GATEIO. Others will result in an error message.
Ticker Channel
Subscribe to Ticker stream:
{
"channel":"ticker",
"symbol":"BTC/USDT",
"venues":["BINANCE"],
"action":"sub"
}
Ticker Payload:
{
"venues": ["BINANCE"],
"channel": "ticker",
"symbol": "BTCUSDT",
"ticker": {
"symbol": "BTCUSDT",
"open": 36631.84000000,
"high": 36785.32000000,
"low": 31109.00000000,
"close": 36198.03000000,
"vol": 2984.41975300,
"amount": 101489083.47069713,
"count": 0,
"provider": "BINANCE",
"tickerTime": 1621839608737,
"updateAt": 1621839608835
}
}
Push the updates of 24 hour rolling window ticker statistics in an array.
Parameter | Description |
---|---|
channel | channel name: ticker |
Conslidated Order Book Channel
Subscribe to COB stream:
{
"channel":"cob",
"symbol":"BTCUSD",
"action":"sub"
}
Consolidated Order Book Payload:
{
"asks": [{
"price": 46840,
"qty": 0.00004784,
"source": "HUOBI"
},
// ……
{
"price": 47040,
"qty": 0.23653,
"source": "BINANCE"
}],
"bids": [{
"price": 47039.99,
"qty": 0.007,
"source": "GATEIO"
},
// ……
{
"price": 47038.62,
"qty": 0.0161,
"source": "KUCOIN"
}],
"symbol": "BTCUSDT",
"updateAt": 1640850556984
}
Push the updates of best bid/ask quotations from all connected exchanges.
Parameter | Description |
---|---|
channel | channel name: cob |
A subscription of channel cob
, the parameter of venue
is not required.
User Data Streams
User data streams provides real-time communication capacity for create and cancel orders, order updates, account updates. Private channel requires Authentication, Signature method is the same with REST API: HMAC SHA256
.
URLs
BINANCE
wss://apibn.apifiny.com/ws/stream
BINANCEUS
wss://apibnu.apifiny.com/ws/stream
COINBASEPRO
wss://apicb.apifiny.com/ws/stream
FTX
wss://apiftx.apifiny.com/ws/stream
HUOBI
wss://apihb.apifiny.com/ws/stream
KUCOIN
wss://apikc.apifiny.com/ws/stream
OKX
wss://apiok.apifiny.com/ws/stream
OKCOIN
wss://apiokc.apifiny.com/ws/stream
Other Venues
wss://api.apifiny.com/ws/stream
# python3
import hashlib
import json
import time
import hmac
def gen_signature(your_secret_key, data) -> str:
message = data.encode("utf-8")
return hmac.new(your_secret_key.encode("utf-8"), message, digestmod=hashlib.sha256).hexdigest()
def ws_client():
sslopt = {"cert_reqs": ssl.CERT_NONE}
timestamp = int(time.time() * 1000)
sign = gen_signature(secret_key,f"timestamp={timestamp}")
con = websocket.create_connection("wss://api.apifiny.com/ws/stream", sslopt=sslopt)
auth = {"action":"auth","data":{"timestamp":timestamp,"apiKey":Your_API Key,"signature":sign}}
con.send(json.dumps(auth))
while True:
print(f"recv: {con.recv()}")
ws_client()
Log In
A User Data Stream is private channel requires authentication, you can log in by sending a message to start a new user data stream:
apiKey
: your API keytimestamp
: integer current timestamp (in milliseconds)sign
: SHA256 HMAC of the following string, using your ""Secret Key" as the key and "timestamp=XXXXX" as the value for the HMAC operation to generate
Login message example
// log in
{
"action": "auth",
"data": {
"timestamp": 1657681321343,
"apiKey": Your_API_Key,
"signature": sign
}
}
// success response
{
"type": "auth",
"result": "Websocket connection succeeded",
"error": null
}
As an example, if:
timestamp
:timestamp=1657710522036
secret
:'36CE6953CFDBAD8CB03E9E2A48961E23'
sign
would be 36265e48646297e4402fed57abd2d6473eda6f5be1319600780c1ec4dd19f460
One websocket connection may be logged in to at most five users. If the connection is already authenticated, further attempts to log in will result error message:
Login error example
{"type":"auth","result":null,"error":{"code":65562,"message":"The maximum number of connections is 5"}}
Create New Order
Once the Client logged in, the client can send a JSON payload representing the order to be created.
Parameter | Mandatory | Description |
---|---|---|
action | YES | newOrder |
venue | YES | Venue Name, the exchange, e.g. BINANCE |
orderId | NO | Order ID |
*For the description of the order related parameter, please see Order parameters .
The following request example is the order that can be created:
new order request:
// create new order
{
"action": "newOrder",
"data": {
"orderId": "",
"venue": "BINANCE",
"orderInfo": {
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"quantity": "1.12",
"limitPrice": "100",
"orderSide": "BUY",
"timeInForce": "1",
"total": "0"
}
}
}
// create SOR order, only support at wss://api.apifiny.com/ws/trading
{
"action": "newOrder",
"data": {
"orderId": "",
"venue": "BINANCE,KUCOIN", // Optional, if specified, routing happens within those exchanges
"orderInfo": {
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"quantity": "1.12",
"limitPrice": "100",
"orderSide": "BUY",
"timeInForce": "1",
"total": "0"
}
}
}
Response:
{
"result": {
"accountId": "STA-VENUE1_00000001",
"venue": "BINANCE",
"orderId": "000000011584603011942221",
"symbol": "BTCUSDT",
"baseAsset": "BTC",
"quoteAsset": "USDT",
"orderType": "LIMIT",
"orderSide": "BUY",
"limitPrice": 100,
"quantity": 1.12,
"filledAveragePrice": 0,
"filledCumulativeQuantity": 0,
"lastFilledIsTaker": false,
"timeInForce": 3,
"openQuantity": 1.12,
"orderStatus": "PENDING_SUBMIT",
"createdAt": 1657681321343,
"updatedAt": 1584603012164
},
"type": "order"
}
Cancel an Order
Cancel an Order via the order ID. Send a JSON payload representing the order to be canceled.
Parameter | Mandatory | Description |
---|---|---|
action | YES | cancelOrder |
venue | YES | Venue Name, the exchange, e.g. BINANCE |
orderId | YES | Order ID |
Response:
Same with the new order response.
Cancel Reject:
If the order could not be canceled (still pending submit, already filled or previously canceled, etc), then an error response will indicate the reason in the message
field.
The following request example is cancel an order by ID:
cancel order by ID request:
{
"action": "cancelOrder",
"data": {
"orderId": "872804677639471104",
"venue": "BINANCE"
}
}
// cancel SOR order, only support at wss://api.apifiny.com/ws/stream
{
"action": "cancelOrder",
"data": {
"orderId": "872804677639471104"
}
}
Response:
{
//Same with the new order response
}
Cancel All Order
Send a JSON payload representing canceling all open orders:
The response is a list of ids of the canceled orders.
Parameter | Mandatory | Description |
---|---|---|
action | YES | cancelAllOrder |
venue | YES | venue name |
symbol | NO | Only cancel orders open for the specified trading pair |
Response:
Parameter | Mandatory | Description |
---|---|---|
orderId | YES | Order ID, unique identifier of an order. |
The following request example is cancel all:
Cancel all order request:
{
"action": "cancelAllOrder",
"data": {
"venue": "VENUE1",
"symbol": "BINANCE"
}
}
Response:
{
"result": [
"519e f355d9884e1f8e3d3ffc7caf13b5",
"519e f355d9884e1f8e3d3ffc7caf13b3",
"519e f355d9884e1f8e3d3ffc7caf14b5",
"519e f355d9884e1f8e3d3ffc7caf13b6"
],
"type": "order"
}
Order Update
Once logged in, you've subscribed to the Order Event, the system will send update messages to notify the Client that the order execution report changed.
Parameter Description:
Parameter | Description |
---|---|
lastFilledQuantity | last filled quantity |
lastFilledPrice | last filled price |
lastFilledCreatedAt | last filled time |
lastCommission | trading fees happen in this fill |
lastCommissionCurrency | the currency of the trading fee |
isTaker | this field indicates if the fill was the result of a liquidity provider or liquidity taker. TRUE indicates Taker and FALSE indicates Maker |
The following example of the order status update message notifying that an execution report for the order has changed:
Order Update Payload:
{
"result": {
"accountId": "ST-00000001",
"venue": "VENUE1",
"orderId": "000000121574697605570321",
"tradeId": "ioNE5KwqytFw8TzDy7l41IMdRBc=",
"symbol": "BTCUSD",
"orderType": "LIMIT",
"timeInForce": 1,
"orderSide": "BUY",
"limitPrice": 100.0,
"quantity": 1.12,
"filledAveragePrice": 100.0,
"filledCumulativeQuantity": 1.12,
"openQuantity": 0,
"orderStatus": "FILLED",
"createdAt": 1552116459467,
"updatedAt": 1552116459467,
"cancelledUpdatedAt": null,
"filledUpdatedAt": 1552116459467,
"lastCommission": 0.112,
"lastCommissionCurrency": "USD",
"lastFilledQuantity": 1.12,
"lastFilledPrice": 100.0,
"lastFilledCreatedAt": 1552116459467,
"isTaker": true
},
"type": "order"
}
Account Update
Once logged in, you've subscribed to the Account Event, the system will send messages of account update, it is sent any time an account balance has changed. Update occurs during the following:
- Create new order or orders execute
- Deposits or withdrawals from the account
- Transfer of funds between accounts
Response Description:
Parameter | Description |
---|---|
accountId | account ID |
amount | total amount |
available | available amount |
currency | currency name |
frozen | frozen amount |
venue | Venue name |
Account Update Payload:
{
"result": [{
"accountId": "STA-00000001",
"amount": 0.00512281,
"available": 0.00512281,
"currency": "BTC",
"frozen": 0,
"venue": "BINANCE"
}],
"type": "asset"
}
FIX API
FIX (Financial Information exchange) is a standard protocol which can be used to enter orders, submit cancel requests, and receive fills. Users of the FIX API will typically have existing software using FIX for order management. Users who are not familiar with FIX should first consider using the REST API.
FIX API can be implemented using QuickFIX with the following language support:
Configuration information are as follows:
Configuration for quickfix
FIX API ENDPOINT URL
For the venues we offer co-location, the FIX API endpoint URL will be different each, make sure to use the right base URL accordingly.
BINANCE
fixapibn.apifiny.com:1443
BINANCEUS
fixapibnu.apifiny.com:1443
COINBASEPRO
fixapicb.apifiny.com:1443
FTX
fixapiftx.apifiny.com:1443
HUOBI
fixapihb.apifiny.com:1443
KUCOIN
fixapikc.apifiny.com:1443
OKX
fixapiok.apifiny.com:1443
Other Venues
fix.api.apifiny.com:1443
Quickfix Configuration
Quickfix configuration sample codes:
[default]
ConnectionType=initiator
SenderCompID=STA-00000001
TargetCompID=APIFINY
SocketConnectHost=fix.api.apifiny.com
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=30
ReconnectInterval=5
UseDataDictionary=Y
ResetSeqNumFlag=Y
ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
[session]
BeginString=FIX.4.2
SocketConnectPort=1443
Here is an optional Python3
sample codes for login using quickfix:
Logon
def toAdmin(self, message, sessionID):
timestamp = str(int(time.time() * 1000))
if message.getHeader().getField(35) is "A":
signature = get_signature(timestamp, Your_Secret_Key)
message.setField(fix.RawDataLength(len(signature)))
message.setField(fix.RawData(signature))
message.setField(fix.SecurityID(Your_API_Key))
message.setField(fix.SecurityDesc(timestamp))
msg = message.toString().replace(__SOH__, "|")
logger.info("S >> " + msg)
return
get_signature
is as following:
# python3
import hashlib
import hmac
import json
def gen_signature(Your_secret_key, data) -> str:
message = data.encode("utf-8")
return hmac.new(Your_secret_key.encode("utf-8"), message, digestmod=hashlib.sha256).hexdigest()
Requires authentication. Add Signature in toAdmin
.
Method: Fix
Digest: hash value of account_id using sha256 hash.
Request:
Tag | Name | Description |
---|---|---|
35 | MsgType | A |
95 | RawDataLength | Length of signature data |
96 | RawData | Signature, using your "Your_Secret_Key" as the key and timestamp as the value for the HMAC operation to generate |
48 | SecurityID | apiKey Your API key, displayed as the Access key on web GUI |
107 | SecurityDesc | timestamp Timestamp for your request |
Response:
If successfully message MsgType(35)=A,otherwise MsgType(35)=5 will be returned.
New Order
msg = quickfix42.NewOrderSingle()
msg.setField(fix.ClOrdID(order_id)) # generated order id:the last 16 bits are a 13-bit timestamp + three random numbers up to 64 characters.
msg.setField(fix.Symbol(symbol)) # symbol:BTCUSDT
msg.setField(fix.HandlInst('1'))
msg.setField(fix.OrdType(fix.OrdType_LIMIT)) # OrdType:limit
order.setField(fix.TimeInForce_IMMEDIATE_OR_CANCEL)
msg.setField(fix.TransactTime())
msg.setField(fix.Side(side))
msg.setField(fix.Price(price))
msg.setField(fix.Account(account_id))
msg.setField(fix.OrderQty(qty))
msg.setField(fix.SecurityExchange("BINANCE"))
msg.setField(fix.Text("new Order"))
quickfix.Session.sendToTarget(msg, application.sessionID)
Request:
Tag | Name | Description |
---|---|---|
11 | ClOrdID | Only present on order acknowledgements, ExecType=New (150=0) |
55 | Symbol | Symbol of the original order |
21 | HandlInst | Instructions for order handling on Broker trading floor |
40 | OrdType | 1 = Market(only some venues support); 2 = Limit; 6 = SOR |
59 | TimeInForce | Specifies how long the order remains in effect, 1=GTC, 3=IOC=, 7=PostOnly |
60 | TransactTime | Time the event occurred |
54 | Side | Must be 1 to buy or 2 to sell |
44 | Price | Price of the fill if ExecType indicates a fill, otherwise the order price |
1 | Account | Account id |
38 | OrderQty | OrderQty as accepted |
207 | SecurityExchange | VENUE, e.g. BINANCE |
58 | Text | Free format text string |
Response:
If the order is accepted, an ExecutionReport (8) will be returned. Otherwise, an ExecutionReport with ExecType=8 (Rejected) will be returned.
Cancel Order
msg = quickfix42.OrderCancelRequest()
msg.setField(fix.ClOrdID(order_id))
msg.setField(fix.Account(account_id))
msg.setField(fix.SecurityExchange("BINANCE"))
msg.setField(fix.Text("Cancel Order"))
Request:
Tag | Name | Description |
---|---|---|
11 | ClOrdID | Only present on order acknowledgements, ExecType=New (150=0) |
1 | Account | account id |
207 | SecurityExchange | VENUE, e.g. BINANCE |
58 | Text | Free format text string |
Response:
If the order is successfully cancelled, an ExecutionReport (8) with ExecType=4
(Canceled) will be returned. Otherwise, an OrderCancelReject (9) will be returned.
Execution Report
Execution Report message Sent by the broker/gateway when an order is accepted, rejected, partially filled, or canceled.
Tag | Name | Description |
---|---|---|
11 | ClOrdID | Only present on order acknowledgements, ExecType=New (150=0) |
37 | OrderID | OrderID from the ExecutionReport with ExecType=New (150=0) |
17 | ExecId | Unique identifier of execution message |
55 | Symbol | Symbol of the original order |
54 | Side | Must be 1 to buy or 2 to sell |
32 | LastShares | Amount filled (if ExecType=1). Also called LastQty as of FIX 4.3 |
44 | Price | Price of the fill if ExecType indicates a fill, otherwise the order price |
38 | OrderQty | OrderQty as accepted |
60 | TransactTime | Time the event occurred |
150 | ExecType | 1 for Partially fill and 2 for fill |
39 | OrdStatus | Order status as of the current message |
ExecType VALUES
ExecType | Description |
---|---|
0 | NEW, ACK |
1 | PARTIAL_FILL |
2 | FILL |
4 | CANCELED |
8 | REJECTED |
Query order status
msg = quickfix42.OrderStatusRequest()
msg.setField(fix.ClOrdID(order_id))
msg.setField(fix.Account(account_id))
msg.setField(fix.SecurityExchange("BINANCE"))
Request:
Tag | Name | Description |
---|---|---|
11 | ClOrdID | Only present on order acknowledgements, ExecType=New (150=0) |
1 | Account | account id |
207 | SecurityExchange | VENUE, e.g. BINANCE |
Response:
The response to an Order Status Request is an ExecutionReport (8) .
Status/Error Codes
There are two categories of error codes, one set generated by HTTP
, typically by a server for a client request, and the other category is a set of Apifiny Connect application status/error codes.
HTTP Error code
HTTP status codes are divided into 5 ranges as follows:
- 1xx informational response – the request was received, continuing process
- 2xx successful – the request was successfully received, understood, and accepted
- 3xx redirection – further action needs to be taken in order to complete the request
- 4xx client error – the request contains bad syntax or cannot be fulfilled
- 5xx server error – the server failed to fulfil an apparently valid request
Some of the most common HTTP error codes include:
HTTP 403 - too many errors and IP is blocked
HTTP 502 - service is not available
Apifiny Connect Status/Error Codes
Apifiny Connect status/error codes are returned as a hexadecimal number. The number on the farthest right delineates client side errors (designated by the hexadecimal number A) from server side errors (designated by the hexadecimal number B).
Client side errors should be corrected at the client and the request resubmitted. Server side errors will have a max retry count as well as a resubmit interval of 50 ms. Persistent resubmissions will result in suspension of the submitting IP.
Error Code | Explanation | Hexadecimal Error Code |
---|---|---|
65548 | common error | 0x01000C |
65562 | general request error, please check if the parameters in request are correct. | 0x01001A |
65579 | general server side error, retry or contact customer service. | 0x01002B |
65595 | server busy please wait | 0x01003B |
65658 | IP is not in the white list | 0x01007A |
131098 | Account Session Stopped | 0x02001A |
131099 | create account error | 0x02001B |
131114 | Request too often, please try later | 0x02002A |
131115 | Account doesn't exist, please verify account ID. | 0x02002B |
131147 | Due to local regulations, this service with Apifiny are currently not available in your region | 0x02004B |
131130 | Sorry, the venue does not match the request url, please check the base url. | 0x02003A |
131162 | Account status doesn't satisfy request, please verify account status. | 0x02005A |
131178 | SQL execution error, duplicate primary key | 0x02006A |
196634 | token error | 0x03001A |
196650 | session error | 0x03002A |
196666 | session extension validation Error | 0x03003A |
196682 | sso token error | 0x03004A |
196698 | session type error | 0x03005A |
262170 | withdraw address not exist | 0x04001A |
262186 | the number of withdraw addresses reaches limit | 0x04002A |
262202 | Util_Unknown_Symbol | 0x04003A |
262218 | Util_Unknown_Currency | 0x04004A |
262250 | Util_Unknown_CoinType | 0x04006A |
262266 | Util_Unknown_Coin | 0x04007A |
262299 | Util_Create_Withdraw_Address_Error | 0x04009B |
262427 | A connection issue encountered, please try again | 0x04011B |
262443 | You have reach your daily withdrawal limit, please try next day | 0x04012B |
262458 | You haven't connected to Apifiny via Fireblocks Network yet. | 0x04013A |
262459 | You need to be ID verified to use this feature | 0x04013B |
5243242 | Order doesn't exist, please change order ID, Execute Fail | 0x050016A |
327706 | Order ID doesn't exist, please recreate order id. | 0x05001A |
327722 | Order_OriginalOrderIdDuplicate | 0x05002A |
327723 | New order failure,retry or contact customer service. | 0x05002B |
327738 | Order_OpenOrderNotExist | 0x05003B |
327738 | Order doesn't exist, please change order ID. | 0x05003A |
327741 | This exchange is currently under maitenance or not supported yet. | 0x05003D |
327754 | Order_CancelPendingSubmitWait | 0x05004A |
327755 | cancel order error, need to contact customer service. | 0x05004B |
327786 | timeout for new order or other request, please wait and retry. | 0x05005A |
327786 | orderSide parameter error | 0x05006B |
327786 | too many open orders, cannot create new order, need to delete some orders and retry. | 0x05006A |
327802 | order id repeat | 0x05007B |
327802 | cannot cancel order under current order status, need confirm order status and retry or abandon request. | 0x05007A |
327818 | Order create failed, incorrect timestamp format | 0x05008A |
327818 | timeout for cancel order operation, need wait and retry. | 0x05008A |
327834 | Order create failed, timestamp error | 0x05009A |
327836 | Order_Detail_Not_Exist | 0x05009C |
327946 | Order_Status_Not_Pending_Submit_Cancel | 0x05010A |
327948 | Order_Log_Not_Exist order | 0x05010C |
327962 | the number of new order within 24 hours exceed limit, please contact customer service. | 0x05011A |
327978 | order id rule error | 0x05012A |
328010 | the order is being cancelled, please verify order status. | 0x05014A |
328026 | order cannot be canceled when in Pending_Submit status,please wait for status changed to submitted to cancel order.( if order status is still pending submit after 10 minutes, please contact customer service. ) | 0x05015A |
328042 | Order_GBBO_Error | 0x05016A |
328058 | SOM_Request_Error | 0x05017A |
328074 | Your account has reached the trade amount limitation | 0x05018A |
393242 | Asset_AvailableNotEnough. | 0x06001A |
393242 | withdraw ticket error, please check or create a withdraw ticket first. | 0x06001B |
393258 | Not enough asset available. Please verify if there is enough asset in account. | 0x06002A |
393274 | asset free frozen not enough | 0x06003A |
393290 | asset reduce frozen not enough | 0x06004A |
393306 | Order_Cancel_TimeOut_Error | 0x06005A |
393322 | Asset_Activity_Submitted_Not_Exist | 0x06006A |
393338 | Asset_Query_Deposit_Address_Error | 0x06007A |
393354 | Assets in this currency are insufficient or non-existent | 0x06008A |
393355 | Asset_Activity_Completed_TxId_Error | 0x06008B |
393372 | Asset_Log_Not_Exist | 0x06009C |
393482 | Order_Create_TimeOut_Error | 0x06010A |
393514 | Asset_Activity_Id_Exist | 0x06012A |
393530 | Conversion between two currencies is not supported | 0x06013A |
2097162 | Signature Error | 0x20000A |
2097163 | Permission denied. Invalid API key or permissions for action. | 0x20000B |
2097178 | No matching market | 0x20001A |
2097179 | Timestamp for this request is outside of the recvWindow | 0x20001B |
SDK and Code Demonstration
Disclaimer:
The following SDKs are are only used to help users become familiar with the API endpoint. Please use it with caution and expand R&D according to your own situation.
Apifiny does not make any commitment to the safety and performance of the SDKs, nor will be liable for the risks or even losses caused by using the SDKs.
To get the provided SDK for Apifiny Connector, please visit https://github.com/Apifiny-IO/apifiny-connector-python, or use the command pip3 install -U apifiny
to get the latest python version.
Click to download the Python Demo.
We also have sample code for C++.
Click FIX Demo to download the package for integrating via FIX protocol.
Contact Us
- Apifiny API Telegram Group
- For any questions in sudden drop in performance with the API and/or Websockets.
- For any general questions about the API not covered in the documentation.