Introduction
We have language bindings in Shell, Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
General
v1.0.0
API Resources and Support Channels
- Home - Access and manage your trades.
- OpenApi-SDK
- - OpenApi-Python-SDK - Official OpenApi Python SDK
- - OpenApi-Java-SDK - Official OpenApi JAVA SDK
- - OpenApi-Node.JS-SDK - Official OpenApi Node JS SDK
- Telegram - Discussion Chat Group
- Discord - Official Discussion Discord Group
- Twitter - Official Twitter Channel
Zero-Knowledge Rollups
On-chain data availability and integrity can be ensured with StarkWare’s STARK proofs, a form of zero-knowledge proof (ZK-proof) technology that will help safeguard a fully non-custodial protocol. Built on the Ethereum network, this Layer 2 architecture publishes ZK-proofs directly to Ethereum smart contracts for verification. Transactions are also uniquely packaged for publishing on-chain for traders concerned about data privacy as only balance charges will be made visible.
Cross-Chain Deposits and Withdrawals
Support for the deposits and withdrawals for EVM-compatible chains are available on ApeX Pro. Tokens will be converted to USDC via the 1inch API protocol swap.
Cross-Chain Deposits
ApeX Pro has built multiple asset pools on different chains. When users deposit assets from a non-Ethereum chain, ApeX Pro will transfer an equivalent amount of assets to the user's L2 account through its corresponding asset pool, built on the respective chain.
When a user deposit USDC from A chain, ApeX Pro could transfer the corresponding amount USDC to the user's account in L2 through its own asset pool.
Cross-Chain Withdrawal
You can withdraw assets directly to different chain on ApeX Pro. When a user withdraws their assets to an EVM-compatible chain, the asset will first be transferred to ApeX Pro's L2 asset pool. Thereafter, ApeX Pro will transfer the corresponding amount of assets to the user's address from its own asset pool on the corresponding withdrawal chain.
Please note that the maximum withdrawal amount is not only limited by the total assets available in a user’s account, but also needs to be less than the maximum available amount of the chain's asset pool.
Example:
Assume that there is 10,000 USDC available in Alice's account. Alice wants to withdraw 10,000 USDC via the Polygon chain, but only 8,000 USDC is available in Polygon's asset pool on ApeX Pro. The system will inform Alice that the current available assets in the Polygon chain are insufficient and prompt Alice to withdraw from another chain.
Alice has two choices. She either withdraws 8,000 USDC or less from the Polygon chain and withdraw the remainder of her balance via another chain or proceed to withdraw 10,000 USDC via another chain of which assets pools has sufficient funds to process the withdrawal request.
Traders can safely and easily proceed with deposit and withdrawal transactions via preferred chain on ApeX Pro.
ApeX Pro will also use a monitoring program to adjust the balance of funds across chains to ensure sufficient assets in varying asset pools at any one time.
REST Base Endpoint:
Testnet:
https://testnet.pro.apex.exchange/api/
Mainnet:
https://pro.apex.exchange/api/
Testnet
- ApeX Pro's testnet can be found on
https://testnet.pro.apex.exchange
, built on the Goerli test network. - You can obtain assets for use on the testnet via the faucet here
https://testnet.pro.apex.exchange/faucet
. - ApeX Pro's USDC Token Address (Goerli Testnet):
0xd44BB808bfE43095dBb94c83077766382D63952a
Query path and Parameters:
- You must include ApeX Pro's version number in the url path, e.g. v1, v2.
- The parameter "url path" is not case-sensitive and lower case letters will be displayed by default. The en-dash (-) can be used as spaces between individual words.
- The HTTP endpoint parameters are in camel case, opening with lower case letters.
- Due to different time zones with time parameters, please use int64 across all instances by default.
- Randomly generated id and numbers may be long in length and considering that the js display may be intercepted, these will be reflected as a string by default
- For customized request headers, please enter key in upper case and use the en-dash (-) as spaces between individual words.
Http Get Request
Please add parameters to the query path.as
https://pro.apex.exchange/api/v1/transfers?limit=100&page=1¤cyId=USDC&chainIds=1
Http Post Request
Enter order data in body, in the content-type x-www-form-urlencoded. You do not need to encode your data. as
starkKey=xxxðAddress=yyy&chainId=zzz
Public API Endpoints (Verification Required)
Private API Endpoints (Authentication Required)
All requests made to private endpoints must be authenticated. The following signatures must be used for authentication:
1. ApiKey Signature
- An apiKey signature is required for all private API endpoints
- Users can obtain and save their public and private apiKey via wallet signature verification on ApeX Pro desktop or app
- API trading users can utilize python-sdk to generate the private and public key pair for apiKey and save them for future API requests, refer to python sdk
Generate apiKey
import os
import sys
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0x*****")
configs = client.configs()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="1")
regRes = client.register_user(nonce=nonceRes['data']['nonce'],starkKey=stark_key_pair_with_y_coordinate['public_key'],stark_public_key_y_coordinate=stark_key_pair_with_y_coordinate['public_key_y_coordinate'],ethereum_address=client.default_address)
key = regRes['data']['apiKey']['key']
secret = regRes['data']['apiKey']['secret']
passphrase = regRes['data']['apiKey']['passphrase']
#back stark_key_pair, apiKey,and accountId for private Api or create-oreder or withdraw
print(stark_key_pair_with_y_coordinate)
print(regRes['data']['account']['positionId'])
print(regRes['data']['apiKey'])
import os
import sys
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0x*****")
configs = client.configs()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="1")
regRes = client.register_user(nonce=nonceRes['data']['nonce'],starkKey=stark_key_pair_with_y_coordinate['public_key'],stark_public_key_y_coordinate=stark_key_pair_with_y_coordinate['public_key_y_coordinate'],ethereum_address=client.default_address)
key = regRes['data']['apiKey']['key']
secret = regRes['data']['apiKey']['secret']
passphrase = regRes['data']['apiKey']['passphrase']
#back stark_key_pair, apiKey,and accountId for private Api or create-oreder or withdraw
print(stark_key_pair_with_y_coordinate)
print(regRes['data']['account']['positionId'])
print(regRes['data']['apiKey'])
Signature content message includes timeStamp + method + path + dataString
message = timeStamp + method + path + dataString
Get Requests: dataString content is not required, append query parameters in the path
message = timeStamp + method + path
Post Requests: Request body is saved in dataString content. To ensure proper sorting for parameters within the request body, parameters will be sorted by alphabetical order, refer to python sdk
Sign request message by apiSecret
def sign(
self,
request_path,
method,
iso_timestamp,
data,
):
sortedItems=sorted(data.items(),key=lambda x:x[0],reverse=False)
dataString = '&'.join('{key}={value}'.format(
key=x[0], value=x[1]) for x in sortedItems if x[1] is not None)
message_string = (
iso_timestamp +
method +
request_path +
dataString
)
hashed = hmac.new(
base64.standard_b64encode(
(self.api_key_credentials['secret']).encode(encoding='utf-8'),
),
msg=message_string.encode(encoding='utf-8'),
digestmod=hashlib.sha256,
)
return base64.standard_b64encode(hashed.digest()).decode()
def sign(
self,
request_path,
method,
iso_timestamp,
data,
):
sortedItems=sorted(data.items(),key=lambda x:x[0],reverse=False)
dataString = '&'.join('{key}={value}'.format(
key=x[0], value=x[1]) for x in sortedItems if x[1] is not None)
message_string = (
iso_timestamp +
method +
request_path +
dataString
)
hashed = hmac.new(
base64.standard_b64encode(
(self.api_key_credentials['secret']).encode(encoding='utf-8'),
),
msg=message_string.encode(encoding='utf-8'),
digestmod=hashlib.sha256,
)
return base64.standard_b64encode(hashed.digest()).decode()
- Place signature content, apiKey and related information in the request header
Parameter | Position | Type | Type | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | signstr |
APEX-TIMESTAMP | header | string | true | request timeStamp |
APEX-API-KEY | header | string | true | key |
APEX-PASSPHRASE | header | string | true | passphrase |
2. StarkKey Signature
- For orders and withdrawals, two signatures are required: apiKey and starkKey.
- Users can obtain and save their public and private starkKey via wallet signature verification on ApeX Pro desktop or app
- API trading users with Ethereum private keys can utilize python-sdk to generate the private and public key pair for starkKey and save them for future API requests
- Refer to the starkkey Signature
Response Parameters
- Application data can be found in "data".
- If request fails, response parameters are as follows:
code
: Code errormsg
: Message errorkey
: Keyword error, corresponding multi-language prompt Key will be selected based on keywords Keydetail
: Parameter data error used to supplement error prompts
{
"code": 10002,
"msg": "has been expired!",
"data": {
"time": 1649409187477
},
"key": "ORDER_NOT_CANCEL_FILLED",
"detail":{
"orderId":"1234556"
}
}
Client_id and Nonce Generation
When creating order and withdrawal requests, you will need to send a unique and randomly generated client_Id to server. You can refer to python codes:
def random_client_id():
return str(int(float(str(random.random())[2:])))
def random_client_id():
return str(int(float(str(random.random())[2:])))
When utilizing starkKey signatures in creating order and withdrawal requests, you will need to change client_Id to nonce in the server. Refer to python codes for the algorithm:
def nonce_from_client_id(client_id):
message = hashlib.sha256()
message.update(client_id.encode()) # Encode as UTF-8.
return int(message.digest().hex()[0:8], 16)
def nonce_from_client_id(client_id):
"""Generate a nonce deterministically from an arbitrary string."""
message = hashlib.sha256()
message.update(client_id.encode()) # Encode as UTF-8.
return int(message.digest().hex()[0:8], 16)
Rate Limits
IP Rate Limit
If you receive a HTTP 403 (Access Denied) response, your IP has been either temporarily or permanently banned. You should immediately review the below guidelines to ensure that your application does not continue to violate the limit.
Limit | Comment |
---|---|
Limit 600 requests per 60 secs | Per IP |
API Rate Limit
Rate Limits for All Private Endpoints Per Account
Limit | Comment |
---|---|
80 requests per 60 secs | POST request |
600 requests per 60 secs | GET request |
Orders Limit
Rate Limits for Creating Orders
Limit | Comment |
---|---|
200 orders | Per user |
Margin
- On ApeX Pro, USDC is the default settleCurrency for all available contracts on the platform. The tick size for USDC is set by default to 6 decimal points.
- Every contract will have an initialMarginRate and maintenanceMarginRate.
- initialMarginRate (IMR): The margin required to open a position and is based on the position size and leverage.
- maintenanceMarginRate (MMR): The minimum amount required for holding a leveraged position
Margin required for each single position:
initialMargin = abs(Size * Oracle Price* initialMarginRate)
maintenanceMargin = abs(Size * Oracle Price* maintenanceMarginRate)
Margin required by all positions under all contract types under your account:
total initialMargin = Σ abs(Size * Oracle Price* initialMarginRate)
total maintenanceMargin = Σ abs(Size * Oracle Price* maintenanceMarginRate)
TotalAccountValue =Q+Σ abs(Size*Oracle Price)
where Q is the USDC balance in your account.
Liquidation
When the net equity of the account falls below the maintenance margin required, your position will be taken over by the liquidation engine and liquidated.
Deleverage
Funding Fee
Funding fees will be exchanged between long and short position holders every 1 hour.
Please note that the funding rate will fluctuate in real time every 1 hour. If the funding rate is positive upon settlement, long position holders will pay the funding fees to short position holders. Similarly, when the funding rate is negative, short positive holders will pay long position holders.
Funding Fees = Position Value * Index Price * Funding Rate
Oracle Price
ApeX Pro utilizes Oracle Price in the following case(s):
- User Balance
- Liquidation Price
ApeX Pro pulls Oracle Price data from Stork, which is an oracle solution native to StarkNet and StarkEx. Stork will provide the price datapoint for ApeX Pro to determine the Liquidation Price.
Index Price
ApeX Pro utilizes Index Price in the following case(s): - Profits and Losses - Funding Fees
Index Price is the sum of prices pulled from multiple crypto spot exchanges, then calculated based on weighted average. It is also used to derive funding fees.
If the exchange's settlement token is not in USDC, e.g. In BTC-USDT, the exchange rate between USDC and USDT will be calculated as well.
- BTC-USDC
exchange | symbol | weight |
---|---|---|
Binance | BTC-USDT | 1/6 |
CoinbasePro | BTC-USD | 1/6 |
FTX | BTC-USD | 1/6 |
OKEX | BTC-USDT | 1/6 |
Gemini | BTC-USD | 1/6 |
Kraken | BTC-USD | 1/6 |
- ETH-USDC
exchange | symbol | weight |
---|---|---|
Binance | ETH-USDT | 1/6 |
CoinbasePro | ETH-USD | 1/6 |
FTX | ETH-USD | 1/6 |
OKEX | ETH-USDT | 1/6 |
Gemini | ETH-USD | 1/6 |
Kraken | ETH-USD | 1/6 |
Symbols Configs
- BTC-USDC
name | value |
---|---|
Min ticker price | 0.5 |
Min step size | 0.001 |
Min Order size | 0.001 |
Max Order size | 100 |
Max Position size | 500 |
InitialMarginRate | 0.05 |
MaintenanceMarginRate | 0.03 |
Baseline position value | 1000000 |
incrementalPositionValue | 1000000 |
incrementalInitialMarginRate | 0.0075 |
fundingInterestRate | 0.0003 |
Max fundingInterestRate | 0.00046875,-0.00046875 |
- ETH-USDC
name | value |
---|---|
Min ticker price | 0.05 |
Min step size | 0.01 |
Min Order size | 0.01 |
Max Order size | 1000 |
Max Position size | 10000 |
InitialMarginRate | 0.05 |
MaintenanceMarginRate | 0.03 |
Baseline position value | 1000000 |
incrementalPositionValue | 1000000 |
incrementalInitialMarginRate | 0.0075 |
fundingInterestRate | 0.0003 |
Max fundingInterestRate | 0.00046875,-0.00046875 |
General V3 for Omni
v3.0.0
API Resources and Support Channels
- Home - Access and manage your trades.
- OpenApi-SDK for v3
- - OpenApi-Python-SDK - Official OpenApi Python SDK
- Telegram - Discussion Chat Group
- Discord - Official Discussion Discord Group
- Twitter - Official Twitter Channel
REST Base Endpoint:
Testnet:
https://testnet.omni.apex.exchange/api/
Mainnet:
https://omni.apex.exchange/api/
Testnet
- ApeX Omni's testnet can be found on
https://testnet.omni.apex.exchange
, built on the BNB test chain or base sepolia test chain. - You can obtain assets for use on the testnet via the faucet here
https://testnet.omni.apex.exchange/faucet
. - ApeX Omni's USDT Token Address (BNB test chain):
0x01CB59F3C16FAfe63955e4d435adAFa23d9aBBde
- ApeX Omni's USDT Token Address (base sepolia test chain):
0x2340C88808dcE139B36864970074315BCb0c9Fe0
Development
apex omni
is being actively developed, and new API changes should arrive onapex omni
very quickly.apex omni
usesrequests
andwebsocket
for its methods, alongside other built-in modules. Anyone is welcome to branch/fork the repository and add their own upgrades. If you think you've made substantial improvements to the module, submit a pull request and we'll gladly take a look.- If the user's computer using arm chip, change (libzklink_sdk-arm.dylib and zklink_sdk-arm.py) to (libzklink_sdk.dylib, zklink_sdk.py) and replace old (libzklink_sdk.dylib and zklink_sdk.py) in the directory ./apexpro/ and ./test/
- If the user's computer using x86 chip, change (libzklink_sdk-x86.dylib and zklink_sdk-x86.py) to (libzklink_sdk.dylib, zklink_sdk.py) and replace old (libzklink_sdk.dylib and zklink_sdk.py) in the directory ./apexpro/ and ./test/
- If the user's computer OS is windows, copy zklink_sdk.dll in the directory ./apexpro/ and ./test/. Change zklink_sdk-pc.py to zklink_sdk.py and replace and zklink_sdk.py in the directory ./apexpro/ and ./test/
- If the user's computer OS is Linux and x86 chip, copy zklink_sdk.so in the directory ./apexpro/ and ./test/. Change zklink_sdk-pc.py to zklink_sdk.py and replace and zklink_sdk.py in the directory ./apexpro/ and ./test/
Installation
apex omni
requires Python 3.6.1 - Python 3.9.x . The module can be installed manually or via apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linux with pip
:
pip3 install apexomni-arm
pip3 install apexomni-x86-mac
pip3 install apexomni-x86-windows-linux
Query path and Parameters:
- You must include ApeX Omni's version number in the url path, e.g. v3.
- The parameter "url path" is not case-sensitive and lower case letters will be displayed by default. The en-dash (-) can be used as spaces between individual words.
- The HTTP endpoint parameters are in camel case, opening with lower case letters.
- Due to different time zones with time parameters, please use int64 across all instances by default.
- Randomly generated id and numbers may be long in length and considering that the js display may be intercepted, these will be reflected as a string by default
- For customized request headers, please enter key in upper case and use the en-dash (-) as spaces between individual words.
Http Get Request
Please add parameters to the query path.as
https://omni.apex.exchange/api/v3/transfers?limit=100&page=1¤cyId=USDC&chainIds=1
Http Post Request
Enter order data in body, in the content-type x-www-form-urlencoded. You do not need to encode your data. as
l2Key=xxxðAddress=yyy&chainId=zzz
Public API Endpoints (Verification Required)
Private API Endpoints (Authentication Required)
All requests made to private endpoints must be authenticated. The following signatures must be used for authentication:
1. ApiKey Signature
- An apiKey signature is required for all private API endpoints
- Users can obtain and save their public and private apiKey via wallet signature verification on ApeX Omni desktop or app
- API trading users can utilize python-sdk to generate the private and public key pair for apiKey and save them for future API requests, refer to python sdk
Generate apiKey
from apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_OMNI_MAIN_ARB, NETWORKID_MAIN
print("Hello, Apex Omni")
priKey = "your eth private key"
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs_v3()
zkKeys = client.derive_zk_key(client.default_address)
print(zkKeys)
print(zkKeys['seeds'])
print(zkKeys['l2Key'])
print(zkKeys['pubKeyHash'])
nonceRes = client.generate_nonce_v3(refresh="false", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_OMNI_MAIN_ARB)
regRes = client.register_user_v3(nonce=nonceRes['data']['nonce'],l2Key=zkKeys['l2Key'], seeds=zkKeys['seeds'],ethereum_address=client.default_address)
print(regRes['data']['apiKey']['key'])
print(regRes['data']['apiKey']['secret'])
print(regRes['data']['apiKey']['passphrase'])
time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)
#back zkKeys, apiKey,and accountId for private Api or create-order transfer or withdraw
print(regRes['data']['apiKey'])
changeRes = client.change_pub_key_v3(chainId=NETWORKID_OMNI_MAIN_ARB, seeds=zkKeys.get('seeds'), ethPrivateKey=priKey, zkAccountId = accountRes.get('spotAccount').get('zkAccountId'), subAccountId = accountRes.get('spotAccount').get('defaultSubAccountId'),
newPkHash = zkKeys.get('pubKeyHash'), nonce= accountRes.get('spotAccount').get('nonce'), l2Key= zkKeys.get('l2Key'))
print(changeRes)
time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)
from apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_OMNI_MAIN_ARB, NETWORKID_MAIN
print("Hello, Apex Omni")
priKey = "your eth private key"
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs_v3()
zkKeys = client.derive_zk_key(client.default_address)
print(zkKeys)
print(zkKeys['seeds'])
print(zkKeys['l2Key'])
print(zkKeys['pubKeyHash'])
nonceRes = client.generate_nonce_v3(refresh="false", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_OMNI_MAIN_ARB)
regRes = client.register_user_v3(nonce=nonceRes['data']['nonce'],l2Key=zkKeys['l2Key'], seeds=zkKeys['seeds'],ethereum_address=client.default_address)
print(regRes['data']['apiKey']['key'])
print(regRes['data']['apiKey']['secret'])
print(regRes['data']['apiKey']['passphrase'])
time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)
#back zkKeys, apiKey,and accountId for private Api or create-order transfer or withdraw
print(regRes['data']['apiKey'])
changeRes = client.change_pub_key_v3(chainId=NETWORKID_OMNI_MAIN_ARB, seeds=zkKeys.get('seeds'), ethPrivateKey=priKey, zkAccountId = accountRes.get('spotAccount').get('zkAccountId'), subAccountId = accountRes.get('spotAccount').get('defaultSubAccountId'),
newPkHash = zkKeys.get('pubKeyHash'), nonce= accountRes.get('spotAccount').get('nonce'), l2Key= zkKeys.get('l2Key'))
print(changeRes)
time.sleep(10)
accountRes = client.get_account_v3()
print(accountRes)
Signature content message includes timeStamp + method + path + dataString
message = timeStamp + method + path + dataString
Get Requests: dataString content is not required, append query parameters in the path
message = timeStamp + method + path
Post Requests: Request body is saved in dataString content. To ensure proper sorting for parameters within the request body, parameters will be sorted by alphabetical order, refer to python sdk
Sign request message by apiSecret
def sign(
self,
request_path,
method,
iso_timestamp,
data,
):
sortedItems=sorted(data.items(),key=lambda x:x[0],reverse=False)
dataString = '&'.join('{key}={value}'.format(
key=x[0], value=x[1]) for x in sortedItems if x[1] is not None)
message_string = (
iso_timestamp +
method +
request_path +
dataString
)
hashed = hmac.new(
base64.standard_b64encode(
(self.api_key_credentials['secret']).encode(encoding='utf-8'),
),
msg=message_string.encode(encoding='utf-8'),
digestmod=hashlib.sha256,
)
return base64.standard_b64encode(hashed.digest()).decode()
def sign(
self,
request_path,
method,
iso_timestamp,
data,
):
sortedItems=sorted(data.items(),key=lambda x:x[0],reverse=False)
dataString = '&'.join('{key}={value}'.format(
key=x[0], value=x[1]) for x in sortedItems if x[1] is not None)
message_string = (
iso_timestamp +
method +
request_path +
dataString
)
hashed = hmac.new(
base64.standard_b64encode(
(self.api_key_credentials['secret']).encode(encoding='utf-8'),
),
msg=message_string.encode(encoding='utf-8'),
digestmod=hashlib.sha256,
)
return base64.standard_b64encode(hashed.digest()).decode()
- Place signature content, apiKey and related information in the request header
Parameter | Position | Type | Type | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | signstr |
APEX-TIMESTAMP | header | string | true | request timeStamp |
APEX-API-KEY | header | string | true | key |
APEX-PASSPHRASE | header | string | true | passphrase |
2. zkKeys Signature
- For orders, transfers and withdrawals, two signatures are required: apiKey and zkKeys.
- Users can obtain and save their l2Key and seed zkKeys via wallet signature verification on ApeX Omni desktop or app
- API trading users with Ethereum private keys can utilize python-sdk to generate the l2Key and seed for zkKeys and save them for future API requests
- Refer to the zkKeys Signature
Client_id and Nonce Generation
When creating order and withdrawal requests, you will need to send a unique and randomly generated client_Id to server. You can refer to python codes:
def random_client_id():
return str(int(float(str(random.random())[2:])))
def random_client_id():
return str(int(float(str(random.random())[2:])))
When utilizing zkKeys signatures in creating order and withdrawal requests, you will need to change client_Id to nonce and slotId in the server. Refer to python codes for the algorithm:
message = hashlib.sha256()
message.update(clientId.encode()) # Encode as UTF-8.
nonceHash = message.hexdigest()
nonceInt = int(nonceHash, 16)
maxUint32 = np.iinfo(np.uint32).max
maxUint64 = np.iinfo(np.uint64).max
slotId = (nonceInt % maxUint64)/maxUint32
nonce = nonceInt % maxUint32
accountId = int(accountId, 10) % maxUint32
message = hashlib.sha256()
message.update(clientId.encode()) # Encode as UTF-8.
nonceHash = message.hexdigest()
nonceInt = int(nonceHash, 16)
maxUint32 = np.iinfo(np.uint32).max
maxUint64 = np.iinfo(np.uint64).max
slotId = (nonceInt % maxUint64)/maxUint32
nonce = nonceInt % maxUint32
accountId = int(accountId, 10) % maxUint32
Spot Account
Users can deposit USDT into Spot account, and in the future, deposits of BTC, ETH, BNB, USDC and other assets into Spot Account will be opened.
Contract Account
Margin
- On ApeX Omni, USDT is the default settleCurrency for all available contracts on the platform. The tick size for USDT is set by default to 6 decimal points.
- Every contract will have an initialMarginRate and maintenanceMarginRate.
- initialMarginRate (IMR): The margin required to open a position and is based on the position size and leverage.
- maintenanceMarginRate (MMR): The minimum amount required for holding a leveraged position
Margin required for each single position:
initialMargin = abs(Size * Oracle Price* initialMarginRate)
maintenanceMargin = abs(Size * Oracle Price* maintenanceMarginRate)
Margin required by all positions under all contract types under your account:
total initialMargin = Σ abs(Size * Oracle Price* initialMarginRate)
total maintenanceMargin = Σ abs(Size * Oracle Price* maintenanceMarginRate)
TotalAccountValue =Q+Σ abs(Size*Oracle Price)
where Q is the USDT balance in your account.
Liquidation
When the net equity of the account falls below the maintenance margin required, your position will be taken over by the liquidation engine and liquidated.
Funding Fee
Funding fees will be exchanged between long and short position holders every 1 hour.
Please note that the funding rate will fluctuate in real time every 1 hour. If the funding rate is positive upon settlement, long position holders will pay the funding fees to short position holders. Similarly, when the funding rate is negative, short positive holders will pay long position holders.
Funding Fees = Position Value * Index Price * Funding Rate
Index Price
ApeX Pro utilizes Index Price in the following case(s): - User Balance - Liquidation Price - Profits and Losses - Funding Fees
Index Price is the sum of prices pulled from multiple crypto spot exchanges, then calculated based on weighted average. It is also used to derive funding fees.
Rate Limits
IP Rate Limit
If you receive a HTTP 403 (Access Denied) response, your IP has been either temporarily or permanently banned. You should immediately review the below guidelines to ensure that your application does not continue to violate the limit.
Limit | Comment |
---|---|
Limit 600 requests per 60 secs | Per IP |
API Rate Limit
Rate Limits for All Private Endpoints Per Account
Limit | Comment |
---|---|
80 requests per 60 secs | POST request |
600 requests per 60 secs | GET request |
Orders Limit
Rate Limits for Creating Orders
Limit | Comment |
---|---|
200 orders | Per user |
V2 or V1
ApeX OpenAPI V2 now supports USDT currency pairs! Users can seamlessly manage USDT and USDC accounts, handle deposits and withdrawals, and meet all their currency pair trading needs through V2 APIs. Additionally, V2 adheres to the standards set by V1 for a consistent experience.
Current API Coverage
OpenAPI | USDT Account | USDC Account | USDT Perp | USDC Perp | Quote | USDT Deposit | USDC Deposit |
---|---|---|---|---|---|---|---|
V1 | NO | YES | NO | YES | YES | NO | YES |
V2 | YES | YES | YES | YES | YES | YES | YES |
warning
Please note, the USDT account and USDC account are independent. Assets and positions are not shared, and deposits and withdrawals are processed separately.
To start trading USDT perpetual contract currency pairs, it is necessary to request V2 onboarding and register a USDT account.
sdk-v2
- The client initialization methods in v1 and v2 remain the same. For example:
client = HttpPrivate(APEX_HTTP_TEST, network_id=NETWORKID_TEST, eth_private_key=priKey)
client = HttpPublic(APEX_HTTP_MAIN)
- If the method names in v1 and v2 are identical, it indicates that the implementation logic in v1 and v2 has not changed, and the path supports HTTP requests for both v1 and v2. For example:
client = HttpPublic(APEX_HTTP_MAIN)
print(client.klines(symbol="ETHUSDT",interval=5,start=1681463600, end=1681563600, limit=5))
print(client.depth(symbol="BTC-USDC"))
- If the method names in v1 and v2 differ, it signifies a change in the implementation logic between v1 and v2, and the request paths also differ. Request methods are distinguished by v2 and v1. For example:
client = HttpPrivate(APEX_HTTP_TEST, network_id=NETWORKID_TEST, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v2()
accountRes = client.get_account_v2()
print(accountRes)
PublicApi V3 for Omni
v3.0.0
GET System Time V3
GET /v3/time
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.server_time()
curl "https://omni.apex.exchange/api/v3/time"
Successful Response
{
"data": {
"time": 1648626529
}
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» time | integer | true | none | none |
GET All Config Data V3
USDC and USDT config
GET /v3/symbols
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.configs_v3()
curl "https://omni.apex.exchange/api/v3/symbols"
Successful Response
{
"spotConfig": {
"assets": [
{
"tokenId": "17",
"token": "USDC",
"displayName": "USD Coin",
"decimals": 18,
"showStep": "0.01",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDC.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "35",
"token": "BNB",
"displayName": "BNB",
"decimals": 18,
"showStep": "0.001",
"iconUrl": "https://static-pro.apex.exchange/icon/BNB.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "36",
"token": "ETH",
"displayName": "Ethereum",
"decimals": 18,
"showStep": "0.0001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_ETH.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "140",
"token": "USDT",
"displayName": "Tether USD Coin",
"decimals": 18,
"showStep": "0.01",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDT.svg",
"l2WithdrawFee": "0"
}
],
"global": {
"defaultRegisterTransferToken": "USDT",
"defaultRegisterTransferTokenId": "140",
"defaultRegisterSubAccountId": "0",
"defaultChangePubKeyZklinkChainId": "3",
"defaultChangePubKeyFeeTokenId": "140",
"defaultChangePubKeyFeeToken": "USDT",
"defaultChangePubKeyFee": "0",
"registerTransferLpAccountId": "577029250759000065",
"registerTransferLpSubAccount": "0",
"registerTransferLpSubAccountL2Key": "0x2924686165271a5de8248833a8ab7a6f7fb7f950d7512ecd56952283cc434d8c",
"perpLpAccountId": "",
"perpLpSubAccount": "",
"perpLpSubAccountL2Key": "",
"contractAssetPoolAccountId": "577390086971195406",
"contractAssetPoolZkAccountId": "46",
"contractAssetPoolSubAccount": "0",
"contractAssetPoolL2Key": "0xa54a045e186e7e8635b1d444e14f59c86767c685bbfff92d6b7118113d845d2f",
"contractAssetPoolEthAddress": "0xa50A3b5c5f6192742db99fA21d832ddd72D3028E"
},
"spot": [],
"multiChain": {
"chains": [
{
"chain": "BNB Chain - Testnet",
"chainId": "3",
"chainType": "0",
"l1ChainId": "97",
"chainIconUrl": "https://l2dex-image-static.dev.apexplus.exchange/chains/chain_tokens/BSC/BNB_BNB.svg",
"contractAddress": "0x20F48e49549163976f974E8983Bb451E5Dcf53fD",
"stopDeposit": false,
"feeLess": false,
"gasLess": false,
"gasToken": "BNB",
"dynamicFee": true,
"feeGasLimit": 300000,
"blockTimeSeconds": 15,
"rpcUrl": "https://data-seed-prebsc-2-s1.binance.org:8545",
"webRpcUrl": "https://data-seed-prebsc-2-s1.binance.org:8545",
"webTxUrl": "https://testnet.bscscan.com/tx/",
"txConfirm": 15,
"withdrawGasFeeLess": false,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDT.svg",
"token": "USDT",
"tokenAddress": "0x01cb59f3c16fafe63955e4d435adafa23d9abbde",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDT",
"needResetApproval": true,
"minFee": "2",
"maxFee": "200",
"feeRate": "0.0001"
},
{
"decimals": 6,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDC.svg",
"token": "USDC",
"tokenAddress": "0xf35a44977e9831f564c9af3b721748e840c1ef4c",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC",
"needResetApproval": true,
"minFee": "2",
"maxFee": "200",
"feeRate": "0.0001"
},
{
"decimals": 18,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/BNB.svg",
"token": "BNB",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "BNB",
"needResetApproval": true,
"minFee": "0.00001",
"maxFee": "0.01",
"feeRate": "0.0001"
}
]
},
{
"chain": "Base Sepolia Chain - Testnet",
"chainId": "11",
"chainType": "0",
"l1ChainId": "84532",
"chainIconUrl": "https://l2dex-image-static.dev.apexplus.exchange/chains/chain_logos/base.svg",
"contractAddress": "0x8cDdB93BD8845aE509a6eC1e29836852A9b41b10",
"stopDeposit": false,
"feeLess": false,
"gasLess": false,
"gasToken": "ETH",
"dynamicFee": true,
"feeGasLimit": 300000,
"blockTimeSeconds": 0,
"rpcUrl": "https://sepolia.base.org",
"webRpcUrl": "https://sepolia.base.org",
"webTxUrl": "https://sepolia.basescan.org/tx/",
"txConfirm": 15,
"withdrawGasFeeLess": false,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDT.svg",
"token": "USDT",
"tokenAddress": "0x2340c88808dce139b36864970074315bcb0c9fe0",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDT",
"needResetApproval": true,
"minFee": "2",
"maxFee": "200",
"feeRate": "0.0001"
},
{
"decimals": 6,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDC.svg",
"token": "USDC",
"tokenAddress": "0xaf3a3fd0eea662dd1aefa8b04c201038a4ff5761",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC",
"needResetApproval": true,
"minFee": "2",
"maxFee": "200",
"feeRate": "0.0001"
},
{
"decimals": 18,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/ETH.svg",
"token": "ETH",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": false,
"displayToken": "ETH",
"needResetApproval": true,
"minFee": "0.00001",
"maxFee": "0.01",
"feeRate": "0.0001"
}
]
}
],
"maxWithdraw": "",
"minDeposit": "",
"minWithdraw": ""
}
},
"contractConfig": {
"assets": [
{
"tokenId": "60017",
"token": "USDC",
"displayName": "USD Coin",
"decimals": 18,
"showStep": "0.01",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDC.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "60035",
"token": "BNB",
"displayName": "BNB",
"decimals": 18,
"showStep": "0.001",
"iconUrl": "https://static-pro.apex.exchange/icon/BNB.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "60036",
"token": "ETH",
"displayName": "Ethereum",
"decimals": 18,
"showStep": "0.0001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_ETH.svg",
"l2WithdrawFee": "0"
},
{
"tokenId": "60140",
"token": "USDT",
"displayName": "Tether USD Coin",
"decimals": 18,
"showStep": "0.0001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDT.svg",
"l2WithdrawFee": "0"
}
],
"tokens": [
{
"token": "BTC",
"stepSize": "0.001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BTC.svg"
},
{
"token": "EIGEN",
"stepSize": "0.001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/EIGEN.svg"
}
],
"global": {
"feeAccountId": "",
"feeAccountL2Key": "",
"contractAssetLpAccountId": "",
"contractAssetLpL2Key": "",
"operationAccountId": "",
"operationL2Key": "",
"experienceMoneyAccountId": "",
"experienceMoneyL2Key": "",
"agentAccountId": "",
"agentL2Key": "",
"finxFeeAccountId": "",
"finxFeeL2Key": "",
"negativeRateAccountId": "",
"negativeRateL2Key": "",
"brokerAccountId": "",
"brokerL2Key": ""
},
"perpetualContract": [
{
"baselinePositionValue": "50000.0000",
"crossId": 30002,
"crossSymbolId": 10,
"crossSymbolName": "BTCUSDT",
"digitMerge": "0.1,0.2,0.4,1,2",
"displayMaxLeverage": "100",
"displayMinLeverage": "1",
"enableDisplay": true,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "6",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.00250",
"incrementalMaintenanceMarginRate": "0.00100",
"incrementalPositionValue": "50000.0000",
"initialMarginRate": "0.01",
"maintenanceMarginRate": "0.005",
"maxOrderSize": "50",
"maxPositionSize": "100",
"minOrderSize": "0.0010",
"maxMarketPriceRange": "0.025",
"settleAssetId": "USDT",
"baseTokenId": "BTC",
"stepSize": "0.001",
"symbol": "BTC-USDT",
"symbolDisplayName": "BTCUSDT",
"tickSize": "0.1",
"maxMaintenanceMarginRate": "0.5000",
"maxPositionValue": "5000000.0000",
"tagIconUrl": "https://static-pro.apex.exchange/icon/LABLE_HOT.svg",
"tag": "HOT",
"riskTip": false,
"defaultInitialMarginRate": "0.05",
"klineStartTime": 0,
"maxMarketSizeBuffer": "0.98",
"enableFundingSettlement": true,
"indexPriceDecimals": 2,
"indexPriceVarRate": "0.0005",
"openPositionOiLimitRate": "0.05",
"fundingMaxRate": "0.000234",
"fundingMinRate": "-0.000234",
"fundingMaxValue": "",
"enableFundingMxValue": true,
"l2PairId": "50001",
"settleTimeStamp": 0,
"isPrelaunch": false,
"riskLimitConfig": {
"positionSteps": [
"0",
"50000",
"100000",
"200000",
"300000",
"500000",
"1000000",
"2000000",
"3000000",
"4000000",
"5000000"
],
"imrSteps": [
"0.01",
"0.01333",
"0.02",
"0.04",
"0.05",
"0.1",
"0.2",
"0.25",
"0.33333",
"0.5",
"1"
],
"mmrSteps": [
"0.005",
"0.0065",
"0.01",
"0.02",
"0.025",
"0.05",
"0.1",
"0.125",
"0.15",
"0.25",
"0.5"
]
}
}
],
"prelaunchContract": [
{
"baselinePositionValue": "50000.0000",
"crossId": 5,
"crossSymbolId": 10,
"crossSymbolName": "EIGENUSDT",
"digitMerge": "0.5,1,2,5,10",
"displayMaxLeverage": "30",
"displayMinLeverage": "1",
"enableDisplay": true,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "60",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.00250",
"incrementalMaintenanceMarginRate": "0.00100",
"incrementalPositionValue": "200000.0000",
"initialMarginRate": "0.03333",
"maintenanceMarginRate": "0.00700",
"maxOrderSize": "50",
"maxPositionSize": "100",
"minOrderSize": "0.0010",
"maxMarketPriceRange": "0.025",
"settleAssetId": "USDT",
"baseTokenId": "EIGEN",
"stepSize": "0.001",
"symbol": "EIGEN-USDT",
"symbolDisplayName": "EIGENUSDT",
"tickSize": "0.5",
"maxMaintenanceMarginRate": "0.03000",
"maxPositionValue": "10050000.0000",
"tagIconUrl": "",
"tag": "",
"riskTip": false,
"defaultLeverage": "",
"klineStartTime": 0,
"maxMarketSizeBuffer": "0.98",
"enableFundingSettlement": true,
"indexPriceDecimals": 2,
"indexPriceVarRate": "0.0005",
"openPositionOiLimitRate": "0.05",
"fundingMaxRate": "0.000234",
"fundingMinRate": "-0.000234",
"fundingMaxValue": "",
"enableFundingMxValue": true,
"l2PairId": "60001",
"settleTimeStamp": 1000000,
"isPrelaunch": true,
"riskLimitConfig": {
"positionSteps": null,
"imrSteps": null,
"mmrSteps": null
}
}
],
"maxMarketBalanceBuffer": "0.98"
}
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» spotConfig | object | true | none | Spot trade config |
»» assets | [object] | true | none | Spot trade assets |
»»» tokenId | string | true | none | ZK token ID |
»»» token | string | true | none | ZK token name |
»»» displayName | string | true | none | ZK token displayName |
»»» decimals | integer | true | none | Contract token decimal point accuracy |
»»» showStep | string | true | none | Token show decimals |
»»» iconUrl | string | true | none | Token icon url |
»»» l2WithdrawFee | string | true | none | Token withdraw fee |
»» global | object | true | none | |
»»» defaultRegisterTransferToken | string | true | none | Default transfer token, as 'USDT' |
»»» defaultRegisterTransferTokenId | string | true | none | Default transfer zk token ID, as '141' |
»»» defaultRegisterSubAccountId | string | true | none | Default transfer zk sub account ID, as '0' |
»»» defaultChangePubKeyZklinkChainId | string | true | none | Default transfer zk chain ID, as '9' |
»»» defaultChangePubKeyFeeTokenId | string | true | none | Default change pub key fee token ID, as '141' |
»»» defaultChangePubKeyFeeToken | string | true | none | Default change pub key fee token, as 'USDT' |
»»» defaultChangePubKeyFee | string | true | none | Default change pub key fee, as '0' |
»»» registerTransferLpAccountId | string | true | none | transfer Lp account ID |
»»» registerTransferLpSubAccount | string | true | none | transfer Lp sub account ID |
»»» registerTransferLpSubAccountL2Key | string | true | none | transfer Lp account l2Key |
»»» perpLpAccountId | string | true | none | Perp Lp account ID |
»»» perpLpSubAccount | string | true | none | Perp Lp sub account ID |
»»» perpLpSubAccountL2Key | string | true | none | Perp Lp account l2Key |
»»» contractAssetPoolAccountId | string | true | none | Contract asset pool account ID |
»»» contractAssetPoolZkAccountId | string | true | none | Contract asset pool zk account ID |
»»» contractAssetPoolSubAccount | string | true | none | Contract asset pool sub account ID |
»»» contractAssetPoolL2Key | string | true | none | Contract asset pool account l2Key |
»»» contractAssetPoolEthAddress | string | true | none | Contract asset pool eth address |
»» spot | [string] | true | none | Spot symbols |
»» multiChain | object | true | none | none |
»»» maxWithdraw | string | true | none | Maximum withdrawal amount |
»»» minWithdraw | string | true | none | Minimum withdrawal amount |
»»» minDeposit | string | true | none | Minimum deposit amount |
»»» currency | string | true | USDC | Currency |
»»» chains | [object] | true | none | none |
»»»» chain | string | true | none | Chain |
»»»» contractAddress | string | true | none | Contract address |
»»»» chainIconUrl | string | true | none | Chain icon url |
»»»» gasToken | string | true | none | Gas token name |
»»»» rpcUrl | string | true | none | Chain RPC service Url |
»»»» chainId | integer | true | none | Chain ID |
»»»» feeLess | boolean | true | none | Enable trading fees |
»»»» depositGasFeeLess | boolean | false | none | Enable deposit gas fees |
»»»» withdrawGasFeeLess | boolean | false | none | Enable withdraw gas fees |
»»»» minFee | string | true | none | Minimum deposit gas fee: If gas+value*fee_rate is lesser than min_fee, min_fee amount will be charged instead |
»»»» feeRate | string | true | none | Fee rate |
»»»» webTxUrl | string | true | none | Transaction tx URL |
»»»» tokens | [object] | true | none | none |
»»»»» token | string | true | none | Token name |
»»»»» tokenAddress | string | true | none | Token address |
»»»»» decimals | integer | true | none | Token decimal point accuracy |
»»»»» iconUrl | string | true | none | Token icon URL |
»»»»» pullOff | bool | true | none | Enable taking down of listing, default as FALSE |
»»»» gasLess | boolean | true | none | Enable gas free transaction |
»»»»» withdrawEnable | boolean | true | none | Enable withdraw |
»»»»» slippage | string | true | none | Swap slippage |
»»»»» isDefaultToken | boolean | true | none | If it is default token |
»»»»» displayToken | string | true | none | Display token name |
»»»»» needResetApproval | boolean | true | none | If it is need to reset approval |
»»»»» maxFee | string | true | none | Max deposit gas fee |
» contractConfig | object | true | none | Contract trade Config |
»» assets | [object] | true | none | Contract trade assets |
»»» tokenId | string | true | none | ZK token ID |
»»» token | string | true | none | ZK token name |
»»» displayName | string | true | none | ZK token displayName |
»»» decimals | integer | true | none | Contract token decimal point accuracy |
»»» showStep | string | true | none | Token show decimals |
»»» iconUrl | string | true | none | Token icon url |
»»» l2WithdrawFee | string | true | none | Token withdraw fee |
»» tokens | [object] | true | none | Contract trade tokens |
»»» token | string | true | none | Contract trade token name |
»»» stepSize | string | true | none | Minimum step size |
»»» iconUrl | string | true | none | Contract trade token icon URL |
»» global | object | true | none | Contract trade global config |
»»» feeAccountId | string | true | none | Contract fee account ID |
»»» feeAccountL2Key | string | true | none | Contract fee account L2Key |
»»» contractAssetLpAccountId | string | true | none | Contract asset Lp account ID |
»»» contractAssetLpL2Key | string | true | none | Contract asset Lp account l2Key |
»»» operationAccountId | string | true | none | Contract operation account ID |
»»» operationL2Key | string | true | none | Contract operation account l2Key |
»»» experienceMoneyAccountId | string | true | none | Contract experience money account ID |
»»» experienceMoneyL2Key | string | true | none | Contract experience money l2Key |
»»» agentAccountId | string | true | none | Contract agent account ID |
»»» agentL2Key | string | true | none | Contract agent account l2Key |
»»» finxFeeAccountId | string | true | none | Contract finx account ID |
»»» finxFeeL2Key | string | true | none | Contract finx account l2Key |
»»» negativeRateAccountId | string | true | none | Contract negative rate account ID |
»»» negativeRateL2Key | string | true | none | Contract negative rate account l2Key |
»»» brokerAccountId | string | true | none | Contract broker account ID |
»»» brokerL2Key | string | true | none | Contract broker account l2Key |
»» prelaunchContract | [object] | true | none | Prelaunch contract symbols |
»» perpetualContract | [object] | true | none | Perpetual contract symbols |
»»» baselinePositionValue | string | false | none | Baseline position vaue |
»»» crossId | integer | false | none | Quote API use id for symbol |
»»» crossSymbolId | integer | false | none | Quote API use symbolId for symbol |
»»» crossSymbolName | string | false | none | Quote API use symbolName for symbol |
»»» digitMerge | string | false | none | Depth digit merge |
»»» displayMaxLeverage | string | false | none | Maximum leverage |
»»» displayMinLeverage | string | false | none | Minimum leverage |
»»» enableDisplay | boolean | false | none | Enable display |
»»» enableOpenPosition | boolean | false | none | Enable open position |
»»» enableTrade | boolean | false | none | Enable trade |
»»» fundingImpactMarginNotional | string | false | none | Not required on frontend |
»»» fundingInterestRate | string | false | none | Funding rate ratio |
»»» incrementalInitialMarginRate | string | false | none | |
»»» incrementalMaintenanceMarginRate | string | false | none | |
»»» incrementalPositionValue | string | false | none | Incremental position value |
»»» initialMarginRate | string | false | none | Incremental initial margin rate |
»»» maintenanceMarginRate | string | false | none | Incremental maintenance margin rate |
»»» maxOrderSize | string | false | none | Maximum order size |
»»» maxPositionSize | string | false | none | Maximum position size |
»»» minOrderSize | string | false | none | Minimum order size |
»»» maxMarketPriceRange | string | false | none | Maximum market price rangee |
»»» settleAssetId | string | false | none | Settlement asset id |
»»» baseTokenId | string | false | none | |
»»» stepSize | string | false | none | Minimum step size |
»»» symbol | string | false | none | |
»»» symbolDisplayName | string | false | none | Symbol display name |
»»» tickSize | string | false | none | Minimum tick size |
»»» maxMaintenanceMarginRate | string | false | none | Maximum maintenance margin rate |
»»» maxPositionValue | string | false | none | Maximum position value |
»»» tagIconUrl | string | false | none | Tag icon URL |
»»» tag | string | false | none | Symbol Tag |
»»» riskTip | boolean | false | none | If it has risk tips |
»»» defaultLeverage | string | false | none | Default trade leverage |
»»» maxMarketSizeBuffer | string | false | none | Maximum market trade size buffer |
»»» enableFundingSettlement | boolean | false | none | Enable funding settlement |
»»» indexPriceDecimals | integer | false | none | Index price decimals |
»»» indexPriceVarRate | string | false | none | Index price var rate |
»»» openPositionOiLimitRate | string | false | none | Open position oi limit rate |
»»» fundingMaxRate | string | false | none | Funding maximum rate |
»»» fundingMinRate | string | false | none | Funding minimum rate |
»»» fundingMaxValue | string | false | none | Funding maximum value |
»»» enableFundingMxValue | boolean | false | none | Enable funding maximum value |
»»» l2PairId | string | false | none | zk l2 pair Id |
»»» settleTimeStamp | integer | false | none | Settle time |
»»» isPrelaunch | boolean | false | none | If it is prelaunch symbol |
»»» riskLimitConfig | object | false | none | Risk Limit config |
»»»» positionSteps | null | true | none | Position steps |
»»»» imrSteps | null | true | none | Initial margin rate steps |
»»»» mmrSteps | null | true | none | Maintenance margin rate steps |
GET Market Depth V3
GET /v3/depth
Retrieve all active orderbook for one symbol, inclue all bids and asks.
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Default at 100 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.depth_v3(symbol="BTCUSDT")
curl "https://omni.apex.exchange/api/v3/depth?symbol=BTCUSDT"
Successful Response Generation
success
{
"data": {
"a": [
[
"98743.4",
"0.071"
],
[
"98743.5",
"0.035"
]
],
"b": [
[
"98742.3",
"0.529"
],
[
"98742.2",
"0.178"
]
],
"s": "BTCUSDT",
"u": 1076833
},
"timeCost": 1056809
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» a | [array] | false | none | Sell |
»» b | [array] | false | none | Buy |
»» s | string | false | none | Symbol |
»» u | integer | false | none | none |
GET Newest Trading Data V3
GET /v3/trades
Retrieve trading data.
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Limit, maximum is 500 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.trades_v3(symbol="BTCUSDT")
curl "https://omni.apex.exchange/api/v3/trades?symbol=BTCUSDT"
Successful Response Generation
success
{
"data": [
{
"S": "BUY",
"v": "0.001",
"p": "29000",
"s": "BTCUSDT",
"T": 1647502440973
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» S | string | false | none | Side |
»» v | string | false | none | Size |
»» p | string | false | none | Price |
»» s | string | false | none | Symbol |
»» T | integer | false | none | Trade time |
GET Candlestick Chart Data V3
GET /v3/klines
Retrieves all candlestick chart data.
Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W"
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
interval | query | string | false | Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W" |
start | query | string | false | Start time, second timestamp |
end | query | string | false | End time, second timestamp |
limit | query | string | false | Limit, maximum is 200 |
symbol | query | string | false | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.klines(symbol="BTCUSDT",interval=5)
curl "https://omni.apex.exchange/api/v3/klines?symbol=BTCUSDT&interval=5"
Successful Response Generation
success
{
"data": [
{
"start": 1647511440000,
"symbol": "BTCUSDC",
"interval": "1",
"low": "40000",
"high": "45000",
"open": "45000",
"close": "40000",
"volume": "1.002",
"turnover": "3"
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» klines | [object] | true | none | none |
»» start | integer | false | none | Start time |
»» symbol | string | true | none | Currency |
»» interval | string | true | none | Chart interval |
»» low | string | false | none | Low price |
»» high | string | false | none | High price |
»» open | string | false | none | Open price |
»» close | string | false | none | Close price |
»» volume | string | false | none | Trading volume |
»» turnover | string | false | none | Turnover |
GET Ticker Data V3
GET /v3/ticker
Get the latest data on symbol tickers.
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.ticker_v3(symbol="BTCUSDT")
curl "https://omni.apex.exchange/api/v3/ticker?symbol=BTCUSDT"
Successful Response Generation
success
{
"data": [
{
"symbol": "BTCUSDT",
"price24hPcnt": "0.450141",
"lastPrice": "43511.50",
"highPrice24h": "43513.50",
"lowPrice24h": "29996.00",
"markPrice": "43513.50",
"indexPrice": "40828.94",
"openInterest": "2036854775808",
"turnover24h": "5626085.23749999",
"volume24h": "169.317",
"fundingRate": "0",
"predictedFundingRate": "0",
"nextFundingTime": "10:00:00",
"tradeCount": 100
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» tickers | [object] | true | none | none |
»» symbol | string | false | none | Symbol |
»» price24hPcnt | string | false | none | 24H change (%) |
»» lastPrice | string | false | none | Last price |
»» highPrice24h | string | false | none | 24H highest price |
»» lowPrice24h | string | false | none | 24H lowest price |
»» markPrice | string | false | none | mark price |
»» indexPrice | string | false | none | Index price |
»» openInterest | string | false | none | Open interest |
»» turnover24h | string | false | none | 24H turnover |
»» volume24h | string | false | none | 24H trading volume |
»» fundingRate | string | false | none | Funding rate |
»» predictedFundingRate | string | false | none | Predicted funding rate |
»» nextFundingTime | string | false | none | Next funding rate |
»» tradeCount | string | false | none | 24H trade count |
GET Funding Rate History V3
GET /v3/history-funding
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
Limit | query | string | false | Default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://omni.apex.exchange")
client.history_funding_v3(symbol="BTC-USDT")
curl "https://omni.apex.exchange/api/v3/history-funding?symbol=BTC-USDT"
Successful Response Generation
success
{
"historyFunds": [
{
"symbol": "BTC-USDT",
"rate": "0.0000125000",
"price": "31297.5000008009374142",
"fundingTime": 12315555,
"fundingTimestamp": 12315555
}
],
"totalSize": 11
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» historicalFunds | [object] | true | none | none |
»» symbol | string | false | none | none |
»» rate | string | false | none | Funding rate |
»» price | string | false | none | Price |
»» fundingTime | integer | false | none | Time |
»» fundingTimestamp | integer | false | none | Funding timestamp |
» totalSize | integer | true | none | Size |
PublicApi V2 for Pro
v2.0.0
GET System Time V2
GET /v2/time
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.server_time()
curl "https://pro.apex.exchange/api/v2/time"
Successful Response
{
"data": {
"time": 1648626529
}
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» time | integer | true | none | none |
GET All Config Data V2
USDC and USDT config
GET /v2/symbols
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.configs_v2()
curl "https://pro.apex.exchange/api/v2/symbols"
Successful Response
{
"data": {
"usdcConfig": {
"currency": [
{
"id": "USDC",
"starkExAssetId": "0x02893294412a4c8f915f75892b395ebbf6859ec246ec365c3b1f56f47c3a0a5d",
"starkExResolution": "1000000",
"stepSize": "0.000001",
"showStep": "0.0001",
"iconUrl": "https://static-pro.apex.exchange/icon/USDC.svg"
},
{
"id": "BTC",
"starkExAssetId": "",
"starkExResolution": "",
"stepSize": "0.001",
"showStep": "",
"iconUrl": "https://static-pro.apex.exchange/icon/BTC.svg"
},
{
"id": "ETH",
"starkExAssetId": "",
"starkExResolution": "",
"stepSize": "0.01",
"showStep": "",
"iconUrl": "https://static-pro.apex.exchange/icon/ETH.svg"
}
],
"global": {
"feeAccountId": "10240000",
"feeAccountL2Key": "0x02382ceace17a59ec674b5ca7109eabc66e4107c7f473492cf192c60f4e17600",
"starkExCollateralCurrencyId": "USDC",
"starkExFundingValidityPeriod": 86400,
"starkExMaxFundingRate": "2237",
"starkExOrdersTreeHeight": 64,
"starkExPositionsTreeHeight": 0,
"starkExPriceValidityPeriod": 86400,
"starkExContractAddress": "0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb",
"registerEnvId": 1,
"crossChainAccountId": "351667704786059600",
"crossChainL2Key": "0x0270884a62b952837f1ad48bf28559c86060990af3e63019da59dad9cdd76ed0",
"fastWithdrawAccountId": "351667704786059600",
"fastWithdrawFactRegisterAddress": "0xBE9a129909EbCb954bC065536D2bfAfBd170d27A",
"fastWithdrawL2Key": "0x0270884a62b952837f1ad48bf28559c86060990af3e63019da59dad9cdd76ed0",
"fastWithdrawMaxAmount": "100000",
"bybitWithdrawAccountId": "386890783493456500",
"bybitWithdrawL2Key": "0x03a30ed5c0184757effbbc1df3921da538e514e289f342751333340d90962cf4",
"experienceMonenyAccountId": "431772213377499661",
"experienceMonenyL2Key": "0x0577cf53e44275b3dfdfdfde1639752e35fff0cc6c2919b9389f087e87b16a8d",
"experienceMoneyAccountId": "431772213377499661",
"experienceMoneyL2Key": "0x0577cf53e44275b3dfdfdfde1639752e35fff0cc6c2919b9389f087e87b16a8d"
},
"perpetualContract": [
{
"baselinePositionValue": "50000.0000",
"crossId": 30000,
"crossSymbolId": 10,
"crossSymbolName": "BTCUSDC",
"digitMerge": "0.5,1,2,5,10",
"displayMaxLeverage": "30",
"displayMinLeverage": "1",
"enableDisplay": true,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "10",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.00250",
"incrementalMaintenanceMarginRate": "0.00100",
"incrementalPositionValue": "200000.0000",
"initialMarginRate": "0.03333",
"maintenanceMarginRate": "0.00700",
"maxOrderSize": "100",
"maxPositionSize": "130",
"minOrderSize": "0.0010",
"maxMarketPriceRange": "0.025",
"settleCurrencyId": "USDC",
"starkExOraclePriceQuorum": "1",
"starkExResolution": "10000000000",
"starkExRiskFactor": "128849019",
"starkExSyntheticAssetId": "0x4254432d3130000000000000000000",
"stepSize": "0.001",
"symbol": "BTC-USDC",
"symbolDisplayName": "BTCUSDC",
"symbolDisplayName2": "BTCUSD",
"tickSize": "0.5",
"underlyingCurrencyId": "BTC",
"maxMaintenanceMarginRate": "0.03000",
"maxPositionValue": "10050000.0000",
"tagIconUrl": "",
"tag": "",
"riskTip": false,
"defaultLeverage": "",
"klineStartTime": 0
}
],
"multiChain": {
"chains": [
{
"chain": "Ethereum",
"chainId": 1,
"chainIconUrl": "https://static-pro.apex.exchange/chains/chain_logos/Ethereum.svg",
"contractAddress": "0xe95b3Dc78c0881dEa17A69BaFC6cFeB8d891e9DE",
"depositGasFeeLess": false,
"stopDeposit": false,
"feeLess": false,
"feeRate": "0.0001",
"gasLess": false,
"gasToken": "ETH",
"minFee": "1",
"dynamicFee": true,
"rpcUrl": "https://eth-mainnet.alchemyapi.io/v2/sNRPO_qXIfkVdfpcj33LId04rmHugka2",
"webRpcUrl": "https://eth-mainnet.alchemyapi.io/v2/sNRPO_qXIfkVdfpcj33LId04rmHugka2",
"webTxUrl": "https://etherscan.io/tx/",
"blockTime": "15",
"txConfirm": 15,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/icon/USDC.svg",
"token": "USDC",
"tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": true,
"displayToken": "USDC"
},
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDT.svg",
"token": "USDT",
"tokenAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"pullOff": false,
"withdrawEnable": false,
"slippage": "1",
"isDefaultToken": false,
"displayToken": "USDT"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_ETH.svg",
"token": "ETH",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "ETH"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_DAI.svg",
"token": "DAI",
"tokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "DAI"
}
],
"withdrawGasFeeLess": false,
"isGray": false
},
{
"chain": "BNB Chain(BSC)",
"chainId": 56,
"chainIconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BNB.svg",
"contractAddress": "0xe29304Af265641a49F55294F7E5BA5010ebA4497",
"depositGasFeeLess": false,
"stopDeposit": false,
"feeLess": false,
"feeRate": "0.0001",
"gasLess": true,
"gasToken": "BNB",
"minFee": "1",
"dynamicFee": false,
"rpcUrl": "https://bsc-dataseed3.binance.org",
"webRpcUrl": "https://bsc-dataseed3.binance.org",
"webTxUrl": "https://bscscan.com/tx/",
"blockTime": "3",
"txConfirm": 15,
"tokens": [
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_USDC.svg",
"token": "USDC",
"tokenAddress": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": true,
"displayToken": "USDC"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_USDT.svg",
"token": "USDT",
"tokenAddress": "0x55d398326f99059fF775485246999027B3197955",
"pullOff": false,
"withdrawEnable": false,
"slippage": "1",
"isDefaultToken": false,
"displayToken": "USDT"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BNB.svg",
"token": "BNB",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "BNB"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BUSD.svg",
"token": "BUSD",
"tokenAddress": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "BUSD"
}
],
"withdrawGasFeeLess": false,
"isGray": false
}
],
"currency": "USDC",
"maxWithdraw": "100000",
"minDeposit": "10",
"minWithdraw": "8"
},
"depositFromBybit": false
},
"usdtConfig": {
"currency": [
{
"id": "USDT",
"starkExAssetId": "0x02ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5",
"starkExResolution": "1000000",
"stepSize": "0.000001",
"showStep": "0.0001",
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDT.svg"
},
{
"id": "BTC",
"starkExAssetId": "",
"starkExResolution": "",
"stepSize": "0.001",
"showStep": "",
"iconUrl": "https://static-pro.apex.exchange/icon/BTC.svg"
},
{
"id": "ETH",
"starkExAssetId": "",
"starkExResolution": "",
"stepSize": "0.01",
"showStep": "",
"iconUrl": "https://static-pro.apex.exchange/icon/ETH.svg"
}
],
"global": {
"feeAccountId": "10240000",
"feeAccountL2Key": "0x02382ceace17a59ec674b5ca7109eabc66e4107c7f473492cf192c60f4e17600",
"starkExCollateralCurrencyId": "USDT",
"starkExFundingValidityPeriod": 86400,
"starkExMaxFundingRate": "2237",
"starkExOrdersTreeHeight": 64,
"starkExPositionsTreeHeight": 0,
"starkExPriceValidityPeriod": 86400,
"starkExContractAddress": "0xe53A6eD882Eb3f90cCe0390DDB04c876C5482E6b",
"registerEnvId": 1,
"crossChainAccountId": "503102754309276028",
"crossChainL2Key": "0x05dc82afffe0311f532b3ee86fbf5491fc4be1a3e7a204a37e69416999f00dfc",
"fastWithdrawAccountId": "503102754309276028",
"fastWithdrawFactRegisterAddress": "0xBE9a129909EbCb954bC065536D2bfAfBd170d27A",
"fastWithdrawL2Key": "0x05dc82afffe0311f532b3ee86fbf5491fc4be1a3e7a204a37e69416999f00dfc",
"fastWithdrawMaxAmount": "100000",
"bybitWithdrawAccountId": "",
"bybitWithdrawL2Key": "",
"experienceMonenyAccountId": "503102758994313516",
"experienceMonenyL2Key": "0x01402668ab56fef0c44ec9d0569f2706f08caa4bc29ee2eb2f9376d86bc5adac",
"experienceMoneyAccountId": "503102758994313516",
"experienceMoneyL2Key": "0x01402668ab56fef0c44ec9d0569f2706f08caa4bc29ee2eb2f9376d86bc5adac"
},
"perpetualContract": [
{
"baselinePositionValue": "50000.0000",
"crossId": 30001,
"crossSymbolId": 34,
"crossSymbolName": "BTCUSDT",
"digitMerge": "0.1,0.2,0.4,1,2",
"displayMaxLeverage": "50",
"displayMinLeverage": "1",
"enableDisplay": false,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "10",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.0075",
"incrementalMaintenanceMarginRate": "0.005",
"incrementalPositionValue": "150000.0000",
"initialMarginRate": "0.02",
"maintenanceMarginRate": "0.01",
"maxOrderSize": "100",
"maxPositionSize": "130",
"minOrderSize": "0.0010",
"maxMarketPriceRange": "0.025",
"settleCurrencyId": "USDT",
"starkExOraclePriceQuorum": "3",
"starkExResolution": "10000000000",
"starkExRiskFactor": "1417339208",
"starkExSyntheticAssetId": "0x4254432d3130000000000000000000",
"stepSize": "0.001",
"symbol": "BTC-USDT",
"symbolDisplayName": "BTCUSDT",
"symbolDisplayName2": "BTCUSDT",
"tickSize": "0.1",
"underlyingCurrencyId": "BTC",
"maxMaintenanceMarginRate": "0.3300",
"maxPositionValue": "9650000",
"tagIconUrl": "https://static-pro.apex.exchange/icon/LABLE_HOT.svg",
"tag": "HOT",
"riskTip": false,
"defaultLeverage": "",
"klineStartTime": 0
},
{
"baselinePositionValue": "50000.0000",
"crossId": 30001,
"crossSymbolId": 35,
"crossSymbolName": "ETHUSDT",
"digitMerge": "0.01,0.02,0.04,0.1,0.2",
"displayMaxLeverage": "50",
"displayMinLeverage": "1",
"enableDisplay": false,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "100",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.0075",
"incrementalMaintenanceMarginRate": "0.005",
"incrementalPositionValue": "150000.0000",
"initialMarginRate": "0.02",
"maintenanceMarginRate": "0.01",
"maxOrderSize": "800",
"maxPositionSize": "1700",
"minOrderSize": "0.010",
"maxMarketPriceRange": "0.045",
"settleCurrencyId": "USDT",
"starkExOraclePriceQuorum": "3",
"starkExResolution": "100000000",
"starkExRiskFactor": "1417339208",
"starkExSyntheticAssetId": "0x4554482d3800000000000000000000",
"stepSize": "0.01",
"symbol": "ETH-USDT",
"symbolDisplayName": "ETHUSDT",
"symbolDisplayName2": "ETHUSDT",
"tickSize": "0.01",
"underlyingCurrencyId": "ETH",
"maxMaintenanceMarginRate": "0.3300",
"maxPositionValue": "9650000",
"tagIconUrl": "https://static-pro.apex.exchange/icon/LABLE_HOT.svg",
"tag": "HOT",
"riskTip": false,
"defaultLeverage": "",
"klineStartTime": 0
}
],
"multiChain": {
"chains": [
{
"chain": "Ethereum",
"chainId": 1,
"chainIconUrl": "https://static-pro.apex.exchange/chains/chain_logos/Ethereum.svg",
"contractAddress": "0x379c15156B527D6E693bED60d1FBb44CE46046b8",
"depositGasFeeLess": false,
"stopDeposit": false,
"feeLess": false,
"feeRate": "0.0001",
"gasLess": false,
"gasToken": "ETH",
"minFee": "1",
"dynamicFee": true,
"rpcUrl": "https://eth-mainnet.alchemyapi.io/v2/sNRPO_qXIfkVdfpcj33LId04rmHugka2",
"webRpcUrl": "https://eth-mainnet.alchemyapi.io/v2/sNRPO_qXIfkVdfpcj33LId04rmHugka2",
"webTxUrl": "https://etherscan.io/tx/",
"blockTime": "15",
"txConfirm": 15,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_USDT.svg",
"token": "USDT",
"tokenAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": true,
"displayToken": "USDT"
},
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/icon/USDC.svg",
"token": "USDC",
"tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_ETH.svg",
"token": "ETH",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "ETH"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Ethereum/Ethereum_DAI.svg",
"token": "DAI",
"tokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "DAI"
}
],
"withdrawGasFeeLess": false,
"isGray": false
},
{
"chain": "BNB Chain(BSC)",
"chainId": 56,
"chainIconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BNB.svg",
"contractAddress": "0x7B71Ff8451706B9e863879a84bf967Ff4Dc7A9bF",
"depositGasFeeLess": false,
"stopDeposit": false,
"feeLess": false,
"feeRate": "0.0001",
"gasLess": true,
"gasToken": "BNB",
"minFee": "1",
"dynamicFee": false,
"rpcUrl": "https://bsc-dataseed3.binance.org",
"webRpcUrl": "https://bsc-dataseed3.binance.org",
"webTxUrl": "https://bscscan.com/tx/",
"blockTime": "3",
"txConfirm": 15,
"tokens": [
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_USDT.svg",
"token": "USDT",
"tokenAddress": "0x55d398326f99059fF775485246999027B3197955",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": true,
"displayToken": "USDT"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_USDC.svg",
"token": "USDC",
"tokenAddress": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BNB.svg",
"token": "BNB",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "BNB"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/BSC/BNB_BUSD.svg",
"token": "BUSD",
"tokenAddress": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "BUSD"
}
],
"withdrawGasFeeLess": false,
"isGray": false
},
{
"chain": "Arbitrum One",
"chainId": 42161,
"chainIconUrl": "https://static-pro.apex.exchange/chains/chain_logos/Arbitrum.svg",
"contractAddress": "0x192DB9Fe1C0b9D7c6B4045e4F029b21792c68165",
"depositGasFeeLess": false,
"stopDeposit": false,
"feeLess": true,
"feeRate": "0.0001",
"gasLess": true,
"gasToken": "ETH",
"minFee": "2",
"dynamicFee": false,
"rpcUrl": "https://arb1.arbitrum.io/rpc",
"webRpcUrl": "https://arb1.arbitrum.io/rpc",
"webTxUrl": "https://arbiscan.io/tx/",
"blockTime": "1",
"txConfirm": 12,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Arbitrum/Arbitrum_USDT.svg",
"token": "USDT",
"tokenAddress": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
"pullOff": false,
"withdrawEnable": true,
"slippage": "",
"isDefaultToken": true,
"displayToken": "USDT"
},
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Arbitrum/Arbitrum_USDC.svg",
"token": "USDC",
"tokenAddress": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC.e"
},
{
"decimals": 6,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Arbitrum/Arbitrum_USDC.svg",
"token": "USDC.o",
"tokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "USDC"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Arbitrum/Arbitrum_ETH.svg",
"token": "ETH",
"tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "ETH"
},
{
"decimals": 18,
"iconUrl": "https://static-pro.apex.exchange/chains/chain_tokens/Arbitrum/Arbitrum_WETH.svg",
"token": "WETH",
"tokenAddress": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"pullOff": false,
"withdrawEnable": false,
"slippage": "",
"isDefaultToken": false,
"displayToken": "WETH"
}
],
"withdrawGasFeeLess": false,
"isGray": false
}
],
"currency": "USDT",
"maxWithdraw": "10000",
"minDeposit": "10",
"minWithdraw": "8"
},
}
},
"timeCost": 1416146
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» global | object | true | none | none |
»» feeAccountId | string | true | none | Trading fee system account id |
»» feeAccountL2Key | string | true | none | Trading fee system l2Key |
»» starkExCollateralCurrencyId | string | true | none | Starkex supported collateral asset id |
»» starkExMaxFundingRate | string | true | none | Maximum funding rate |
»» starkExOrdersTreeHeight | integer | true | none | Order merkle tree height |
»» starkExPositionsTreeHeight | integer | true | none | Account merkle tree height |
»» starkExFundingValidityPeriod | integer | true | none | L2 funding validity period |
»» starkExPriceValidityPeriod | integer | true | none | L2 price validity period |
»» fastWithdrawAccountId | string | true | none | Fast withdraw system account id |
»» fastWithdrawL2Key | string | true | none | Fast withdraw system l2Key |
»» fastWithdrawMaxAmount | string | true | none | Maximum Fast withdraw amount |
»» fastWithdrawFactRegisterAddress | string | true | none | L1 Fact registered contract address |
»» crossChainAccountId | string | true | none | Cross chain withdraw account id |
»» crossChainL2Key | string | true | none | Cross chain withdraw system l2Key |
»» registerChainId | integer | true | 5 | The 'envId' is initially filled during onboarding, serving to differentiate environments, with 1 indicating the production environment and 5 representing testing environments. |
» currency | [object] | true | none | none |
»» id | string | true | none | Token name |
»» stepSize | string | true | none | Minimum step size |
»» starkExAssetId | string | false | none | StarkEx asset id |
»» starkExResolution | string | false | none | StarkEx resolution |
» multiChain | object | true | none | none |
»» maxWithdraw | string | true | none | Maximum withdrawal amount |
»» minWithdraw | string | true | none | Minimum withdrawal amount |
»» minDeposit | string | true | none | Minimum deposit amount |
»» currency | string | true | USDC | Currency |
»» chains | [object] | true | none | none |
»»» chain | string | true | none | Chain |
»»» contractAddress | string | true | none | Contract address |
»»» chainIconUrl | string | true | none | Chain icon url |
»»» gasToken | string | true | none | Gas token name |
»»» rpcUrl | string | true | none | Chain RPC service Url |
»»» chainId | integer | true | none | Chain ID |
»»» feeLess | boolean | true | none | Enable trading fees |
»»» depositGasFeeLess | boolean | false | none | Enable deposit gas fees |
»»» withdrawGasFeeLess | boolean | false | none | Enable withdraw gas fees |
»»» minFee | string | true | none | Minimum deposit gas fee: If gas+value*fee_rate is lesser than min_fee, min_fee amount will be charged instead |
»»» feeRate | string | true | none | Fee rate |
»»» webTxUrl | string | true | none | Transaction tx URL |
»»» tokens | [object] | true | none | none |
»»»» token | string | true | none | Token name |
»»»» tokenAddress | string | true | none | Token address |
»»»» decimals | integer | true | none | Token decimal point accuracy |
»»»» iconUrl | string | true | none | Token icon URL |
»»»» pullOff | bool | true | none | Enable taking down of listing, default as FALSE |
»»» gasLess | boolean | true | none | Enable gas free transaction |
» perpetualContract | [object] | true | none | none |
»» symbol | string | true | none | Symbol id |
»» symbolDisplayName | string | true | none | Symbol display name |
»» settleCurrencyId | string | true | none | Settlement asset id |
»» underlyingCurrencyId | string | true | none | Underlying asset id |
»» tickSize | string | true | none | Minimum tick size |
»» stepSize | string | true | none | Minimum step size |
»» minOrderSize | string | true | none | Minimum order size |
»» maxOrderSize | string | true | none | Maximum order size |
»» maxPositionSize | string | true | none | Maximum position size |
»» maxMarketPriceRange | string | true | none | Maximum market price rangee |
»» initialMarginRate | string | true | none | Initial margin rate |
»» maintenanceMarginRate | string | true | none | Maintenance margin rate |
»» baselinePositionValue | string | true | none | Baseline position vaue |
»» incrementalPositionValue | string | true | none | Incremental position value |
»» incrementalInitialMarginRate | string | true | none | Incremental initial margin rate |
»» incrementalMaintenanceMarginRate | string | true | none | Incremental maintenance margin rate |
»» enableTrade | boolean | true | none | Enable trade |
»» enableDisplay | boolean | true | none | Enable display |
»» enableOpenPosition | boolean | true | none | Enable open position |
»» digitMerge | string | true | none | Depth digit merge |
»» crossId | integer | true | none | Quote API use id for symbol |
»» crossSymbolId | integer | true | none | Quote API use symbolId for symbol |
»» crossSymbolName | string | true | none | Quote API use symbolName for symbol |
»» fundingInterestRate | string | true | none | Funding rate ratio |
»» fundingImpactMarginNotional | string | true | none | Not required on frontend |
»» displayMaxLeverage | string | true | none | Maximum leverage |
»» displayMinLeverage | string | true | none | Minimum leverage |
»» starkExSyntheticAssetId | string | true | none | Currency synthetic asset id |
»» starkExResolution | string | true | none | Currency resolution |
»» starkExRiskFactor | string | true | none | none |
»» starkExOraclePriceQuorum | string | true | none | none |
GET Market Depth V2
GET /v2/depth
Retrieve all active orderbook for one symbol, inclue all bids and asks.
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Default at 100 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.depth(symbol="BTCUSDC")
curl "https://pro.apex.exchange/api/v2/depth?symbol=BTCUSDC"
Successful Response Generation
success
{
"data": {
"a": [
[
"98743.4",
"0.071"
],
[
"98743.5",
"0.035"
]
],
"b": [
[
"98742.3",
"0.529"
],
[
"98742.2",
"0.178"
]
],
"s": "BTCUSDT",
"u": 1076833
},
"timeCost": 1056809
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» a | [array] | false | none | Sell |
»» b | [array] | false | none | Buy |
»» s | string | false | none | Symbol |
»» u | integer | false | none | none |
GET Newest Trading Data V2
GET /v2/trades
Retrieve trading data.
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Limit, maximum is 500 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.trades(symbol="BTCUSDT")
curl "https://pro.apex.exchange/api/v2/trades?symbol=BTCUSDT"
Successful Response Generation
success
{
"data": [
{
"S": "BUY",
"v": "0.001",
"p": "29000",
"s": "BTCUSDT",
"T": 1647502440973
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» S | string | false | none | Side |
»» v | string | false | none | Size |
»» p | string | false | none | Price |
»» s | string | false | none | Symbol |
»» T | integer | false | none | Trade time |
GET Candlestick Chart Data V2
GET /v2/klines
Retrieves all candlestick chart data.
Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W"
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
interval | query | string | false | Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W" |
start | query | string | false | Start time, second timestamp |
end | query | string | false | End time, second timestamp |
limit | query | string | false | Limit,, maximum is 1500 |
symbol | query | string | false | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.klines(symbol="BTCUSDC",interval=5)
curl "https://pro.apex.exchange/api/v2/klines?symbol=BTCUSDC?interval=5"
Successful Response Generation
success
{
"data": [
{
"start": 1647511440000,
"symbol": "BTCUSDC",
"interval": "1",
"low": "40000",
"high": "45000",
"open": "45000",
"close": "40000",
"volume": "1.002",
"turnover": "3"
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» klines | [object] | true | none | none |
»» start | integer | false | none | Start time |
»» symbol | string | true | none | Currency |
»» interval | string | true | none | Chart interval |
»» low | string | false | none | Low price |
»» high | string | false | none | High price |
»» open | string | false | none | Open price |
»» close | string | false | none | Close price |
»» volume | string | false | none | Trading volume |
»» turnover | string | false | none | Turnover |
GET Ticker Data V2
GET /v2/ticker
Get the latest data on symbol tickers.
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.ticker(symbol="BTCUSDC")
curl "https://pro.apex.exchange/api/v2/ticker?symbol=BTCUSDC"
Successful Response Generation
success
{
"data": [
{
"symbol": "BTCUSDC",
"price24hPcnt": "0.450141",
"lastPrice": "43511.50",
"highPrice24h": "43513.50",
"lowPrice24h": "29996.00",
"oraclePrice": "43513.50",
"indexPrice": "40828.94",
"openInterest": "2036854775808",
"turnover24h": "5626085.23749999",
"volume24h": "169.317",
"fundingRate": "0",
"predictedFundingRate": "0",
"nextFundingTime": "10:00:00",
"tradeCount": 100
}
]
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» tickers | [object] | true | none | none |
»» symbol | string | false | none | Symbol |
»» price24hPcnt | string | false | none | 24H change (%) |
»» lastPrice | string | false | none | Last price |
»» highPrice24h | string | false | none | 24H highest price |
»» lowPrice24h | string | false | none | 24H lowest price |
»» oraclePrice | string | false | none | Oracle price |
»» indexPrice | string | false | none | Index price |
»» openInterest | string | false | none | Open interest |
»» turnover24h | string | false | none | 24H turnover |
»» volume24h | string | false | none | 24H trading volume |
»» fundingRate | string | false | none | Funding rate |
»» predictedFundingRate | string | false | none | Predicted funding rate |
»» nextFundingTime | string | false | none | Next funding rate |
»» tradeCount | string | false | none | 24H trade count |
GET Funding Rate History V2
GET /v2/history-funding
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
Limit | query | string | false | Default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.history_funding_v2(symbol="BTC-USDT")
curl "https://pro.apex.exchange/api/v2/history-funding?symbol=BTC-USDT"
Successful Response Generation
success
{
"historyFunds": [
{
"symbol": "BTC-USDT",
"rate": "0.0000125000",
"price": "31297.5000008009374142",
"fundingTime": 12315555,
"fundingTimestamp": 12315555
}
],
"totalSize": 11
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» historicalFunds | [object] | true | none | none |
»» symbol | string | false | none | none |
»» rate | string | false | none | Funding rate |
»» price | string | false | none | Price |
»» fundingTime | integer | false | none | Time |
»» fundingTimestamp | integer | false | none | Funding timestamp |
» totalSize | integer | true | none | Size |
GET Check If User Exists V2
GET /v2/check-user-exist
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
ethAddress | query | string | FALSE | 0x111111 |
Successful Response Generation
success
{
"data": false
}
Response Status Code
Status Code | Value | Comment | Data Model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | boolean | true | none | none |
PublicApi
v1.0.0
GET System Time
GET /v1/time
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.server_time()
curl "https://pro.apex.exchange/api/v1/time"
Successful Response
{
"data": {
"time": 1648626529
}
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» time | integer | true | none | none |
GET All Config Data
GET /v1/symbols
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.configs()
curl "https://pro.apex.exchange/api/v1/symbols"
Successful Response
{
"data": {
"currency": [
{
"id": "USDC",
"starkExAssetId": "0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f",
"starkExResolution": "1000000",
"stepSize": "0.000001",
"showStep": "0.0001",
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDC.svg"
},
{
"id": "BTC",
"starkExAssetId": "",
"starkExResolution": "",
"stepSize": "0.0001",
"showStep": "",
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/BTC.svg"
},
],
"global": {
"feeAccountId": "10240000",
"feeAccountL2Key": "0x05d08ae9202f9e19ffa0211676536ba3e4c5f1e433a4c01d60fceae00a095100",
"starkExCollateralCurrencyId": "USDC",
"starkExFundingValidityPeriod": 604800,
"starkExMaxFundingRate": "1120",
"starkExOrdersTreeHeight": 64,
"starkExPositionsTreeHeight": 0,
"starkExPriceValidityPeriod": 31536000,
"starkExContractAddress": "0x7478037C3a1F44f0Add4Ae06158fefD10d44Bb63",
"registerEnvId": 5,
"crossChainAccountId": "349914288015540743",
"crossChainL2Key": "0x0486880561f5ddb979c92dcd4eefdedeb050bc5aad3522b00b211855f3c2ca87",
"fastWithdrawAccountId": "349914288015540743",
"fastWithdrawFactRegisterAddress": "0x5070F5d37419AEAd10Df2252421e457336561269",
"fastWithdrawL2Key": "0x0486880561f5ddb979c92dcd4eefdedeb050bc5aad3522b00b211855f3c2ca87",
"fastWithdrawMaxAmount": "100000"
},
"perpetualContract": [
{
"baselinePositionValue": "1000000.0000",
"crossId": 30000,
"crossSymbolId": 10,
"crossSymbolName": "BTCUSDC",
"digitMerge": "0.5,1,2,5",
"displayMaxLeverage": "20",
"displayMinLeverage": "1",
"enableDisplay": true,
"enableOpenPosition": true,
"enableTrade": true,
"fundingImpactMarginNotional": "10",
"fundingInterestRate": "0.0003",
"incrementalInitialMarginRate": "0.0075",
"incrementalMaintenanceMarginRate": "0.0000",
"incrementalPositionValue": "1000000.0000",
"initialMarginRate": "0.0500",
"maintenanceMarginRate": "0.0300",
"maxOrderSize": "100.0000",
"maxPositionSize": "500.0000",
"minOrderSize": "0.0010",
"maxMarketPriceRange": "0.03",
"settleCurrencyId": "USDC",
"starkExOraclePriceQuorum": "1",
"starkExResolution": "10000000000",
"starkExRiskFactor": "128849019",
"starkExSyntheticAssetId": "0x4254432d3130000000000000000000",
"stepSize": "0.001",
"symbol": "BTC-USDC",
"symbolDisplayName": "BTCUSDC",
"tickSize": "0.5",
"underlyingCurrencyId": "BTC",
"maxMaintenanceMarginRate":"0.03000",
"maxPositionValue":"10150000.0000"
}
],
"multiChain": {
"chains": [
{
"chain": "Goerli - Testnet",
"chainId": 5,
"chainIconUrl": "https://l2dex-image-static.dev.apexplus.exchange/chains/chain_logos/Goerli.svg",
"contractAddress": "0x4c0023E8c570D4c3Bd357e7869027cF0106Ed3B7",
"depositGasFeeLess": false,
"feeLess": false,
"feeRate": "0.001",
"gasLess": false,
"gasToken": "ETH",
"minFee": "10",
"rpcUrl": "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
"webTxUrl": "https://goerli.etherscan.io/tx/",
"txConfirm": 30,
"tokens": [
{
"decimals": 6,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/USDC.svg",
"token": "USDC",
"tokenAddress": "0xd44BB808bfE43095dBb94c83077766382D63952a",
"pullOff": false
},
{
"decimals": 18,
"iconUrl": "https://l2dex-image-static.dev.apexplus.exchange/icon/ETH.svg",
"token": "ETH",
"tokenAddress": "",
"pullOff": true
}
],
"withdrawGasFeeLess": false
}
],
"currency": "USDC",
"maxWithdraw": "100000",
"minDeposit": "10",
"minWithdraw": "10"
}
},
"timeCost": 266616
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» global | object | true | none | none |
»» feeAccountId | string | true | none | Trading fee system account id |
»» feeAccountL2Key | string | true | none | Trading fee system l2Key |
»» starkExCollateralCurrencyId | string | true | none | Starkex supported collateral asset id |
»» starkExMaxFundingRate | string | true | none | Maximum funding rate |
»» starkExOrdersTreeHeight | integer | true | none | Order merkle tree height |
»» starkExPositionsTreeHeight | integer | true | none | Account merkle tree height |
»» starkExFundingValidityPeriod | integer | true | none | L2 funding validity period |
»» starkExPriceValidityPeriod | integer | true | none | L2 price validity period |
»» fastWithdrawAccountId | string | true | none | Fast withdraw system account id |
»» fastWithdrawL2Key | string | true | none | Fast withdraw system l2Key |
»» fastWithdrawMaxAmount | string | true | none | Maximum Fast withdraw amount |
»» fastWithdrawFactRegisterAddress | string | true | none | L1 Fact registered contract address |
»» crossChainAccountId | string | true | none | Cross chain withdraw account id |
»» crossChainL2Key | string | true | none | Cross chain withdraw system l2Key |
»» registerChainId | integer | true | 5 | envId initially filled during onboarding: Differentiate by environment with 1 as production and 5 as testing environments |
» currency | [object] | true | none | none |
»» id | string | true | none | Token name |
»» stepSize | string | true | none | Minimum step size |
»» starkExAssetId | string | false | none | StarkEx asset id |
»» starkExResolution | string | false | none | StarkEx resolution |
» multiChain | object | true | none | none |
»» maxWithdraw | string | true | none | Maximum withdrawal amount |
»» minWithdraw | string | true | none | Minimum withdrawal amount |
»» minDeposit | string | true | none | Minimum deposit amount |
»» currency | string | true | USDC | Currency |
»» chains | [object] | true | none | none |
»»» chain | string | true | none | Chain |
»»» contractAddress | string | true | none | Contract address |
»»» chainIconUrl | string | true | none | Chain icon url |
»»» gasToken | string | true | none | Gas token name |
»»» rpcUrl | string | true | none | Chain RPC service Url |
»»» chainId | integer | true | none | Chain ID |
»»» feeLess | boolean | true | none | Enable trading fees |
»»» depositGasFeeLess | boolean | false | none | Enable deposit gas fees |
»»» withdrawGasFeeLess | boolean | false | none | Enable withdraw gas fees |
»»» minFee | string | true | none | Minimum deposit gas fee: If gas+value*fee_rate is lesser than min_fee, min_fee amount will be charged instead |
»»» feeRate | string | true | none | Fee rate |
»»» webTxUrl | string | true | none | Transaction tx URL |
»»» tokens | [object] | true | none | none |
»»»» token | string | true | none | Token name |
»»»» tokenAddress | string | true | none | Token address |
»»»» decimals | integer | true | none | Token decimal point accuracy |
»»»» iconUrl | string | true | none | Token icon URL |
»»»» pullOff | bool | true | none | Enable taking down of listing, default as FALSE |
»»» gasLess | boolean | true | none | Enable gas free transaction |
» perpetualContract | [object] | true | none | none |
»» symbol | string | true | none | Symbol id |
»» symbolDisplayName | string | true | none | Symbol display name |
»» settleCurrencyId | string | true | none | Settlement asset id |
»» underlyingCurrencyId | string | true | none | Underlying asset id |
»» tickSize | string | true | none | Minimum tick size |
»» stepSize | string | true | none | Minimum step size |
»» minOrderSize | string | true | none | Minimum order size |
»» maxOrderSize | string | true | none | Maximum order size |
»» maxPositionSize | string | true | none | Maximum position size |
»» maxMarketPriceRange | string | true | none | Maximum Market Price rangee |
»» initialMarginRate | string | true | none | Initial margin rate |
»» maintenanceMarginRate | string | true | none | Maintenance margin rate |
»» baselinePositionValue | string | true | none | Baseline position vaue |
»» incrementalPositionValue | string | true | none | Incremental position value |
»» incrementalInitialMarginRate | string | true | none | Incremental initial margin rate |
»» incrementalMaintenanceMarginRate | string | true | none | Incremental maintenance margin rate |
»» enableTrade | boolean | true | none | Enable trade |
»» enableDisplay | boolean | true | none | Enable display |
»» enableOpenPosition | boolean | true | none | Enable open position |
»» digitMerge | string | true | none | Depth digit merge |
»» crossId | integer | true | none | Quote API use id for symbol |
»» crossSymbolId | integer | true | none | Quote API use symbolId for symbol |
»» crossSymbolName | string | true | none | Quote API use symbolName for symbol |
»» fundingInterestRate | string | true | none | Funding rate ratio |
»» fundingImpactMarginNotional | string | true | none | Not required on frontend |
»» displayMaxLeverage | string | true | none | Maximum leverage |
»» displayMinLeverage | string | true | none | Minimum leverage |
»» starkExSyntheticAssetId | string | true | none | Currency synthetic asset id |
»» starkExResolution | string | true | none | Currency resolution |
»» starkExRiskFactor | string | true | none | none |
»» starkExOraclePriceQuorum | string | true | none | none |
GET Market Depth
GET /v1/depth
Retrieve all active orderbook for one symbol, inclue all bids and asks.
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Default at 100 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.depth(symbol="BTCUSDC")
curl "https://pro.apex.exchange/api/v1/depth?symbol=BTCUSDC"
Successful Response Generation
success
{
"data": {
"a": [
[
"98743.4",
"0.071"
],
[
"98743.5",
"0.035"
]
],
"b": [
[
"98742.3",
"0.529"
],
[
"98742.2",
"0.178"
]
],
"s": "BTCUSDT",
"u": 1076833
},
"timeCost": 1056809
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» a | [array] | false | none | Sell |
»» b | [array] | false | none | Buy |
»» s | string | false | none | Symbol |
»» u | integer | false | none | none |
GET Newest Trading Data
GET /v1/trades
Retrieve trading data.
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
limit | query | string | false | Limit, maximum is 500 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.trades(symbol="BTCUSDC")
curl "https://pro.apex.exchange/api/v1/trades?symbol=BTCUSDC"
Successful Response Generation
success
{
"data": [
{
"S": "BUY",
"v": "0.001",
"p": "29000",
"s": "BTCUSDC",
"T": 1647502440973
}
]
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» data | [object] | true | none | none |
»» S | string | false | none | Side |
»» v | string | false | none | Size |
»» p | string | false | none | Price |
»» s | string | false | none | Symbol |
»» T | integer | false | none | Trade time |
GET Candlestick Chart Data
GET /v1/klines
Retrieves all candlestick chart data.
Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W"
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
interval | query | string | false | Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W" |
start | query | string | false | Start time , second timestamp |
end | query | string | false | End time , second timestamp |
limit | query | string | false | Limit, maximum is 1500 |
symbol | query | string | false | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.klines(symbol="BTCUSDC",interval=5)
curl "https://pro.apex.exchange/api/v1/klines?symbol=BTCUSDC?interval=5"
Successful Response Generation
success
{
"data": [
{
"start": 1647511440000,
"symbol": "BTCUSDC",
"interval": "1",
"low": "40000",
"high": "45000",
"open": "45000",
"close": "40000",
"volume": "1.002",
"turnover": "3"
}
]
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» klines | [object] | true | none | none |
»» start | integer | false | none | Start time |
»» symbol | string | true | none | Currency |
»» interval | string | true | none | Chart interval |
»» low | string | false | none | Low price |
»» high | string | false | none | High price |
»» open | string | false | none | Open price |
»» close | string | false | none | Close price |
»» volume | string | false | none | Trading volume |
»» turnover | string | false | none | Turnover |
GET Ticker Data
GET /v1/ticker
Get the latest data on symbol tickers.
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.ticker(symbol="BTCUSDC")
curl "https://pro.apex.exchange/api/v1/ticker?symbol=BTCUSDC"
Successful Response Generation
success
{
"data": [
{
"symbol": "BTCUSDC",
"price24hPcnt": "0.450141",
"lastPrice": "43511.50",
"highPrice24h": "43513.50",
"lowPrice24h": "29996.00",
"oraclePrice": "43513.50",
"indexPrice": "40828.94",
"openInterest": "2036854775808",
"turnover24h": "5626085.23749999",
"volume24h": "169.317",
"fundingRate": "0",
"predictedFundingRate": "0",
"nextFundingTime": "10:00:00",
"tradeCount": 100
}
]
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» tickers | [object] | true | none | none |
»» symbol | string | false | none | Symbol |
»» price24hPcnt | string | false | none | 24H change (%) |
»» lastPrice | string | false | none | Last price |
»» highPrice24h | string | false | none | 24H highest price |
»» lowPrice24h | string | false | none | 24H lowest price |
»» oraclePrice | string | false | none | Oracle price |
»» indexPrice | string | false | none | Index price |
»» openInterest | string | false | none | Open interest |
»» turnover24h | string | false | none | 24H turnover |
»» volume24h | string | false | none | 24H trading volume |
»» fundingRate | string | false | none | Funding rate |
»» predictedFundingRate | string | false | none | Predicted funding rate |
»» nextFundingTime | string | false | none | Next funding rate |
»» tradeCount | string | false | none | 24H trade count |
GET Funding Rate History
GET /v1/history-funding
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
symbol | query | string | true | use crossSymbolName responded from All Config Data |
Limit | query | string | false | Default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
from apexpro.http_public import HttpPublic
client = HttpPublic("https://pro.apex.exchange")
client.history_funding(symbol="BTC-USDC")
curl "https://pro.apex.exchange/api/v1/history-funding?symbol=BTC-USDC"
Successful Response Generation
success
{
"historyFunds": [
{
"symbol": "BTC-USD",
"rate": "0.0000125000",
"price": "31297.5000008009374142",
"fundingTime": 12315555,
"fundingTimestamp": 12315555
}
],
"totalSize": 11
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | type | required | limit | comment |
---|---|---|---|---|
» historicalFunds | [object] | true | none | none |
»» symbol | string | false | none | none |
»» rate | string | false | none | Funding rate |
»» price | string | false | none | Price |
»» fundingTime | integer | false | none | Time |
»» fundingTimestamp | integer | false | none | Funding timestamp |
» totalSize | integer | true | none | Size |
GET Check If User Exists
GET /v1/check-user-exist
Request Parameters
Parameter | Position | type | required | comment |
---|---|---|---|---|
ethAddress | query | string | FALSE | 0x111111 |
Successful Response Generation
success
{
"data": false
}
Response Status Code
status code | value | comment | data model |
---|---|---|---|
200 | OK | success | Inline |
Response Parameters
status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | boolean | true | none | none |
PrivateApi V3 for Omni
v3.0.0
POST Generate nonce
POST /v3/generate-nonce
Generate and obtain nonce before registration. The nonce is used to assemble the signature field upon registration.
from apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_MAIN, NETWORKID_MAIN
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs_v3()
zkKeys = client.derive_zk_key(client.default_address)
print(zkKeys)
nonceRes = client.generate_nonce_v3(refresh="false", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_MAIN)
curl https://omni.apex.exchange/api/v3/generate-nonce -X POST -d 'l2Key={l2Key}ðAddress={ethAddress}&chainId={chainId}'
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
body | body | object | false | none |
» l2Key | body | string | true | User's l2Key of zkKeys |
» ethAddress | body | string | true | User's Ethereum address |
» chainId | body | string | true | API trading users to enter "9"(NETWORKID_MAIN) on mainnet |
Successful Response Generation
{
"data": {
"nonce": "1123940951220551680",
"nonceExpired": 1648727402292
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» nonce | string | true | none | nonce |
» nonceExpired | integer | true | none | The time at which nonce expires, please complete registration before this time |
POST Registration & Onboarding
POST /v3/onboarding
- Consolidate onboarding data and generate digital signature via your wallet. You can refer to python sdk, derive_zk_key for more information
- Create your zkKey pair with your signature, including (seeds, l2Key, pubKeyHash)
- Send consolidated onboarding data request to the server for response to user registration data, including API keys
curl https://omni.apex.exchange/api/v3/onboarding -H 'APEX-SIGNATURE: ***' -H 'APEX-ETHEREUM-ADDRESS: ***' -X POST -d 'l2Key={l2Key}ðereumAddress={ethereumAddress}&referredByAffiliateLink={referredByAffiliateLink}&country={country}'
from apexpro.constants import APEX_OMNI_HTTP_MAIN, NETWORKID_MAIN, NETWORKID_MAIN
print("Hello, Apex Omni")
priKey = "your eth private key"
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs_v3()
zkKeys = client.derive_zk_key(client.default_address)
print(zkKeys)
nonceRes = client.generate_nonce_v3(refresh="false", l2Key=zkKeys['l2Key'],ethAddress=client.default_address, chainId=NETWORKID_MAIN)
regRes = client.register_user_v3(nonce=nonceRes['data']['nonce'],l2Key=zkKeys['l2Key'], seeds=zkKeys['seeds'],ethereum_address=client.default_address)
changePubKeyStatus (
INIT // ini
REGISTERING //registering (waiting for l2 execute)
UN_CHANGE_PUB_KEY // un ChangePubKey
PROCESSING // ChangePubKey in progress
FINISH // ChangePubKey is finished
)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Onboarding signature |
APEX-ETHEREUM-ADDRESS | header | string | true | Ethereum address |
body | body | object | false | none |
» l2Key | body | string | true | Public l2Key associated with the zkKeys you created. |
» ethereumAddress | body | string | true | Ethereum address associated with the user being created. |
» referredByAffiliateLink | body | string | false | Referred affiliate link |
» country | body | string | false | Country code: Must be ISO 3166-1 Alpha-2 compliant |
Successful Response Generation
{
"apiKey": {
"apiKey": "d4fc8895-2aec-00",
"key": "d4fc8895-2aec-0025-a620",
"secret": "l5oxJeCvjqAps",
"remark": "",
"ips": []
},
"user": {
"ethereumAddress": "0xc4C5036b68a",
"isRegistered": false,
"email": "11@aa.com",
"username": "pythonTest",
"referredByAffiliateLink": "",
"affiliateLink": "0",
"apexTokenBalance": "",
"stakedApexTokenBalance": "",
"isEmailVerified": false,
"isSharingUsername": false,
"isSharingAddress": false,
"country": "",
"id": "1213724853023293440",
"avatarUrl": "",
"avatarBorderUrl": "",
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false,
"appNotifyTradingEnable": false
},
"account": {
"ethereumAddress": "0xc4c5036b68a",
"l2Key": "oxaaaa",
"id": "3505225848",
"version": "123",
"spotAccount": {
"createdAt": 1690365436385,
"updatedAt": 1690365436385,
"zkAccountId": "3505225848111",
"isMultiSigEthAddress": false,
"defaultSubAccountId": "3505225848111",
"nonce": 1111,
"status": "NORMAL",
"subAccounts": [
{
"subAccountId": "3505225848111",
"l2Key": "0x1123",
"nonce": 11,
"nonceVersion": 11,
"changePubKeyStatus": "REGISTING"
}
]
},
"spotWallets": [
{
"userId": "12137",
"accountId": "350",
"subAccountId": "350",
"balance": "1191781.577364",
"tokenId": "1",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000",
"createdAt": 1690365436385,
"updatedAt": 1690365436385
}
],
"experienceMoney": [
{
"availableAmount": "0.000000",
"totalNumber": "0",
"totalAmount": "0.000000",
"recycledAmount": "0.000000",
"token": "USDT"
}
],
"contractAccount": {
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"unrealizePnlPriceType": "INDEX_PRICE"
},
"contractWallets": [
{
"userId": "121372485302",
"accountId": "350522584833",
"balance": "1191778.137753",
"token": "USDT",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000"
}
],
"positions": [
{
"isPrelaunch": false,
"symbol": "BTC-USDT",
"status": "",
"side": "LONG",
"size": "0.000",
"entryPrice": "0.00",
"exitPrice": "",
"createdAt": 1690366452416,
"updatedTime": 1690366452416,
"fee": "0.000000",
"fundingFee": "0.000000",
"lightNumbers": "",
"customInitialMarginRate": "0"
}
],
"isNewUser": false
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» apiKey | object | true | none | none |
»» key | string | true | none | Placed in request header for sending to server |
»» passphrase | string | true | none | Placed in request header for sending to server |
»» secret | string | true | none | Used to generate signature |
» user | object | true | none | none |
»» ethereumAddress | string | true | none | Ethereum address |
»» isRegistered | boolean | true | none | Registration confirmation |
string | true | none | ||
»» username | string | true | none | Username |
»» referredByAffiliateLink | string | true | none | referred Affiliate Link |
»» isEmailVerified | boolean | true | none | Email binding confirmation |
»» emailNotifyGeneralEnable | boolean | true | none | Newsletter, Market Updates, Product notify |
»» emailNotifyTradingEnable | boolean | true | none | Deposits、Withdrawals, Account notify |
»» emailNotifyAccountEnable | boolean | true | none | Order and Liquidation notify |
»» popupNotifyTradingEnable | boolean | true | none | Trading pop-up notify |
» account | object | true | none | none |
»» l2Key | string | true | none | User's l2Key |
»» ethereumAddress | string | true | none | User's ethereumAddress |
»» id | string | true | none | User's account ID |
»» spotAccount | object | true | none | User's spot account |
»»» createdAt | integer | true | none | User's account create time |
»»» updatedAt | integer | true | none | User's account update time |
»»» zkAccountId | string | true | none | User's zk account ID |
»»» defaultSubAccountId | string | true | none | User's zk default sub account ID |
»»» nonce | integer | true | none | User's account nonce |
»»» status | string | true | none | User's account status |
»»» subAccounts | [object] | true | none | User's sub accounts |
»»»» subAccountId | string | false | none | User's sub account ID |
»»»» l2Key | string | false | none | User's sub account l2Key |
»»»» nonce | integer | false | none | User's sub account nonce |
»»»» nonceVersion | integer | false | none | User's sub account nonce version |
»»»» changePubKeyStatus | string | false | none | User's sub account change pubKey status |
»» spotWallets | [object] | true | none | User's spot wallets |
»»» tokenId | string | false | none | Spot token ID |
»»» pendingDepositAmount | string | false | none | Pending deposit amount |
»»» pendingWithdrawAmount | string | false | none | Pending withdraw amount |
»»» pendingTransferOutAmount | string | false | none | Pending transfer out amount |
»»» pendingTransferInAmount | string | false | none | Pending transfer in amount |
»» experienceMoney | [object] | true | none | Experience money |
»»» availableAmount | string | false | none | Available experience money amount |
»»» totalNumber | string | false | none | Total experience money number |
»»» totalAmount | string | false | none | Total experience money value |
»»» recycledAmount | string | false | none | Recycled experience money value |
»» contractAccount | object | true | none | |
»»» makerFeeRate | string | true | none | Maker fee rate |
»»» takerFeeRate | string | true | none | Taker fee rate |
»»» createdAt | integer | true | none | Created time |
»»» minInitialMarginRate | string | true | none | Min Initial Margin Rate |
»»» status | string | false | none | Account status |
»» contractWallets | [object] | true | none | Contract wallets |
»»» token | string | false | none | Asset token |
»»» balance | string | false | none | Wallet balance |
»»» pendingDepositAmount | string | true | none | Pending deposit amount |
»»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»»» symbol | string | false | none | Symbol |
»»» side | string | false | none | Side |
»»» size | string | false | none | Size |
»»» entryPrice | string | false | none | Entry price |
»»» fee | string | false | none | Order fee |
»»» createdAt | integer | false | none | Created at |
»»» updatedTime | integer | false | none | Updated time |
»»» fundingFee | string | false | none | Funding fee |
»»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Data
GET /v3/user
curl https://omni.apex.exchange/api/v3/user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_v3 import HttpPrivate_v3
from apexpro.constants import APEX_OMNI_HTTP_MAIN,
NETWORKID_MAIN
print("Hello, Apex Omni")
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
userRes = client.get_user_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
POST Edit User Data
POST /v3/modify-user
curl https://omni.apex.exchange/api/v3/modify-user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'userData={userData}&email={email}&username={username}&isSharingUsername={isSharingUsername}&isSharingAddress={isSharingAddress}&country={country}&emailNotifyGeneralEnable={emailNotifyGeneralEnable}&emailNotifyTradingEnable={emailNotifyTradingEnable}&emailNotifyAccountEnable={emailNotifyAccountEnable}&popupNotifyTradingEnable={popupNotifyTradingEnable}'
from apexpro.http_private_v3 import HttpPrivate_v3
from apexpro.constants import APEX_OMNI_HTTP_MAIN,
NETWORKID_MAIN
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
userRes = client.get_user_v3()
userRes = client.modify_user_v3(username="pythonTest",email="11@aa.com",emailNotifyGeneralEnable="true")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» userData | body | string | false | none |
body | string | false | ||
» username | body | string | false | Username |
» isSharingUsername | body | string | false | none |
» isSharingAddress | body | string | false | none |
» country | body | string | false | country |
» emailNotifyGeneralEnable | body | string | false | Newsletter, market and product updates |
» emailNotifyTradingEnable | body | string | false | Order and liquidation updates |
» emailNotifyAccountEnable | body | string | false | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | body | string | false | Enable trading notifications |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
GET Retrieve User Account Data
GET /v3/account
Get an account for a user by id. Using the client, the id will be generated with client information and an Ethereum address.
curl https://omni.apex.exchange/api/v3/account -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_v3 import HttpPrivate_v3
from apexpro.constants import APEX_OMNI_HTTP_MAIN,
NETWORKID_MAIN
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"ethereumAddress": "0xc4c5036b68a",
"l2Key": "oxaaaa",
"id": "3505225848",
"version": "123",
"spotAccount": {
"createdAt": 1690365436385,
"updatedAt": 1690365436385,
"zkAccountId": "3505225848111",
"isMultiSigEthAddress": false,
"defaultSubAccountId": "3505225848111",
"nonce": 1111,
"status": "NORMAL",
"subAccounts": [
{
"subAccountId": "3505225848111",
"l2Key": "0x1123",
"nonce": 11,
"nonceVersion": 11,
"changePubKeyStatus": "REGISTING"
}
]
},
"spotWallets": [
{
"userId": "12137",
"accountId": "350",
"subAccountId": "350",
"balance": "1191781.577364",
"tokenId": "1",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000",
"createdAt": 1690365436385,
"updatedAt": 1690365436385
}
],
"experienceMoney": [
{
"availableAmount": "0.000000",
"totalNumber": "0",
"totalAmount": "0.000000",
"recycledAmount": "0.000000",
"token": "USDT"
}
],
"contractAccount": {
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"unrealizePnlPriceType": "INDEX_PRICE",
"token": "USDC"
},
"contractWallets": [
{
"userId": "121372485302",
"accountId": "350522584833",
"balance": "1191778.137753",
"asset": "USDT",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000"
}
],
"positions": [
{
"isPrelaunch": false,
"symbol": "BTC-USDT",
"status": "",
"side": "LONG",
"size": "0.000",
"entryPrice": "0.00",
"exitPrice": "",
"createdAt": 1690366452416,
"updatedTime": 1690366452416,
"fee": "0.000000",
"fundingFee": "0.000000",
"lightNumbers": "",
"customInitialMarginRate": "0"
}
],
"isNewUser": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» account | object | true | none | none |
»» l2Key | string | true | none | User's l2Key |
»» ethereumAddress | string | true | none | User's ethereumAddress |
»» id | string | true | none | User's account ID |
»» spotAccount | object | true | none | User's spot account |
»»» createdAt | integer | true | none | User's account create time |
»»» updatedAt | integer | true | none | User's account update time |
»»» zkAccountId | string | true | none | User's zk account ID |
»»» defaultSubAccountId | string | true | none | User's zk default sub account ID |
»»» nonce | integer | true | none | User's account nonce |
»»» status | string | true | none | User's account status |
»»» subAccounts | [object] | true | none | User's sub accounts |
»»»» subAccountId | string | false | none | User's sub account ID |
»»»» l2Key | string | false | none | User's sub account l2Key |
»»»» nonce | integer | false | none | User's sub account nonce |
»»»» nonceVersion | integer | false | none | User's sub account nonce version |
»»»» changePubKeyStatus | string | false | none | User's sub account change pubKey status |
»» spotWallets | [object] | true | none | User's spot wallets |
»»» tokenId | string | false | none | Spot token ID |
»»» pendingDepositAmount | string | false | none | Pending deposit amount |
»»» pendingWithdrawAmount | string | false | none | Pending withdraw amount |
»»» pendingTransferOutAmount | string | false | none | Pending transfer out amount |
»»» pendingTransferInAmount | string | false | none | Pending transfer in amount |
»» experienceMoney | [object] | true | none | Experience money |
»»» availableAmount | string | false | none | Available experience money amount |
»»» totalNumber | string | false | none | Total number |
»»» totalAmount | string | false | none | Total value |
»»» recycledAmount | string | false | none | Recycled value |
»» contractAccount | object | true | none | |
»»» makerFeeRate | string | true | none | Maker fee rate |
»»» takerFeeRate | string | true | none | Taker fee rate |
»»» createdAt | integer | true | none | Created time |
»»» minInitialMarginRate | string | true | none | Min initial margin rate |
»»» status | string | false | none | Account status |
»» contractWallets | [object] | true | none | Contract wallets |
»»» asset | string | false | none | Asset |
»»» balance | string | false | none | Wallet balance |
»» pendingDepositAmount | string | true | none | Pending deposit amount |
»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»»» symbol | string | false | none | Symbol |
»»» side | string | false | none | Side |
»»» size | string | false | none | Size |
»»» entryPrice | string | false | none | Entry price |
»»» fee | string | false | none | Order fee |
»»» createdAt | integer | false | none | Created at |
»»» updatedTime | integer | false | none | Updated time |
»»» fundingFee | string | false | none | Funding fee |
»»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Account balance
GET /v3/account-balance
curl https://omni.apex.exchange/api/v3/account-balance -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_v3 import HttpPrivate_v3
from apexpro.constants import APEX_OMNI_HTTP_MAIN,
NETWORKID_MAIN
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
userRes = client.get_account_v3()
accountRes = client.get_account_balance_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"totalEquityValue": "100.000000",
"availableBalance": "100.000000",
"initialMargin": "100.000000",
"maintenanceMargin": "100.000000",
"symbolToOraclePrice": {
"BTC-USDT": {
"oraclePrice": "20000",
"createdTime": 124566
}
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» totalEquityValue | string | true | none | |
» availableBalance | string | true | none | |
» initialMargin | string | true | none | |
» maintenanceMargin | string | true | none | |
» symbolToOraclePrice | object | true | none | |
»» BTC-USDC | object | true | none | |
»»» oraclePrice | string | true | none | |
»»» createdTime | integer | true | none |
GET Retrieve User Deposit and Withdraw Data
GET /v3/transfers
curl https://omni.apex.exchange/api/v3/transfers?limit={limit}&page={page}¤cyId={currencyId}&chainIds={chainIds} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_v3 import HttpPrivate_v3
from apexpro.constants import APEX_OMNI_HTTP_MAIN,
NETWORKID_MAIN
# need api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase} for private api
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
transfersRes = client.transfers_v3(limit=100,page=0,currencyId="USDT",chainIds="1,5,13")
direction (
NEXT
PREVIOUS
)
TransfersType (
DEPOSIT
WITHDRAW
FAST_WITHDRAW
OMNI_TO_PERP //spot account -> contract account
OMNI_FROM_PERP //spot account <- contract account
AFFILIATE_REBATE // affliate rebate
REFERRAL_REBATE // referral rebate
BROKER_REBATE // broker rebate
)
Deposit Status{
PENDING_RISK_CHECKING // risk checking
PENDING_SEND_L2 // sending to l2
SUCCESS // deposit success
SUCCESS_L2_APPROVED // L2 approved success
FAILED_RISK_CHECKING // risk checking failed
FAILED_SEND_L2 // sending to l2 failed
FAILED_L2_REJECTED // l2 rejected
}
Withdrawal and FastWithdrawal Status{
PENDING_WITHDRAW_L1_TRY // pending withdraw
PENDING_SEND_L2 // pending send
SUCCESS // withdraw success
SUCCESS_L2_APPROVED // l2 approve withdraw success
WITHDRAW_CAN_BE_CLAIM //the withdrawal can be claim
PENDING_L1_CLAIMING //pengding claim
SUCCESS_L1_CLAIMED //claim success
FAILED_WITHDRAW_L1_TRY_REJECTED // withdraw to l1 be rejected
FAILED_SEND_L2 // withdraw failed
FAILED_L2_REJECTED // withdraw failed by l2
FAST_WITHDRAW_L1_SUCCESS // fast withdraw success
FAILED_L1_CLAIMED_REJECTED //claim failed
}
TransferStatus (
PENDING_CHECKING // transfer checking
PENDING_SEND_L2 // sending to l2
SUCCESS // transfer success
SUCCESS_L2_APPROVED // l2 approved
FAILED_CHECK_INVALID // transfer check failed
FAILED_SEND_L2 // transfer send failed
FAILED_L2_REJECTED // l2 rejected
)
Request Parameters
Parameters | Position | Type | Required | Comments |
---|---|---|---|---|
limit | query | integer | false | Page limit default at 100 |
id | query | string | no | if direction is NEXT the id is the last one of this page, or direction is PREVIOUS the id is first one of this page |
tokenId | query | string | no | Filter to show only token ID, all will be searched if the field is empty |
beginTimeInclusive | query | integer | false | Start time |
endTimeExclusive | query | string | false | End time |
chainIds | query | string | false | Check for multiple chainID records, separated by commas |
transferType | query | string | false | Check for multiple transferType records, separated by commas |
subAccountId | query | string | yes | none, default 0 |
direction | query | string | no | default NEXT |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"transfers": [
{
"id": "1111",
"type": "WITHDRAW",
"amount": "3000",
"transactionHash": "0x12aaaaaaaa",
"status": "PENDING",
"createdAt": 1647502440973,
"updatedAt": 1647502440973,
"confirmedAt": 1647502440973,
"fromTokenId": "12",
"toTokenId": "12",
"chainId": "1235",
"orderId": "1235",
"ethAddress": "0x1235",
"fromEthAddress": "0x1235",
"toEthAddress": "0x1235",
"fee": "11",
"clientId": "12345"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» transfers | [object] | true | none | none |
»» id | string | false | none | none |
»» type | string | false | none | DEPOSIT, WITHDRAW or FAST_WITHDRAW |
»» Amount | string | false | none | Amount |
»» transactionHash | string | false | none | Transaction hash |
»» status | string | false | none | Status |
»» createdAt | integer | false | none | Created at |
»» updatedAt | string | false | none | Only applicable for deposits |
»» clientId | string | false | none | Client to create a randomized id (only for withdrawal) |
»» orderId | string | true | none | Success Wallet Transaction Id |
»» chainId | string | true | none | Supported chainId |
»» fee | string | true | none | Fee |
» totalSize | string | true | none | Total size |
POST User transfer asset from fund account to contract account
POST /v3/transfer-out
from apexpro.http_private_sign import HttpPrivateSign
from apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST, NETWORKID_OMNI_TEST_BNB
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'
seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'
client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
zk_seeds=seeds,zk_l2Key=l2Key,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()
#smple3 transfer_out, from fund account to contract account
#createTransferRes = client.create_transfer_out_v3(amount='1.1',asset='USDT')
#print(createTransferRes)
createTransferRes = client.create_transfer_out_v3(amount='0.01',asset='ETH')
print(createTransferRes)
Body Request
amount: string
clientTransferId: string
timestamp: 0
tokenId: string
token: string
fee: string
signature: string
zkAccountId: string
nonce: 0
receiverAccountId: string
receiverZkAccountId: string
receiverSubAccountId: string
receiverAddress: string
subAccountId: string
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | yes | Request signature |
APEX-TIMESTAMP | header | string | yes | Request timestamp |
APEX-API-KEY | header | string | yes | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | yes | apiKeyCredentials.passphrase |
body | body | object | no | none |
» amount | body | string | yes | Amount |
» clientTransferId | body | string | yes | Unique id of the client associated with the transfer. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» timestamp | body | integer | yes | Timestamp,sec |
» tokenId | body | string | yes | Asset token id |
» token | body | string | yes | Asset token |
» fee | body | string | yes | Transfer fee, default is 0 |
» signature | body | string | yes | The signature for the transfer, |
» zkAccountId | body | string | yes | User's zk account id |
» nonce | body | integer | yes | User's eth address nonce |
» receiverAccountId | body | string | yes | Contract asset pool account id |
» receiverZkAccountId | body | string | yes | Contract asset pool zk account id |
» receiverSubAccountId | body | string | yes | Contract asset pool sub account id, default is 0 |
» receiverAddress | body | string | yes | Contract asset pool eth address |
» subAccountId | body | string | yes | User's sub account id,default is 0 |
Successful Response Generation
{
"id": "1234455",
"type": "TRANSFER_OUT"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | |
» type | string | true | none |
POST User transfer asset from contract account to fund account
POST /v3/contract-transfer-out
example
from apexpro.http_private_sign import HttpPrivateSign
from apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST, NETWORKID_OMNI_TEST_BNB
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'
seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'
client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
zk_seeds=seeds,zk_l2Key=l2Key,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()
#smple4 contract transfer_out, from contract account to fund account
createContractTransferRes = client.create_contract_transfer_out_v3(amount='1.2',asset='USDT', clientId='apexomni-518082507269-1741841574131-212072')
print(createContractTransferRes)
Body Request
amount: string
clientWithdrawId: string
expireTime: 0
ethAddress: string
signature: string
token: string
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | yes | Request signature |
APEX-TIMESTAMP | header | string | yes | Request timestamp |
APEX-API-KEY | header | string | yes | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | yes | apiKeyCredentials.passphrase |
body | body | object | no | none |
» amount | body | string | yes | Amount |
» clientWithdrawId | body | string | yes | Unique id of the client associated with the transfer. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expireTime | body | integer | yes | Expire time,sec |
» ethAddress | body | string | yes | User's eth address |
» signature | body | string | yes | The signature for the transfer, signed with private key. |
» token | body | string | yes | Asset token |
Successful Response Generation
{
"id": "12345",
"type": "PERP_TO_ZK"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | |
» type | string | true | none |
POST User Withdrawal
`POST /v3/withdrawal
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
};
example
curl https://omni.apex.exchange/api/v3/withdrawal -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount=1&clientWithdrawId=xxx×tamp=1234556ðAddress=0x123&signature=0x1123&zkAccountId=111&subAccountId=0&l2Key=0x12345&toChainId=3&l2SourceTokenId=140&l1TargetTokenId=140&fee=0&nonce=1&isFastWithdraw=false'
from apexpro.http_private_sign import HttpPrivateSign
from apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST, NETWORKID_OMNI_TEST_BNB
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'
seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'
client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
zk_seeds=seeds,zk_l2Key=l2Key,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()
createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=NETWORKID_OMNI_TEST_BNB)
print(createWithdrawRes)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | yes | Amount |
» clientWithdrawId | body | string | yes | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» timestamp | body | integer | yes | Timestamp,sec |
» ethAddress | body | string | yes | EthAddress |
» signature | body | string | yes | The signature for the withdraw, signed with zkKeys. |
» zkAccountId | body | string | yes | The user's zkAccountId |
» subAccountId | body | string | yes | The user's subAccountId, default is 0 |
» l2Key | body | string | yes | Zk l2Key |
» toChainId | body | string | yes | To chainId |
» l2SourceTokenId | body | string | yes | Default is 140,(USDT) |
» l1TargetTokenId | body | string | yes | Default is 140,(USDT) |
» fee | body | string | yes | Default is 0 |
» nonce | body | integer | yes | The user zk account nonce |
» isFastWithdraw | body | string | yes | Defalut is false |
Successful Response Generation
{
"id": "1234455",
"type": "WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | id |
» type | string | true | none | type |
GET Withdrawal Fees
- the withdrawal need zkAvailableAmount >= withdrawAmount
- the fast withdrawal needzkAvailableAmount >= withdrawAmount && fastPoolAvailableAmount>= withdrawAmount
`GET /v3/withdraw-fee
curl https://omni.apex.exchange/api/v3/withdraw-fee?amount={amount}&chainId={chainId}&tokenId={tokenId} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_sign import HttpPrivateSign
from apexpro.constants import NETWORKID_TEST, APEX_OMNI_HTTP_TEST, NETWORKID_OMNI_TEST_BNB
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'
seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'
client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
zk_seeds=seeds,zk_l2Key=l2Key,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()
withdraw_feeRes = client.withdraw_fee_v3(amount="3",chainIds="3",tokenId='140')
print(withdraw_feeRes)
createWithdrawRes = client.create_withdrawal_v3(amount='3',asset='USDT', toChainId=3, fee=withdraw_feeRes.get('data').get('withdrawFeeAndPoolBalances')[0].get('fee'), isFastWithdraw=True)
print(createWithdrawRes)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
amount | query | string | false | USDT |
chainIds | query | string | false | withdraw to chainId |
tokenId | query | string | false | default is 140(USDT) |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"withdrawFeeAndPoolBalances": [
{
"chainId": "123",
"tokenId": "111",
"fee": "1.1",
"zkAvailableAmount": "1.1",
"fastpoolAvailableAmount": "1.1"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» withdrawFeeAndPoolBalances | [object] | true | none | Fee and Pool |
»» chainId | string | true | none | ChainId |
»» zklinkTokenId | string | true | none | TokenId |
»» fee | string | true | none | Fee |
»» zklinkAvailableAmount | string | true | none | Pool zklink available amount |
»» fastpoolAvailableAmount | string | false | none | Fast pool available amount |
GET Contract Account Transfer Limits
GET /v3/contract-transfer-limit
curl https://omni.apex.exchange/api/v3/contract-transfer-limit?token={token} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
accountRes = client.contract_transfer_limit_v3(token='USDT')
print(accountRes)
print(accountRes)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"withdrawAvailableAmount": "100.1",
"transferAvailableAmount": "100.1",
"experienceMoneyAvailableAmount": "100.1",
"experienceMoneyRecycledAmount": "100.1",
"withdrawAvailableOriginAmount": "100.1",
"experienceMoneyNeedRecycleAmount": "100.1"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» withdrawAvailableAmount | string | true | none | Withdraw available amount |
» transferAvailableAmount | string | true | none | Transfer available amount |
» experienceMoneyAvailableAmount | string | true | none | Experience money available amount |
» experienceMoneyRecycledAmount | string | true | none | Experience money recycled amount |
» withdrawAvailableOriginAmount | string | true | none | Withdraw available origin amount |
» experienceMoneyNeedRecycleAmount | string | true | none | Experience money need recycle amount |
GET Trade History
GET /v3/fills
curl https://omni.apex.exchange/api/v3/fills?limit=100&page=0&symbol=BTC-USDC&side=BUY -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
fillsRes = client.fills_v3(limit=100,page=0,symbol="BTC-USDC",side="BUY")
Order Type
"UNKNOWN_ORDER_TYPE"
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | Symbol |
side | query | string | false | BUY or SELL |
limit | query | string | false | default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | orderType |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientOrderId": "1234",
"orderId": "123546",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | Total order size |
GET Worst Price
GET /v3/get-worst-price
get market price from orderbook
curl https://omni.apex.exchange/api/v3/get-worst-price?size=1&symbol=BTC-USDT&side=BUY -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
fillsRes = client.get_worst_price_v3(size=1,symbol="BTC-USDT",side="BUY")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | Symbol |
size | query | string | true | Order open size |
side | query | string | true | BUY or SELL order |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"worstPrice": "123.00",
"bidOnePrice": "123.00",
"askOnePrice": "123.00"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» worstPrice | string | true | none | Lowest price |
» bidOnePrice | string | true | none | Bid price |
» askOnePrice | string | true | none | Ask price |
POST Creating Orders
POST /v3/order
TimeInForce (
GOOD_TIL_CANCEL // Effective until canceled, default.
FILL_OR_KILL // Immediately and completely filled or canceled.
IMMEDIATE_OR_CANCEL // Immediately executed or canceled.
)
example
curl https://omni.apex.exchange/api/v3/order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={symbol}&side={side}&type={type}&size={size}&price={price}&limitFee={limitFee}&expiration={expiration}&timeInForce={timeInForce}&triggerPrice={triggerPrice}&trailingPercent={trailingPercent}&clientOrderId={clientOrderId}&signature={signature}&reduceOnly=false'
key = 'your apiKey-key from register'
secret = 'your apiKey-secret from register'
passphrase = 'your apiKey-passphrase from register'
seeds = 'your zk seeds from register'
l2Key = 'your l2Key seeds from register'
client = HttpPrivateSign(APEX_OMNI_HTTP_TEST, network_id=NETWORKID_TEST,
zk_seeds=seeds,zk_l2Key=l2Key,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountData = client.get_account_v3()
currentTime = time.time()
createOrderRes = client.create_order_v3(symbol="BTC-USDT", side="SELL",
type="MARKET", size="0.001", timestampSeconds= currentTime,
price="60000")
print(createOrderRes)
# sample6
# Create a TP/SL order
# first, Set a slippage to get an acceptable slPrice or tpPrice
#slippage is recommended to be greater than 0.1
# when buying, the price = price*(1 + slippage). when selling, the price = price*(1 - slippage)
slippage = decimal.Decimal("-0.1")
slPrice = decimal.Decimal("58000") * (decimal.Decimal("1") + slippage)
tpPrice = decimal.Decimal("79000") * (decimal.Decimal("1") - slippage)
createOrderRes = client.create_order_v3(symbol="BTC-USDT", side="BUY",
type="LIMIT", size="0.01",
price="65000",
isOpenTpslOrder=True,
isSetOpenSl=True,
slPrice=slPrice,
slSide="SELL",
slSize="0.01",
slTriggerPrice="58000",
isSetOpenTp=True,
tpPrice=tpPrice,
tpSide="SELL",
tpSize="0.01",
tpTriggerPrice="79000",
)
print(createOrderRes)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | Symbol |
» side | body | string | true | BUY or SELL |
» type | body | string | true | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT", "TAKE_PROFIT_MARKET" |
» size | body | string | true | Size |
» price | body | string | true | Price |
» limitFee | body | string | true | limitFee = price * size * takerFeeRate( from GET /v1/account) |
» expiration | body | string | true | Order expiry time |
» timeInForce | body | string | false | "GOOD_TIL_CANCEL", "FILL_OR_KILL", "IMMEDIATE_OR_CANCEL", "POST_ONLY" |
» triggerPrice | body | string | false | Trigger price |
» trailingPercent | body | string | false | Conditional order trailing-stop |
» clientOrderId | body | string | true | Randomized client id |
» signature | body | string | true | zkKey signature |
» reduceOnly | body | string | false | Reduce-only |
Successful Response Generation
{
"id": "1234",
"clientId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"remainingSize": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"stopPnl": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1",
"triggerPriceType": "INDEX",
"isOpenTpslOrder": true,
"isSetOpenTp": true,
"isSetOpenSl": false,
"openTpParam": {
"side": "SELL",
"price": "18000",
"limitFee": "100",
"clientOrderId": "111100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100"
},
"openSlParam": {
"side": "SELL",
"price": "18000",
"limitFee": "100",
"clientOrderId": "111100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100"
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel Order
POST /v3/delete-order
curl https://omni.apex.exchange/api/v3/delete-order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
deleteOrderRes = client.delete_order_v3(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | false | none |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
POST Cancel Order By ClientOrderId
POST /v3/delete-client-order-id
curl https://omni.apex.exchange/api/v3/delete-client-order-id` -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
deleteOrderRes = client.delete_order_by_client_order_id_v3(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | false | none |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
GET Open Orders
GET /v3/open-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://omni.apex.exchange/api/v3/open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
openOrdersRes = client.open_orders_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"data": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel all Open Orders
POST /v3/delete-open-orders
Body Request Parameters
symbol: BTC-USDT,ETH-USDT
curl https://omni.apex.exchange/api/v3/delete-open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={BTC-USDC,ETH-USDC}'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
deleteOrdersRes = client.delete_open_orders_v3(symbol="BTC-USDT,ETH-USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | false | "BTC-USDT,ETH-USDT", Cancel all orders if none |
Successful Response Generation
{
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
GET All Order History
GET /v3/history-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://omni.apex.exchange/api/v3/history-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
historyOrdersRes = client.history_orders_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | none |
status | query | string | false | none |
side | query | string | false | BUY or SELL |
type | query | string | false | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT","TAKE_PROFIT_MARKET" |
limit | query | string | false | default 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | "ACTIVE","CONDITION","HISTORY" |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | total order size |
GET Order ID
GET /v3/order
curl https://omni.apex.exchange/api/v3/order?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
getOrderRes = client.get_order_v3(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Order by clientOrderId
GET /v3/order-by-client-order-id"
curl https://omni.apex.exchange/api/v3/order-by-client-order-id?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
getOrderRes = client.get_order_by_client_order_id_v3(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Funding Rate
GET /v3/funding
curl https://omni.apex.exchange/api/v3/funding?limit={limit}&page={page}&symbol={symbol}&side={side} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
fundingRes = client.funding_v3(limit=100,page=0,symbol="BTC-USDT",side="BUY")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | none |
limit | query | string | false | Default at 100 |
page | query | string | false | Page numbers start from 0 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
side | query | string | false | Side |
status | query | string | false | Order status |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"fundingValues": [
{
"id": "1234",
"symbol": "BTC-USD",
"fundingValue": "10000",
"rate": "0.0000125000",
"positionSize": "500",
"price": "90",
"side": "LONG",
"status": "SUCCESS",
"fundingTime": 1647502440973,
"transactionId": "1234556"
}
],
"totalSize": 11
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» fundingValues | [object] | true | none | none |
»» id | string | false | none | id |
»» symbol | string | false | none | Symbol |
»» fundingValue | string | false | none | Funding fee value |
»» rate | string | false | none | Funding rate |
»» positionSize | string | false | none | Open position size |
»» price | string | false | none | Symbol price |
»» side | string | false | none | Position side |
»» status | string | false | none | Position funding status |
»» fundingTime | integer | false | none | Funding fee time |
»» transactionId | string | false | none | Successful wallet transaction ID |
» totalSize | integer | true | none | Total size |
GET User Historial Profit and Loss
GET /v3/historical-pnl
curl https://omni.apex.exchange/api/v3/historical-pnl?limit={limit}&page={page}&beginTimeInclusive={beginTimeInclusive}&endTimeExclusive={endTimeExclusive}&type={type}&symbol={symbol} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
historicalPnlRes = client.historical_pnl_v3(limit=100,page=0,beginTimeInclusive=1651406864000,endTimeExclusive=1657105971171,symbol="BTC-USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
beginTimeInclusive | query | string | false | StartTime |
endTimeExclusive | query | string | false | EndTime |
type | query | string | false | Position type |
symbol | query | string | false | Symbol |
page | query | string | false | Page numbers start from 0 |
limit | query | string | false | Default at 100 |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historicalPnl": [
{ "symbol": "BTC-USDC",
"size": "1.0000",
"totalPnl": "1.0000",
"price": "1.0000",
"createdAt": 1647502440973,
"type": "CLOSE_POSITION",
"isLiquidate": false,
"isDeleverage": false
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
» historicalPnl | [object] | true | none | none |
»» size | string | false | none | Size |
»» totalPnl | string | false | none | Closing profit and loss |
»» price | string | false | none | Price |
»» exitPrice | string | false | none | Closing price |
»» createdAt | integer | false | none | Time |
»» type | string | false | none | postion type |
»» isLiquidate | boolean | false | none | Liquidate |
»» isDeleverage | boolean | false | none | ADL |
» totalSize | integer | true | none | none |
GET Yesterday's Profit & Loss
GET /v3/yesterday-pnl
curl https://omni.apex.exchange/api/v3/yesterday-pnl -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
yesterdayPnlRes = client.yesterday_pnl_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"data": "11.11"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Profit and loss value |
GET Historical Asset Value
GET /v3/history-value
curl https://omni.apex.exchange/api/v3/history-value -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
historyValueRes = client.history_value_v3()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
endTime | query | int64 | false | Start time |
startTime | query | int64 | false | End time |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historyValues": [
{
"accountTotalValue": "123.11",
"dateTime": 1651406864000
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» historyValues | [object] | true | none | none |
»» accountTotalValue | string | false | none | Assets |
»» dateTime | integer | false | none | Assets date and time snapshot |
POST Sets the initial margin rate of a contract
POST /v3/set-initial-margin-rate
curl https://omni.apex.exchange/api/v3/set-initial-margin-rate -H "Content-Type: application/x-www-form-urlencoded" -H "APEX-SIGNATURE: ***" -H "APEX-TIMESTAMP: ***" -H "APEX-API-KEY: ***" -H "APEX-PASSPHRASE: ***" -X POST -d "symbol=BTC-USDC&initialMarginRate=0.02"
key = 'your apiKey-key from register V3'
secret = 'your apiKey-secret from register V3'
passphrase = 'your apiKey-passphrase from register V3'
client = HttpPrivate_v3(APEX_OMNI_HTTP_MAIN, network_id=NETWORKID_OMNI_MAIN_ARB, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
configs = client.configs_v3()
accountRes = client.get_account_v3()
setInitialMarginRateRes = client.set_initial_margin_rate_v3(symbol="BTC-USDT",initialMarginRate="0.1")
print(setInitialMarginRateRes)
Body
symbol: string
initialMarginRate: string
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | symbol |
» initialMarginRate | body | string | true | initialMarginRate(the reciprocal of the opening leverage) |
Successful Response Generation
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
GET Repayment price V3
GET /v3/repayment-price
Direction (
SPOT_TO_PRICING //Spot assets -> Priced assets (usdt)
PRICING_TO_SPOT //Priced assets (usdt)->Spot assets
)
Status (
PENDING_CHECKING
PENDING_CENSORING
SUCCESS
SUCCESS_L2_APPROVED
FAILED_CHECK_INVALID
FAILED_CENSOR_FAILURE
FAILED_L2_REJECTED
)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
repaymentPriceTokens | query | string | yes | |
clientId | query | string | yes | none |
APEX-SIGNATURE | header | string | yes | none |
APEX-TIMESTAMP | header | string | yes | none |
APEX-API-KEY | header | string | yes | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | yes | apiKeyCredentials.passphrase |
repaymentPriceTokens: ETH|1,BTC|0.1
Successful Response Generation
Successful
{
"repaymentTokens": [
{
"token": "ETH",
"price": "3000",
"size": "1"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» repaymentTokens | [object] | true | none | |
»» token | string | false | none | |
»» price | string | false | none | |
»» size | string | false | none |
POST User manual repayment V3
POST /v3/manual-create-repayment
Body
repaymentTokens: ETH|3000|1,BTC|60000|0.1
clientId: string
signature: string
expireTime: 0
poolRepaymentTokens: ETH|3000|1,BTC|60000|0.1
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | yes | none |
APEX-TIMESTAMP | header | string | yes | none |
APEX-API-KEY | header | string | yes | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | yes | apiKeyCredentials.passphrase |
body | body | object | yes | none |
» repaymentTokens | body | string | yes | token |
» clientId | body | string | yes | Unique id of the client associated with the transfer. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» signature | body | string | yes | none |
» expireTime | body | integer | yes | sec |
» poolRepaymentTokens | body | string | yes | token |
Successful Response Generation
Successful
{
"id": "1234455"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none |
PrivateApi V2 for Pro
v2.0
POST Generate nonce V2
POST /v2/generate-nonce
Before registering, generate and obtain a nonce. The nonce serves the purpose of assembling the signature field during the registration process.
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0x*****")
configs = client.configs_v2()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="5")
curl https://pro.apex.exchange/api/v2/generate-nonce -X POST -d 'starkKey={starkKey}ðAddress={ethAddress}&chainId={chainId}'
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
body | body | object | false | none |
» starkKey | body | string | true | User's starkKey |
» ethAddress | body | string | true | User's Ethereum address |
» chainId | body | string | true | API trading users to enter "1" on mainnet |
Successful Response Generation
{
"data": {
"nonce": "1123940951220551680",
"nonceExpired": 1648727402292
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» nonce | string | true | none | nonce |
» nonceExpired | integer | true | none | The time at which nonce expires, please complete registration before this time |
POST Registration & Onboarding V2
POST /v2/onboarding
- Consolidate onboarding data and generate a digital signature using your wallet. Refer to the Python SDK, specifically derive_stark_key, for more information.
- Create your Stark Key pair with your signature, comprising (publicKey, publicKeyYCoordinate, privateKey).
- Send the consolidated onboarding data request to the server for a response, including API keys for user registration.
curl https://pro.apex.exchange/api/v2/onboarding -H 'APEX-SIGNATURE: ***' -H 'APEX-ETHEREUM-ADDRESS: ***' -X POST -d 'starkKey={starkKey}&starkKeyYCoordinate={starkKeyYCoordinate}ðereumAddress={ethereumAddress}&referredByAffiliateLink={referredByAffiliateLink}&country={country}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0xb7daaaaaaaaaaaaaaaa")
configs = client.configs_v2()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="5")
regRes = client.register_user_v2(nonce=nonceRes['data']['nonce'],starkKey=stark_key_pair_with_y_coordinate['public_key'],stark_public_key_y_coordinate=stark_key_pair_with_y_coordinate['public_key_y_coordinate'],ethereum_address=client.default_address)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Onboarding signature |
APEX-ETHEREUM-ADDRESS | header | string | true | Ethereum address |
body | body | object | false | none |
» starkKey | body | string | true | Public starkKey associated with the key-pair you created. |
» starkKeyYCoordinate | body | string | true | Public starkKey Y-Coordinate associated with the key-pair you created. |
» ethereumAddress | body | string | true | Ethereum address associated with the user being created. |
» referredByAffiliateLink | body | string | false | Referred affiliate link |
» country | body | string | false | Country code: Must be ISO 3166-1 Alpha-2 compliant |
Successful Response Generation
{
"apiKey": {
"key": "290xxxxxx",
"passphrase": "S6xxxxx",
"secret": "KQ3xxxx"
},
"user": {
"ethereumAddress": "0x09xxxxxx",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "man",
"referredByAffiliateLink": "url",
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
},
"account": {
"starkKey": "180913017c740260fea4b2c62828a4008ca8b0d6e4",
"positionId": "1812",
"id": "1812",
"takerFeeRate": "0.0005",
"makerFeeRate": "0.0005",
"createdAt": 1647502440973,
"experienceMoney": [
{
"availableAmount": "0.000000",
"totalNumber": "0",
"totalAmount": "0.000000",
"recycledAmount": "0.000000",
"token": "USDC"
}
],
"accounts": [
{
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"token": "USDC"
},
{
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"token": "USDT"
}
],
"wallets": [
{
"userId": "12137",
"accountId": "350",
"balance": "1191781.577364",
"asset": "USDC",
"token": "USDC",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000"
},
{
"userId": "12137",
"accountId": "350",
"balance": "1191781.577364",
"asset": "USDT",
"token": "USDT",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000"
}
],
"openPositions": [
{
"symbol": "BTC-USD",
"side": "LONG",
"size": "1000",
"entryPrice": "100",
"fee": "50",
"fundingFee": "100",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"lightNumbers": "1"
}
],
"id": "id"
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» apiKey | object | true | none | none |
»» key | string | true | none | Placed in request header for sending to server |
»» passphrase | string | true | none | Placed in request header for sending to server |
»» secret | string | true | none | Used to generate signature |
» user | object | true | none | none |
»» ethereumAddress | string | true | none | Ethereum address |
»» isRegistered | boolean | true | none | Registration confirmation |
string | true | none | ||
»» username | string | true | none | Username |
»» referredByAffiliateLink | string | true | none | referred Affiliate Link |
»» isEmailVerified | boolean | true | none | Email binding confirmation |
»» emailNotifyGeneralEnable | boolean | true | none | Newsletter, Market Updates, Product notify |
»» emailNotifyTradingEnable | boolean | true | none | Deposits、Withdrawals, Account notify |
»» emailNotifyAccountEnable | boolean | true | none | Order and Liquidation notify |
»» popupNotifyTradingEnable | boolean | true | none | Trading pop-up notify |
» account | object | true | none | none |
»» starkKey | string | true | none | User's starkKey |
»» positionId | string | true | none | User's account ID |
»» id | string | true | none | User's account ID |
»» experienceMoney | [object] | true | none | |
»»» availableAmount | string | false | none | |
»»» totalNumber | string | false | none | |
»»» totalAmount | string | false | none | |
»»» recycledAmount | string | false | none | |
»»» token | string | false | none | |
»» accounts | [object] | true | none | |
»»» makerFeeRate | string | true | none | Maker fee rate |
»»» takerFeeRate | string | true | none | Taker fee rate |
»»» createdAt | integer | true | none | Created time |
»»» minInitialMarginRate | string | true | none | |
»»» status | string | false | none | |
»»» token | string | true | none | |
»» wallets | [object] | true | none | User wallet |
»»» userId | string | false | none | User ID |
»»» accountId | string | false | none | Account ID |
»»» asset | string | false | none | Asset |
»»» balance | string | false | none | Wallet balance |
»» pendingDepositAmount | string | true | none | Pending deposit amount |
»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | Side |
»» size | string | false | none | Size |
»» entryPrice | string | false | none | Entry price |
»» fee | string | false | none | Order fee |
»» createdAt | integer | false | none | Created at |
»» updatedTime | integer | false | none | Updated time |
»» fundingFee | string | false | none | Funding fee |
»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Data V2
GET /v2/user
curl https://pro.apex.exchange/api/v2/user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
userRes = client.get_user()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
POST Edit User Data V2
POST /v2/modify-user
curl https://pro.apex.exchange/api/v2/modify-user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'userData={userData}&email={email}&username={username}&isSharingUsername={isSharingUsername}&isSharingAddress={isSharingAddress}&country={country}&emailNotifyGeneralEnable={emailNotifyGeneralEnable}&emailNotifyTradingEnable={emailNotifyTradingEnable}&emailNotifyAccountEnable={emailNotifyAccountEnable}&popupNotifyTradingEnable={popupNotifyTradingEnable}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
userRes = client.modify_user(username="pythonTest",email="11@aa.com",emailNotifyGeneralEnable="true")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» userData | body | string | false | none |
body | string | false | ||
» username | body | string | false | Username |
» isSharingUsername | body | string | false | none |
» isSharingAddress | body | string | false | none |
» country | body | string | false | country |
» emailNotifyGeneralEnable | body | string | false | Newsletter, market and product updates |
» emailNotifyTradingEnable | body | string | false | Order and liquidation updates |
» emailNotifyAccountEnable | body | string | false | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | body | string | false | Enable trading notifications |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
GET Retrieve User Account Data V2
GET /v2/account
Retrieve a user's account by their ID. Utilize the client, where the ID is generated with client information and an Ethereum address.
curl https://pro.apex.exchange/api/v1/account -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
accountRes = client.get_account()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"starkKey": "1234567",
"positionId": "350522584833",
"ethereumAddress": "0xc4c5036b68a42d8f1c6ba9ba8e5dd49ad5c1ef5c",
"id": "350522584833",
"experienceMoney": [
{
"availableAmount": "0.000000",
"totalNumber": "0",
"totalAmount": "0.000000",
"recycledAmount": "0.000000",
"token": "USDC"
}
],
"accounts": [
{
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"token": "USDC"
},
{
"createdAt": 1690365436385,
"takerFeeRate": "0.00050",
"makerFeeRate": "0.00020",
"minInitialMarginRate": "0",
"status": "NORMAL",
"token": "USDT"
}
],
"wallets": [
{
"userId": "121372485302",
"accountId": "350522584833",
"balance": "1191778.137753",
"asset": "USDC",
"token": "USDC",
"pendingDepositAmount": "0.000000",
"pendingWithdrawAmount": "0.000000",
"pendingTransferOutAmount": "0.000000",
"pendingTransferInAmount": "0.000000"
}
],
"positions": [
{
"token": "USDC",
"symbol": "BTC-USDC",
"status": "",
"side": "LONG",
"size": "0.000",
"entryPrice": "0.00",
"exitPrice": "",
"createdAt": 1690366452416,
"updatedTime": 1690366452416,
"fee": "0.000000",
"fundingFee": "0.000000",
"lightNumbers": "",
"customInitialMarginRate": "0"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
»» starkKey | string | true | none | User's starkKey |
»» positionId | string | true | none | User's account ID |
»» id | string | true | none | User's account ID |
»» makerFeeRate | string | true | none | Maker fee rate |
»» takerFeeRate | string | true | none | Taker fee rate |
»» createdAt | integer | true | none | Created time |
»» wallets | [object] | true | none | User wallet |
»»» userId | string | false | none | User ID |
»»» accountId | string | false | none | Account ID |
»»» asset | string | false | none | Asset |
»»» balance | string | false | none | Wallet balance |
»» pendingDepositAmount | string | true | none | Pending deposit amount |
»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | Side |
»» size | string | false | none | Size |
»» entryPrice | string | false | none | Entry price |
»» fee | string | false | none | Order fee |
»» createdAt | integer | false | none | Created at |
»» updatedTime | integer | false | none | Updated time |
»» fundingFee | string | false | none | Funding fee |
»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Account balance V2
GET /v2/account-balance
curl https://pro.apex.exchange/api/v2/account-balance -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
accountRes = client.get_account_balance()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"usdtBalance": {
"totalEquityValue": "100.000000",
"availableBalance": "100.000000",
"initialMargin": "100.000000",
"maintenanceMargin": "100.000000",
"symbolToOraclePrice": {
"BTC-USDC": {
"oraclePrice": "20000",
"createdTime": 124566
}
}
},
"usdcBalance": {
"totalEquityValue": "100.000000",
"availableBalance": "100.000000",
"initialMargin": "100.000000",
"maintenanceMargin": "100.000000",
"symbolToOraclePrice": {
"BTC-USDC": {
"oraclePrice": "20000",
"createdTime": 124566
}
}
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» usdtBalance | object | true | none | |
»» totalEquityValue | string | true | none | |
»» availableBalance | string | true | none | |
»» initialMargin | string | true | none | |
»» maintenanceMargin | string | true | none | |
»» symbolToOraclePrice | object | true | none | |
»»» BTC-USDC | object | true | none | |
»»»» oraclePrice | string | true | none | |
»»»» createdTime | integer | true | none | |
» usdcBalance | object | true | none | |
»» totalEquityValue | string | true | none | |
»» availableBalance | string | true | none | |
»» initialMargin | string | true | none | |
»» maintenanceMargin | string | true | none | |
»» symbolToOraclePrice | object | true | none | |
»»» BTC-USDC | object | true | none | |
»»»» oraclePrice | string | true | none | |
»»»» createdTime | integer | true | none |
GET Retrieve User Deposit Data V2
GET /v2/transfers
Please note, the currency is required to retrieve user deposit data.
curl https://pro.apex.exchange/api/v2/transfers?limit={limit}&page={page}¤cyId={currencyId}&chainIds={chainIds} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
transfersRes = client.transfers_v2(limit=100,page=0,currencyId="USDT",chainIds="1,5,13")
Deposit Status{
UNKNOWN_DEPOSIT_STATUS 0 // Unknown.
PENDING_L1_CREATING 1 // Deposit pending on L1, awaiting confirmation.
PENDING_RISK_CHECKING 2 // Confirmed, risk check in progress.
PENDING_CENSORING 3 // Risk check complete, awaiting verification.
SUCCESS 4 // Deposit success, your funds have been sent to your wallet. Awaiting L2 validation.
SUCCESS_L2_APPROVED 5 // L2 approved.
CANCELED 6 // L1 confirmation failure, deposit has been canceled.
FAILED_RISK_CHECK_FAILURE 7 // Deposit has failed due to failed risk check.
FAILED_CENSOR_FAILURE 8 // Deposit has failed due to inaccurate data, data entries have been rolled back.
FAILED_L2_REJECTED 9 // Deposit has failed due to failed L2 approval. Deposited funds have been removed from your account.
}
Withdrawal Status{
UNKNOWN_WITHDRAW_STATUS 0 // Unknown.
PENDING_RISK_CHECKING 1 // Risk check in progress.
PENDING_CENSORING 2 // Pending verification.
PENDING_L2_APPROVING 3 // Approved, awaiting L2 validation.
PENDING_L1_CONFIRMING 4 // L2 validation complete, pending L1 confirmation.
PENDING_L1_WITHDRAWING 5 // Withdrawal request on L1 complete, awaiting user withdrawal.
SUCCESS 6 // Withdrawal success, your withdrawn funds can now be found in your wallet.
FAILED_RISK_CHECK_FAILURE 7 // Withdrawal unsuccessful due to failed risk check.
FAILED_CENSOR_FAILURE 8 // Withdrawal unsuccessful due to inaccurate data, data entries have been rolled back.
FAILED_L2_REJECTED 9 // Withdrawal unsuccessful due to failed L2 approval and roll back has commenced.
}
Cross-Chain Withdrawal Status{
UNKNOWN_CROSS_WITHDRAW_STATUS 0 // Unknown.
PENDING_CROSS_WITHDRAW_CHECKING 1 // Pending chain verification.
SUCCESS_CROSS_WITHDRAW_SUBMIT_CENSOR 2
PENDING_CROSS_WITHDRAW__CENSOR_CHECKING_ACCOUNT 3 //
PENDING_CROSS_WITHDRAW_CENSORING 4 // Pending data verification.
PENDING_CROSS_WITHDRAW_L2_APPROVING 5 // Verification successful, awaiting L2 approval.
PENDING_CROSS_WITHDRAW_L1_SUBMIT 6 //Approved, submitting to L1.
PENDING_CROSS_WITHDRAW_L1_CONFIRMING 7 // L1 submission successful, pending L1 validation.
CROSS_WITHDRAW_SUCCESS 8 // Withdrawal successful.
FAILED_CROSS_WITHDRAW_TRANSFER_REJECTED 9 /Transfer rejected.
FAILED_CROSS_WITHDRAW__CENSOR_CHECKING_ACCOUNT_REJECTED 10 //Account verification rejected.
FAILED_CROSS_WITHDRAW_CENSORING 11 //Inaccurate validation data.
FAILED_CROSS_L2_REJECTED 12 // Transfer has failed. L2 validation rejection, roll back has commenced.
FAILED_CROSS_WITHDRAW_L1_SUBMIT_REJECTED 13
FAILED_CROSS_WITHDRAW_L1_REJECTED 14// Withdrawal request failed, L1 transfer unsuccessful.
}
Cross-Chain Deposit Status{
UNKNOWN_CROSS_DEPOSIT_STATUS 0 // Unknown.
PENDING_CROSS_DEPOSIT_L1_CREATING 1 // Deposit confirmed on L1, creating transaction.
PENDING_CROSS_DEPOSIT_L2_TRIGGER 2 // Awaiting trigger for transfer to L2.
PENDING_CROSS_DEPOSIT_CENSOR_CHECKING 3 // L1 deposit successful, awaiting transfer to L2.
SUCCESS_CROSS_DEPOSIT_SUBMIT_CENSOR 4
PENDING_CROSS_DEPOSIT_CENSOR_CHECKING_ACCOUNT 5 //
PENDING_CROSS_DEPOSIT_CENSORING 6 // Confirmed, verification in progress.
PENDING_CROSS_DEPOSIT_L2_APPROVING 7 // Pending L2 approval.
CROSS_DEPOSIT_SUCCESS 8 //Deposit successful.
FAILED_CROSS_DEPOSIT_TRANSFER_REJECTED 9 //Transfer rejected.
FAILED_CROSS_DEPOSIT_CENSOR_CHECKING_ACCOUNT_REJECTED 10 //User account error found.
CROSS_DEPOSIT_CENSORING 11 //Inaccurate validation data.
FAILED_CROSS_L2_REJECTED 12 // Transfer has failed. L2 validation rejection, roll back has commenced.
}
Fast Withdrawal Status{
UNKNOWN_FAST_WITHDRAW_STATUS 0 // Unknown.
PENDING_FAST_WITHDRAW_CHECKING 1 //Pending checks.
PENDING_FAST_WITHDRAW_SUBMIT 2 //Submitted for checking, creating txid.
PENDING_FAST_WITHDRAW_CHECKING_ACCOUNT 3 // PENDING_FAST_WITHDRAW_CENSORING 4 //Pending data verification.
PENDING_FAST_WITHDRAW_L1_SUBMIT 5 //Confirmed, awaiting send to L1 .
PENDING_FAST_WITHDRAW_L1_CONFIRMING 6 // Confirmed, pending L1 confirmation.
PENDING_FAST_WITHDRAW_CENSORING_CONFIRMING 7 //Pending verification, awaiting confirmation of transfer.
PENDING_FAST_WITHDRAW_L2_APPROVING 8 // Verification successful, pending L2 approval.
FAST_WITHDRAW_SUCCESS 9 // Withdrawal successful, your funds can be found in your wallet.
FAILED_FAST_WITHDRAW_TRANSFER_REJECTED 10 //Transfer rejected.
FAILED_FAST_WITHDRAW_CHECKING_ACCOUNT_REJECTED 11 //User account error found.
FAILED_FAST_WITHDRAW_CENSORING 12 //Inaccurate validation data.
FAILED_FAST_WITHDRAW_L1_SUBMIB_REJECTED 13 // Withdrawal has failed, unsuccessful transfer to L1.
FAILED_FAST_WITHDRAW_L1_REJECTED 14 // Withdrawal unsuccessful, request rejected on L1.
FAILED_FAST_WITHDRAW_L2_REJECTED 15 // L2 validation rejection, roll back has commenced.
PENDING_L1_WITHDRAWING 16 // Status: Click for withdrawal smart contract.
}
Request Parameters
Parameters | Position | Type | Required | Comments |
---|---|---|---|---|
limit | query | integer | false | Page limit default at 100 |
page | query | integer | false | Page numbers start from 0 |
currencyId | query | string | true | Filter to show only currency ID, all will be searched if the field is empty |
beginTimeInclusive | query | integer | false | Start time |
endTimeExclusive | query | string | false | End time |
chainIds | query | string | false | Check for multiple chainID records, separated by commas |
transferType | query | string | false | Check for multiple transferType records, separated by commas |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"transfers": [
{
"id": "foo",
"type": "DEPOSIT",
"currencyId": "USDC",
"amount": "3000",
"transactionHash": "0x12aaaaaaaa",
"status": "PENDING",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"confirmedAt": 1647502440973,
"clientId": "12345",
"confirmedCount": 12,
"requiredCount": 12,
"orderId": "12345",
"chainId": "1",
"fee": "10.0"
}
],
"totalSize": 123
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» transfers | [object] | true | none | none |
»» id | string | false | none | none |
»» type | string | false | none | DEPOSIT, WITHDRAW or FAST_WITHDRAW |
»» CurrencyId | string | false | none | Currency ID |
»» Amount | string | false | none | Amount |
»» transactionHash | string | false | none | Transaction hash |
»» status | string | false | none | Status |
»» createdAt | integer | false | none | Created at |
»» confirmedAt | integer | false | none | Confirmed time (only for withdrawals) |
»» updatedTime | string | true | none | Only applicable for deposits |
»» confirmedCount | string | true | none | Number of confirmations on L1, only for deposits |
»» requiredCount | string | true | none | Number of confirmations required for deposits on L1, only for deposits |
»» clientId | string | false | none | Client to create a randomized id (only for withdrawal) |
»» orderId | string | true | none | Success Wallet Transaction Id |
»» chainId | string | true | none | Supported chainId |
»» fee | string | true | none | Fee |
» totalSize | string | true | none | Total size |
GET Retrieve User Withdrawal List V2
GET /v2/withdraw-list
Please note, the token is required to retrieve the user withdrawal list.
curl https://pro.apex.exchange/api/v2/withdraw-list?limit={limit}&page={page}&beginTimeInclusive={beginTimeInclusive}&endTimeExclusive={endTimeExclusive} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
withdrawListRes = client.withdraw_list(limit=100,page=0,beginTimeInclusive=1651406864000,endTimeExclusive=1657105971171)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
limit | query | integer | false | Page limit default at 100 |
page | query | integer | false | Page numbers start from 0 |
beginTimeInclusive | query | integer | false | Start time |
endTimeExclusive | query | string | false | End time |
transferType | query | string | false | Check for multiple transferType records, separated by commas |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"transfers": [
{
"id": "foo",
"type": "WITHDRAW",
"currencyId": "USDC",
"amount": "3000",
"transactionHash": "0x12aaaaaaaa",
"status": "PENDING_L2_APPROVING",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"confirmedAt": 1647502440973,
"clientId": "12345",
"orderId": "12345",
"chainId": "1",
"fee": "10.0"
}
],
"totalSize": 123
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» transfers | [object] | true | none | none |
»» id | string | false | none | none |
»» type | string | false | none | DEPOSIT, WITHDRAW or FAST_WITHDRAW |
»» CurrencyId | string | false | none | Currency ID |
»» Amount | string | false | none | Amount |
»» transactionHash | string | false | none | Transaction hash |
»» status | string | false | none | Status |
»» createdAt | integer | false | none | Created at |
»» confirmedAt | integer | false | none | Confirmed time (only for withdrawals) |
»» updatedTime | string | false | none | Only applicable for deposits |
»» confirmedCount | string | false | none | Number of confirmations on L1, only for deposits |
»» requiredCount | string | false | none | Number of confirmations required for deposits on L1, only for deposits |
»» clientId | string | false | none | client create the Randomized id (only for withdrawal) |
»» orderId | string | true | none | Success Wallet Transaction Id |
»» chainId | string | false | none | Supported chainId |
»» fee | string | false | none | Fee |
»» withdrawStatus | string | false | none | PENDING_L2_APPROVING,SUCCESS : Withdrawal status, search for multiple statuses separated by commas |
» totalSize | string | true | none | none |
POST User Withdrawal V2
POST /v2/create-withdrawal
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
};
example
curl https://pro.apex.exchange/api/v2/create-withdrawal -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createWithdrawRes = client.create_withdrawal_v2(amount='1001',expirationEpochSeconds=currentTime,asset='USDT')
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset (in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
Successful Response Generation
{
"id": "1234455",
"type": "WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | id |
» type | string | true | none | type |
POST User Withdrawal to Designated Address V2
POST /v2/create-withdrawal-to-address
Transfer funds from L1 to a designated Ethereum address without the need to register for a corresponding StarkKey associated with the Ethereum address.
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
ethAddress,
};
example
curl https://pro.apex.exchange/api/v2/create-withdrawal -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createWithdrawRes = client.create_withdrawal_v2(amount='1001',expirationEpochSeconds=currentTime,asset='USDT',ethAddress="0x***")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | Request signature | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Withdraw Amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset(in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
» ethAddress | body | string | false | Withdraw only to your registered Ethereum address. |
Successful Response Generation
{
"id": "1234455",
"type": "WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | none |
» type | string | true | none | Withdrawal type |
POST User Fast Withdrawal V2
POST /v2/fast-withdraw
fact = this.starkLib.factRegistry.getTransferErc20Fact({
recipient: toEthAddress,
tokenAddress: usdcAddress,
tokenDecimals: 6,
humanAmount: params.Amount,
salt: nonceFromClientId(clientId),
});
const transferToSign = {
senderPositionId: accountId,
receiverPositionId: fastWithdrawAccountId,
receiverPublicKey: fastWithdrawL2Key,
factRegistryAddress: fastWithdrawFactRegisterAddress,
fact,
humanAmount: params.amount,
clientId,
expirationIsoTimestamp: params.expiration,
};
example
curl https://pro.apex.exchange/api/v2/fast-withdraw -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}&erc20Address={erc20Address}&fee={fee}&lpAccountId={lpAccountId}&chainId={chainId}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
feeRes = client.uncommon_withdraw_fee_v2(amount='1002',chainId='56', token='USDT')
fastWithdrawRes = client.fast_withdrawal_v2(amount='1002',expirationEpochSeconds=currentTime,asset='USDT',fee=feeRes['data']['fee'])
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | false | Withdrawal amount |
» clientId | body | string | false | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | false | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | false | Asset(in USDC) being withdrawn. |
» signature | body | string | false | The signature for the transfer, signed with the account's STARK private key. |
» erc20Address | body | string | false | USDC address |
» fee | body | string | false | Fees |
» chainId | body | string | true | chainId |
» lpAccountId | body | string | false | Attach documents to retrieve fast_withdraw_account_id |
Successful Response Generation
{
"id": "1234455",
"type": "FAST_WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | id |
» type | string | true | none | type |
POST Cross-Chain Withdrawals V2
POST /v2/cross-chain-withdraw
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
fee
};
example
curl https://pro.apex.exchange/api/v2/cross-chain-withdraw -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}&erc20Address={erc20Address}&fee={fee}&lpAccountId={lpAccountId}&chainId={chainId}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
feeRes = client.uncommon_withdraw_fee(amount='1003',chainId='56', token='USDT')
crossWithdrawRes = client.cross_chain_withdraw(amount='1003',expirationEpochSeconds= currentTime,asset='USDT',fee=feeRes['data']['fee'],chainId='56')
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Withdrawal amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset(in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
» erc20Address | body | string | true | USDC address |
» chainId | body | string | true | Randomized clientId |
» fee | body | string | true | Fees |
» lpAccountId | body | string | true | Attach documents to retrieve fast_withdraw_account_id |
Successful Response Generation
{
"id": "1234455",
"type": "CROSS_WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | none |
» type | string | true | none | Withdrawal type |
GET Fast & Cross-Chain Withdrawal Fees V2
GET /v2/uncommon-withdraw-fee
curl https://pro.apex.exchange/api/v2/uncommon-withdraw-fee?amount={amount}&chainId={chainId}&token=USDC -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
feeRes = client.uncommon_withdraw_fee(amount='1003',chainId='56', token='USDT')
Request Parameters
Please note, the token is required to request parameters.
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
amount | query | string | false | USDC |
chainId | query | string | false | chainId |
token | query | string | true | USDC USDT |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"fee": "1.1",
"poolAvailableAmount": "10"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» fee | string | true | none | Fees calculated |
» poolAvailableAmount | string | true | none | Available balance in pool |
GET Withdrawal & Transfer Limits V2
GET /v2/transfer-limit
curl https://pro.apex.exchange/api/v1/transfer-limit?currencyId=USDC -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
transfer_limitRes = client.transfer_limit(currencyId="USDC")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
currencyId | query | string | true | USDC |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"withdrawAvailableAmount": "100.1",
"transferAvailableAmount": "100.1"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» withdrawAvailableAmount | string | true | none | Withdraw available amount |
» transferAvailableAmount | string | true | none | Transfer available amount |
GET Trade History
GET /v2/fills
Please note, the token is required to retrieve a trade history.
curl https://pro.apex.exchange/api/v2/fills?limit=100&page=0&symbol=BTC-USDC&side=BUY&token=USDC -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
fillsRes = client.fills_v2(limit=100,page=0,symbol="BTC-USDC",side="BUY")
Order Type
"UNKNOWN_ORDER_TYPE"
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | Symbol |
token | query | string | true | USDC USDT |
side | query | string | false | BUY or SELL |
limit | query | string | false | default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | orderType |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | Total order size |
GET Worst Price V2
GET /v2/get-worst-price
Obtain the market price from the order book.
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | Symbol |
size | query | string | true | Order open size |
side | query | string | true | BUY or SELL order |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"worstPrice": "123.00",
"bidOnePrice": "123.00",
"askOnePrice": "123.00"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» worstPrice | string | true | none | Lowest price |
» bidOnePrice | string | true | none | Bid price |
» askOnePrice | string | true | none | Ask price |
POST Creating Orders V2
POST /v2/create-order
Signature content:
orderToSign:
OrderWithClientId = {
humanSize: params.size,
humanPrice: params.price,
limitFee: params.limitFee,
symbol: params.symbol,
side: params.side,
expirationIsoTimestamp: params.expiration,
clientOrderId,
positionId, };
TimeInForce (
GOOD_TIL_CANCEL // Effective until canceled, default.
FILL_OR_KILL // Immediately and completely filled or canceled.
IMMEDIATE_OR_CANCEL // Immediately executed or canceled.
)
example
curl https://pro.apex.exchange/api/v2/create-order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={symbol}&side={side}&type={type}&size={size}&price={price}&limitFee={limitFee}&expiration={expiration}&timeInForce={timeInForce}&triggerPrice={triggerPrice}&trailingPercent={trailingPercent}&clientOrderId={clientOrderId}&signature={signature}&reduceOnly=false'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createOrderRes = client.create_order_v2(symbol="BTC-USDC", side="BUY",
type="LIMIT", size="0.01",
price="20001", limitFee="0.001",
accountId="330547708362228116",reduceOnly=False,
expirationEpochSeconds= currentTime, timeInForce="GOOD_TIL_CANCEL")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | Symbol |
» side | body | string | true | BUY or SELL |
» type | body | string | true | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT", "TAKE_PROFIT_MARKET" |
» size | body | string | true | Size |
» price | body | string | true | Price |
» limitFee | body | string | true | limitFee = price * size * takerFeeRate( from GET /v1/account) |
» expiration | body | string | true | Order expiry time |
» timeInForce | body | string | false | "GOOD_TIL_CANCEL", "FILL_OR_KILL", "IMMEDIATE_OR_CANCEL", "POST_ONLY" |
» triggerPrice | body | string | false | Trigger price |
» trailingPercent | body | string | false | Conditional order trailing-stop |
» clientOrderId | body | string | true | Randomized client id |
» signature | body | string | true | starkKey signature |
» reduceOnly | body | string | false | Reduce-only |
Successful Response Generation
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel Order V2
POST /v2/delete-order
curl https://pro.apex.exchange/api/v2/delete-order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}&token={USDC}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrderRes = client.delete_order(id="123456",token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | true | none |
» token | body | string | true | USDT or USDC |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
POST Cancel Order By ClientOrderId
POST /v2/delete-client-order-id
curl https://pro.apex.exchange/api/v2/delete-client-order-id` -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrderRes = client.delete_order_by_client_order_id_v2(id="123456",token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | true | none |
» token | body | string | true | USDT or USDC |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
GET Open Orders V2
GET /v2/open-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://pro.apex.exchange/api/v2/open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
openOrdersRes = client.open_orders_v2(token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT or USDC |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"data": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USDT",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel all Open Orders V2
POST /v2/delete-open-orders
Body Request Parameters
symbol: BTC-USDC,ETH-USDC
token: USDC
curl https://pro.apex.exchange/api/v2/delete-open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={BTC-USDC,ETH-USDC}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrdersRes = client.delete_open_orders_v2(symbol="BTC-USDC,ETH-USDC", token="USDC")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | false | "BTC-USDC,ETH-USDC", Cancel all orders if none |
» token | body | string | true | USDT or USDC |
Successful Response Generation
{
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
GET All Order History V2
GET /v2/history-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://pro.apex.exchange/api/v2/history-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historyOrdersRes = client.history_orders_v2(token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT or USDC |
symbol | query | string | false | none |
status | query | string | false | none |
side | query | string | false | BUY or SELL |
type | query | string | false | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT","TAKE_PROFIT_MARKET" |
limit | query | string | false | default 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | "ACTIVE","CONDITION","HISTORY" |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | total order size |
GET Order ID V2
GET /v2/get-order
curl https://pro.apex.exchange/api/v2/get-order?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
getOrderRes = client.get_order_v2(id="123456",token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
token | query | string | true | USDT or USDC |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USDT",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Order by clientOrderId V2
GET /v2/order-by-client-order-id"
curl https://pro.apex.exchange/api/v2/order-by-client-order-id?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
getOrderRes = client.get_order_by_client_order_id_v2(id="123456",token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
token | query | string | true | USDC or USDT |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Funding Rate V2
GET /v2/funding
curl https://pro.apex.exchange/api/v2/funding?limit={limit}&page={page}&symbol={symbol}&side={side}&token={token} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
fundingRes = client.funding_v2(limit=100,page=0,symbol="BTC-USDC",side="BUY", token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | none |
token | query | string | true | USDT or USDC |
limit | query | string | false | Default at 100 |
page | query | string | false | Page numbers start from 0 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
side | query | string | false | Side |
status | query | string | false | Order status |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"fundingValues": [
{
"id": "1234",
"symbol": "BTC-USD",
"fundingValue": "10000",
"rate": "0.0000125000",
"positionSize": "500",
"price": "90",
"side": "LONG",
"status": "SUCCESS",
"fundingTime": 1647502440973,
"transactionId": "1234556"
}
],
"totalSize": 11
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» fundingValues | [object] | true | none | none |
»» id | string | false | none | id |
»» symbol | string | false | none | Symbol |
»» fundingValue | string | false | none | Funding fee value |
»» rate | string | false | none | Funding rate |
»» positionSize | string | false | none | Open position size |
»» price | string | false | none | Symbol price |
»» side | string | false | none | Position side |
»» status | string | false | none | Position funding status |
»» fundingTime | integer | false | none | Funding fee time |
»» transactionId | string | false | none | Successful wallet transaction ID |
» totalSize | integer | true | none | Total size |
GET User Historial Profit and Loss V2
GET /v2/historical-pnl
curl https://pro.apex.exchange/api/v1/historical-pnl?limit={limit}&page={page}&beginTimeInclusive={beginTimeInclusive}&endTimeExclusive={endTimeExclusive}&type={type}&symbol={symbol}&token={token} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historicalPnlRes = client.historical_pnl_v2(limit=100,page=0,beginTimeInclusive=1651406864000,endTimeExclusive=1657105971171,symbol="BTC-USDC", token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT or USDC |
beginTimeInclusive | query | string | false | StartTime |
endTimeExclusive | query | string | false | EndTime |
type | query | string | false | Position type |
symbol | query | string | false | Symbol |
page | query | string | false | Page numbers start from 0 |
limit | query | string | false | Default at 100 |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historicalPnl": [
{ "symbol": "BTC-USDC",
"size": "1.0000",
"totalPnl": "1.0000",
"price": "1.0000",
"createdAt": 1647502440973,
"type": "CLOSE_POSITION",
"isLiquidate": false,
"isDeleverage": false
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
» historicalPnl | [object] | true | none | none |
»» size | string | false | none | Size |
»» totalPnl | string | false | none | Closing profit and loss |
»» price | string | false | none | Price |
»» exitPrice | string | false | none | Closing price |
»» createdAt | integer | false | none | Time |
»» type | string | false | none | postion type |
»» isLiquidate | boolean | false | none | Liquidate |
»» isDeleverage | boolean | false | none | ADL |
» totalSize | integer | true | none | none |
GET Yesterday's Profit & Loss V2
GET /v2/yesterday-pnl
curl https://pro.apex.exchange/api/v2/yesterday-pnl?token={token} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
yesterdayPnlRes = client.yesterday_pnl_v2()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT or USDC |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"data": "11.11"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Profit and loss value |
GET Historical Asset Value
GET /v2/history-value
curl https://pro.apex.exchange/api/v2/history-value?token={token} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historyValueRes = client.history_value_v2(token="USDT")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
token | query | string | true | USDT or USDC |
endTime | query | int64 | false | Start time |
startTime | query | int64 | false | End time |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historyValues": [
{
"accountTotalValue": "123.11",
"dateTime": 1651406864000
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» historyValues | [object] | true | none | none |
»» accountTotalValue | string | false | none | Assets |
»» dateTime | integer | false | none | Assets date and time snapshot |
POST Sets the initial margin rate of a contract V2
POST /v2/set-initial-margin-rate
curl https://pro.apex.exchange/api/v2/set-initial-margin-rate?symbol={symbol}&initialMarginRate={initialMarginRate} -H "Content-Type: application/x-www-form-urlencoded" -H "APEX-SIGNATURE: ***" -H "APEX-TIMESTAMP: ***" -H "APEX-API-KEY: ***" -H "APEX-PASSPHRASE: ***" -X POST -d "symbol=BTC-USDC&initialMarginRate=0.02"
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
setInitialMarginRateRes = client.set_initial_margin_rate_v2(symbol="BTC-USDT",initialMarginRate="0.1")
print(setInitialMarginRateRes)
Body
symbol: string
initialMarginRate: string
token: string
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | symbol |
» initialMarginRate | body | string | true | initialMarginRate(the reciprocal of the opening leverage) |
Successful Response Generation
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
PrivateApi
v1.0.0
POST Generate nonce
POST /v1/generate-nonce
Generate and obtain nonce before registration. The nonce is used to assemble the signature field upon registration.
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0x*****")
configs = client.configs()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="5")
curl https://pro.apex.exchange/api/v1/generate-nonce -X POST -d 'starkKey={starkKey}ðAddress={ethAddress}&chainId={chainId}'
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
body | body | object | false | none |
» starkKey | body | string | true | User's starkKey |
» ethAddress | body | string | true | User's Ethereum address |
» chainId | body | string | true | API trading users to enter "1" on mainnet |
Successful Response Generation
{
"data": {
"nonce": "1123940951220551680",
"nonceExpired": 1648727402292
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» nonce | string | true | none | nonce |
» nonceExpired | integer | true | none | The time at which nonce expires, please complete registration before this time |
POST Registration & Onboarding
POST /v1/onboarding
- Consolidate onboarding data and generate digital signature via your wallet. You can refer to python sdk, derive_stark_key for more information
- Create your Stark Key pair with your signature, including (publicKey, publicKeyYCoordinate, privateKey)
- Send consolidated onboarding data request to the server for response to user registration data, including API keys
curl https://pro.apex.exchange/api/v1/onboarding -H 'APEX-SIGNATURE: ***' -H 'APEX-ETHEREUM-ADDRESS: ***' -X POST -d 'starkKey={starkKey}&starkKeyYCoordinate={starkKeyYCoordinate}ðereumAddress={ethereumAddress}&referredByAffiliateLink={referredByAffiliateLink}&country={country}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key="0xb7daaaaaaaaaaaaaaaa")
configs = client.configs()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId="5")
regRes = client.register_user(nonce=nonceRes['data']['nonce'],starkKey=stark_key_pair_with_y_coordinate['public_key'],stark_public_key_y_coordinate=stark_key_pair_with_y_coordinate['public_key_y_coordinate'],ethereum_address=client.default_address)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Onboarding signature |
APEX-ETHEREUM-ADDRESS | header | string | true | Ethereum address |
body | body | object | false | none |
» starkKey | body | string | true | Public starkKey associated with the key-pair you created. |
» starkKeyYCoordinate | body | string | true | Public starkKey Y-Coordinate associated with the key-pair you created. |
» ethereumAddress | body | string | true | Ethereum address associated with the user being created. |
» referredByAffiliateLink | body | string | false | Referred affiliate link |
» country | body | string | false | Country code: Must be ISO 3166-1 Alpha-2 compliant |
Successful Response Generation
{
"apiKey": {
"key": "290xxxxxx",
"passphrase": "S6xxxxx",
"secret": "KQ3xxxx"
},
"user": {
"ethereumAddress": "0x09xxxxxx",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "man",
"referredByAffiliateLink": "url",
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
},
"account": {
"starkKey": "180913017c740260fea4b2c62828a4008ca8b0d6e4",
"positionId": "1812",
"id": "1812",
"takerFeeRate": "0.0005",
"makerFeeRate": "0.0005",
"createdAt": 1647502440973,
"wallets": [
{
"userId": "123456",
"accountId": "123455667",
"asset": "USDC",
"balance": "1000",
"pendingDepositAmount": "100.1",
"pendingWithdrawAmount": "100.1",
"pendingTransferOutAmount": "100.1",
"pendingTransferInAmount": "100.1"
}
],
"openPositions": [
{
"symbol": "BTC-USD",
"side": "LONG",
"size": "1000",
"entryPrice": "100",
"fee": "50",
"fundingFee": "100",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"lightNumbers": "1"
}
],
"id": "id"
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» apiKey | object | true | none | none |
»» key | string | true | none | Placed in request header for sending to server |
»» passphrase | string | true | none | Placed in request header for sending to server |
»» secret | string | true | none | Used to generate signature |
» user | object | true | none | none |
»» ethereumAddress | string | true | none | Ethereum address |
»» isRegistered | boolean | true | none | Registration confirmation |
string | true | none | ||
»» username | string | true | none | Username |
»» referredByAffiliateLink | string | true | none | referred Affiliate Link |
»» isEmailVerified | boolean | true | none | Email binding confirmation |
»» emailNotifyGeneralEnable | boolean | true | none | Newsletter, Market Updates, Product notify |
»» emailNotifyTradingEnable | boolean | true | none | Deposits、Withdrawals, Account notify |
»» emailNotifyAccountEnable | boolean | true | none | Order and Liquidation notify |
»» popupNotifyTradingEnable | boolean | true | none | Trading pop-up notify |
» account | object | true | none | none |
»» starkKey | string | true | none | User's starkKey |
»» positionId | string | true | none | User's account ID |
»» id | string | true | none | User's account ID |
»» makerFeeRate | string | true | none | Maker fee rate |
»» takerFeeRate | string | true | none | Taker fee rate |
»» createdAt | integer | true | none | Created time |
»» wallets | [object] | true | none | User wallet |
»»» userId | string | false | none | User ID |
»»» accountId | string | false | none | Account ID |
»»» asset | string | false | none | Asset |
»»» balance | string | false | none | Wallet balance |
»» pendingDepositAmount | string | true | none | Pending deposit amount |
»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | Side |
»» size | string | false | none | Size |
»» entryPrice | string | false | none | Entry price |
»» fee | string | false | none | Order fee |
»» createdAt | integer | false | none | Created at |
»» updatedTime | integer | false | none | Updated time |
»» fundingFee | string | false | none | Funding fee |
»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Data
GET /v1/user
curl https://pro.apex.exchange/api/v1/user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
userRes = client.get_user()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
POST Edit User Data
POST /v1/modify-user
curl https://pro.apex.exchange/api/v1/modify-user -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'userData={userData}&email={email}&username={username}&isSharingUsername={isSharingUsername}&isSharingAddress={isSharingAddress}&country={country}&emailNotifyGeneralEnable={emailNotifyGeneralEnable}&emailNotifyTradingEnable={emailNotifyTradingEnable}&emailNotifyAccountEnable={emailNotifyAccountEnable}&popupNotifyTradingEnable={popupNotifyTradingEnable}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
userRes = client.modify_user(username="pythonTest",email="11@aa.com",emailNotifyGeneralEnable="true")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» userData | body | string | false | none |
body | string | false | ||
» username | body | string | false | Username |
» isSharingUsername | body | string | false | none |
» isSharingAddress | body | string | false | none |
» country | body | string | false | country |
» emailNotifyGeneralEnable | body | string | false | Newsletter, market and product updates |
» emailNotifyTradingEnable | body | string | false | Order and liquidation updates |
» emailNotifyAccountEnable | body | string | false | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | body | string | false | Enable trading notifications |
Successful Response Generation
{
"ethereumAddress": "0x091aaaaaaaaaa",
"isRegistered": true,
"email": "email@apex.exchange",
"username": "supersam15o",
"userData": {},
"isEmailVerified": false,
"emailNotifyGeneralEnable": false,
"emailNotifyTradingEnable": false,
"emailNotifyAccountEnable": false,
"popupNotifyTradingEnable": false
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» ethereumAddress | string | true | none | Ethereum address |
» isRegistered | boolean | true | none | Registration completed |
string | true | none | ||
» username | string | true | none | Username |
» userData | object | true | none | none |
» isEmailVerified | boolean | true | none | none |
» emailNotifyGeneralEnable | string | true | none | Newsletter, market and product updates |
» emailNotifyTradingEnable | string | true | none | Order and liquidation updates |
» emailNotifyAccountEnable | string | true | none | Deposit, withdrawal and account updates |
» popupNotifyTradingEnable | string | true | none | Enable trading notifications |
GET Retrieve User Account Data
GET /v1/account
Get an account for a user by id. Using the client, the id will be generated with client information and an Ethereum address.
curl https://pro.apex.exchange/api/v1/account -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
accountRes = client.get_account()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"starkKey": "180913017c740260fea4b2c62828a4008ca8b0d6e4",
"positionId": "1812",
"takerFeeRate": "0.0005",
"makerFeeRate": "0.0005",
"createdAt": 1647502440973,
"wallets": [
{
"userId": "123456",
"accountId": "123455667",
"asset": "USDC",
"balance": "1000",
"pendingDepositAmount": "100.1",
"pendingWithdrawAmount": "100.1",
"pendingTransferOutAmount": "100.1",
"pendingTransferInAmount": "100.1"
}
],
"openPositions": [
{
"symbol": "BTC-USD",
"side": "LONG",
"size": "1000",
"entryPrice": "100",
"fee": "50",
"fundingFee": "100",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"lightNumbers": "1"
}
],
"id": "id"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
»» starkKey | string | true | none | User's starkKey |
»» positionId | string | true | none | User's account ID |
»» id | string | true | none | User's account ID |
»» makerFeeRate | string | true | none | Maker fee rate |
»» takerFeeRate | string | true | none | Taker fee rate |
»» createdAt | integer | true | none | Created time |
»» wallets | [object] | true | none | User wallet |
»»» userId | string | false | none | User ID |
»»» accountId | string | false | none | Account ID |
»»» asset | string | false | none | Asset |
»»» balance | string | false | none | Wallet balance |
»» pendingDepositAmount | string | true | none | Pending deposit amount |
»» pendingWithdrawAmount | string | true | none | Pending withdrawal amount |
»» pendingTransferOutAmount | string | true | none | Pending outbound transfer amount |
»» pendingTransferInAmount | string | true | none | Pending inbound transfer amount |
»» openPositions | [object] | true | none | Open positions |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | Side |
»» size | string | false | none | Size |
»» entryPrice | string | false | none | Entry price |
»» fee | string | false | none | Order fee |
»» createdAt | integer | false | none | Created at |
»» updatedTime | integer | false | none | Updated time |
»» fundingFee | string | false | none | Funding fee |
»» lightNumbers | string | false | none | ADL ranking |
GET Retrieve User Account balance
GET /v1/account-balance
curl https://pro.apex.exchange/api/v1/account-balance -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
accountRes = client.get_account_balance()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"totalEquityValue": "100.000000",
"availableBalance": "100.000000",
"initialMargin": "100.000000",
"maintenanceMargin": "100.000000",
"symbolToOraclePrice": {
"BTC-USDC": {
"oraclePrice": "20000",
"createdTime": 124566
}
}
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» totalEquityValue | string | true | none | |
» availableBalance | string | true | none | |
» initialMargin | string | true | none | |
» maintenanceMargin | string | true | none | |
» symbolToOraclePrice | object | true | none | |
»» BTC-USDC | object | true | none | |
»»» oraclePrice | string | true | none | |
»»» createdTime | integer | true | none |
GET Retrieve User Deposit Data
GET /v1/transfers
curl https://pro.apex.exchange/api/v1/transfers?limit={limit}&page={page}¤cyId={currencyId}&chainIds={chainIds} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
transfersRes = client.transfers(limit=100,page=0,currencyId="USDC",chainIds="1,5,13")
Deposit Status{
UNKNOWN_DEPOSIT_STATUS 0 // Unknown.
PENDING_L1_CREATING 1 // Deposit pending on L1, awaiting confirmation.
PENDING_RISK_CHECKING 2 // Confirmed, risk check in progress.
PENDING_CENSORING 3 // Risk check complete, awaiting verification.
SUCCESS 4 // Deposit success, your funds have been sent to your wallet. Awaiting L2 validation.
SUCCESS_L2_APPROVED 5 // L2 approved.
CANCELED 6 // L1 confirmation failure, deposit has been canceled.
FAILED_RISK_CHECK_FAILURE 7 // Deposit has failed due to failed risk check.
FAILED_CENSOR_FAILURE 8 // Deposit has failed due to inaccurate data, data entries have been rolled back.
FAILED_L2_REJECTED 9 // Deposit has failed due to failed L2 approval. Deposited funds have been removed from your account.
}
Withdrawal Status{
UNKNOWN_WITHDRAW_STATUS 0 // Unknown.
PENDING_RISK_CHECKING 1 // Risk check in progress.
PENDING_CENSORING 2 // Pending verification.
PENDING_L2_APPROVING 3 // Approved, awaiting L2 validation.
PENDING_L1_CONFIRMING 4 // L2 validation complete, pending L1 confirmation.
PENDING_L1_WITHDRAWING 5 // Withdrawal request on L1 complete, awaiting user withdrawal.
SUCCESS 6 // Withdrawal success, your withdrawn funds can now be found in your wallet.
FAILED_RISK_CHECK_FAILURE 7 // Withdrawal unsuccessful due to failed risk check.
FAILED_CENSOR_FAILURE 8 // Withdrawal unsuccessful due to inaccurate data, data entries have been rolled back.
FAILED_L2_REJECTED 9 // Withdrawal unsuccessful due to failed L2 approval and roll back has commenced.
}
Cross-Chain Withdrawal Status{
UNKNOWN_CROSS_WITHDRAW_STATUS 0 // Unknown.
PENDING_CROSS_WITHDRAW_CHECKING 1 // Pending chain verification.
SUCCESS_CROSS_WITHDRAW_SUBMIT_CENSOR 2
PENDING_CROSS_WITHDRAW__CENSOR_CHECKING_ACCOUNT 3 //
PENDING_CROSS_WITHDRAW_CENSORING 4 // Pending data verification.
PENDING_CROSS_WITHDRAW_L2_APPROVING 5 // Verification successful, awaiting L2 approval.
PENDING_CROSS_WITHDRAW_L1_SUBMIT 6 //Approved, submitting to L1.
PENDING_CROSS_WITHDRAW_L1_CONFIRMING 7 // L1 submission successful, pending L1 validation.
CROSS_WITHDRAW_SUCCESS 8 // Withdrawal successful.
FAILED_CROSS_WITHDRAW_TRANSFER_REJECTED 9 /Transfer rejected.
FAILED_CROSS_WITHDRAW__CENSOR_CHECKING_ACCOUNT_REJECTED 10 //Account verification rejected.
FAILED_CROSS_WITHDRAW_CENSORING 11 //Inaccurate validation data.
FAILED_CROSS_L2_REJECTED 12 // Transfer has failed. L2 validation rejection, roll back has commenced.
FAILED_CROSS_WITHDRAW_L1_SUBMIT_REJECTED 13
FAILED_CROSS_WITHDRAW_L1_REJECTED 14// Withdrawal request failed, L1 transfer unsuccessful.
}
Cross-Chain Deposit Status{
UNKNOWN_CROSS_DEPOSIT_STATUS 0 // Unknown.
PENDING_CROSS_DEPOSIT_L1_CREATING 1 // Deposit confirmed on L1, creating transaction.
PENDING_CROSS_DEPOSIT_L2_TRIGGER 2 // Awaiting trigger for transfer to L2.
PENDING_CROSS_DEPOSIT_CENSOR_CHECKING 3 // L1 deposit successful, awaiting transfer to L2.
SUCCESS_CROSS_DEPOSIT_SUBMIT_CENSOR 4
PENDING_CROSS_DEPOSIT_CENSOR_CHECKING_ACCOUNT 5 //
PENDING_CROSS_DEPOSIT_CENSORING 6 // Confirmed, verification in progress.
PENDING_CROSS_DEPOSIT_L2_APPROVING 7 // Pending L2 approval.
CROSS_DEPOSIT_SUCCESS 8 //Deposit successful.
FAILED_CROSS_DEPOSIT_TRANSFER_REJECTED 9 //Transfer rejected.
FAILED_CROSS_DEPOSIT_CENSOR_CHECKING_ACCOUNT_REJECTED 10 //User account error found.
CROSS_DEPOSIT_CENSORING 11 //Inaccurate validation data.
FAILED_CROSS_L2_REJECTED 12 // Transfer has failed. L2 validation rejection, roll back has commenced.
}
Fast Withdrawal Status{
UNKNOWN_FAST_WITHDRAW_STATUS 0 // Unknown.
PENDING_FAST_WITHDRAW_CHECKING 1 //Pending checks.
PENDING_FAST_WITHDRAW_SUBMIT 2 //Submitted for checking, creating txid.
PENDING_FAST_WITHDRAW_CHECKING_ACCOUNT 3 // PENDING_FAST_WITHDRAW_CENSORING 4 //Pending data verification.
PENDING_FAST_WITHDRAW_L1_SUBMIT 5 //Confirmed, awaiting send to L1 .
PENDING_FAST_WITHDRAW_L1_CONFIRMING 6 // Confirmed, pending L1 confirmation.
PENDING_FAST_WITHDRAW_CENSORING_CONFIRMING 7 //Pending verification, awaiting confirmation of transfer.
PENDING_FAST_WITHDRAW_L2_APPROVING 8 // Verification successful, pending L2 approval.
FAST_WITHDRAW_SUCCESS 9 // Withdrawal successful, your funds can be found in your wallet.
FAILED_FAST_WITHDRAW_TRANSFER_REJECTED 10 //Transfer rejected.
FAILED_FAST_WITHDRAW_CHECKING_ACCOUNT_REJECTED 11 //User account error found.
FAILED_FAST_WITHDRAW_CENSORING 12 //Inaccurate validation data.
FAILED_FAST_WITHDRAW_L1_SUBMIB_REJECTED 13 // Withdrawal has failed, unsuccessful transfer to L1.
FAILED_FAST_WITHDRAW_L1_REJECTED 14 // Withdrawal unsuccessful, request rejected on L1.
FAILED_FAST_WITHDRAW_L2_REJECTED 15 // L2 validation rejection, roll back has commenced.
PENDING_L1_WITHDRAWING 16 // Status: Click for withdrawal smart contract.
}
Request Parameters
Parameters | Position | Type | Required | Comments |
---|---|---|---|---|
limit | query | integer | false | Page limit default at 100 |
page | query | integer | false | Page numbers start from 0 |
currencyId | query | string | false | Filter to show only currency ID, all will be searched if the field is empty |
beginTimeInclusive | query | integer | false | Start time |
endTimeExclusive | query | string | false | End time |
chainIds | query | string | false | Check for multiple chainID records, separated by commas |
transferType | query | string | false | Check for multiple transferType records, separated by commas |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"transfers": [
{
"id": "foo",
"type": "DEPOSIT",
"currencyId": "USDC",
"amount": "3000",
"transactionHash": "0x12aaaaaaaa",
"status": "PENDING",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"confirmedAt": 1647502440973,
"clientId": "12345",
"confirmedCount": 12,
"requiredCount": 12,
"orderId": "12345",
"chainId": "1",
"fee": "10.0"
}
],
"totalSize": 123
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» transfers | [object] | true | none | none |
»» id | string | false | none | none |
»» type | string | false | none | DEPOSIT, WITHDRAW or FAST_WITHDRAW |
»» CurrencyId | string | false | none | Currency ID |
»» Amount | string | false | none | Amount |
»» transactionHash | string | false | none | Transaction hash |
»» status | string | false | none | Status |
»» createdAt | integer | false | none | Created at |
»» confirmedAt | integer | false | none | Confirmed time (only for withdrawals) |
»» updatedTime | string | true | none | Only applicable for deposits |
»» confirmedCount | string | true | none | Number of confirmations on L1, only for deposits |
»» requiredCount | string | true | none | Number of confirmations required for deposits on L1, only for deposits |
»» clientId | string | false | none | Client to create a randomized id (only for withdrawal) |
»» orderId | string | true | none | Success Wallet Transaction Id |
»» chainId | string | true | none | Supported chainId |
»» fee | string | true | none | Fee |
» totalSize | string | true | none | Total size |
GET Retrieve User Withdrawal List
GET /v1/withdraw-list
curl https://pro.apex.exchange/api/v1/withdraw-list?limit={limit}&page={page}&beginTimeInclusive={beginTimeInclusive}&endTimeExclusive={endTimeExclusive} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
withdrawListRes = client.withdraw_list(limit=100,page=0,beginTimeInclusive=1651406864000,endTimeExclusive=1657105971171)
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
limit | query | integer | false | Page limit default at 100 |
page | query | integer | false | Page numbers start from 0 |
beginTimeInclusive | query | integer | false | Start time |
endTimeExclusive | query | string | false | End time |
transferType | query | string | false | Check for multiple transferType records, separated by commas |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"transfers": [
{
"id": "foo",
"type": "WITHDRAW",
"currencyId": "USDC",
"amount": "3000",
"transactionHash": "0x12aaaaaaaa",
"status": "PENDING_L2_APPROVING",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"confirmedAt": 1647502440973,
"clientId": "12345",
"orderId": "12345",
"chainId": "1",
"fee": "10.0"
}
],
"totalSize": 123
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» transfers | [object] | true | none | none |
»» id | string | false | none | none |
»» type | string | false | none | DEPOSIT, WITHDRAW or FAST_WITHDRAW |
»» CurrencyId | string | false | none | Currency ID |
»» Amount | string | false | none | Amount |
»» transactionHash | string | false | none | Transaction hash |
»» status | string | false | none | Status |
»» createdAt | integer | false | none | Created at |
»» confirmedAt | integer | false | none | Confirmed time (only for withdrawals) |
»» updatedTime | string | false | none | Only applicable for deposits |
»» confirmedCount | string | false | none | Number of confirmations on L1, only for deposits |
»» requiredCount | string | false | none | Number of confirmations required for deposits on L1, only for deposits |
»» clientId | string | false | none | client create the Randomized id (only for withdrawal) |
»» orderId | string | true | none | Success Wallet Transaction Id |
»» chainId | string | false | none | Supported chainId |
»» fee | string | false | none | Fee |
»» withdrawStatus | string | false | none | PENDING_L2_APPROVING,SUCCESS : Withdrawal status, search for multiple statuses separated by commas |
» totalSize | string | true | none | none |
POST User Withdrawal
POST /v1/create-withdrawal
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
};
example
curl https://pro.apex.exchange/api/v1/create-withdrawal -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createWithdrawRes = client.create_withdrawal(amount='1001',expirationEpochSeconds=currentTime,asset='USDC')
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset (in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
Successful Response Generation
{
"id": "1234455",
"type": "WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | id |
» type | string | true | none | type |
POST User Withdrawal to Designated Address
POST /v1/create-withdrawal-to-address
Transfer funds from L1 to a designated Ethereum address without registering for a corresponding StarkKey tagged to the Ethereum address.
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
ethAddress,
};
example
curl https://pro.apex.exchange/api/v1/create-withdrawal -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createWithdrawRes = client.create_withdrawal(amount='1001',expirationEpochSeconds=currentTime,asset='USDC',ethAddress="0x***")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | Request signature | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Withdraw Amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset(in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
» ethAddress | body | string | false | Withdraw only to your registered Ethereum address. |
Successful Response Generation
{
"id": "1234455",
"type": "WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | none |
» type | string | true | none | Withdrawal type |
POST User Fast Withdrawal
POST /v1/fast-withdraw
fact = this.starkLib.factRegistry.getTransferErc20Fact({
recipient: toEthAddress,
tokenAddress: usdcAddress,
tokenDecimals: 6,
humanAmount: params.Amount,
salt: nonceFromClientId(clientId),
});
const transferToSign = {
senderPositionId: accountId,
receiverPositionId: fastWithdrawAccountId,
receiverPublicKey: fastWithdrawL2Key,
factRegistryAddress: fastWithdrawFactRegisterAddress,
fact,
humanAmount: params.amount,
clientId,
expirationIsoTimestamp: params.expiration,
};
example
curl https://pro.apex.exchange/api/v1/fast-withdraw -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}&erc20Address={erc20Address}&fee={fee}&lpAccountId={lpAccountId}&chainId={chainId}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
feeRes = client.uncommon_withdraw_fee(amount='1002',chainId='56')
fastWithdrawRes = client.fast_withdrawal(amount='1002',expirationEpochSeconds=currentTime,asset='USDC',fee=feeRes['data']['fee'])
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | false | Withdrawal amount |
» clientId | body | string | false | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | false | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | false | Asset(in USDC) being withdrawn. |
» signature | body | string | false | The signature for the transfer, signed with the account's STARK private key. |
» erc20Address | body | string | false | USDC address |
» fee | body | string | false | Fees |
» chainId | body | string | true | chainId |
» lpAccountId | body | string | false | Attach documents to retrieve fast_withdraw_account_id |
Successful Response Generation
{
"id": "1234455",
"type": "FAST_WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | id |
» type | string | true | none | type |
POST Cross-Chain Withdrawals
POST /v1/cross-chain-withdraw
withdrawalToSign = {
humanAmount: params.amount,
expirationIsoTimestamp: params.expiration,
clientId,
positionId,
fee
};
example
curl https://pro.apex.exchange/api/v1/cross-chain-withdraw -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'amount={amount}&clientId={clientId}&asset={asset}&expiration={expiration}&signature={signature}ðAddress={ethAddress}&erc20Address={erc20Address}&fee={fee}&lpAccountId={lpAccountId}&chainId={chainId}'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
feeRes = client.uncommon_withdraw_fee(amount='1003',chainId='56')
crossWithdrawRes = client.cross_chain_withdraw(amount='1003',expirationEpochSeconds= currentTime,asset='USDC',fee=feeRes['data']['fee'],chainId='56')
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» amount | body | string | true | Withdrawal amount |
» clientId | body | string | true | Unique id of the client associated with the withdrawal. Must be <= 40 characters. When using the client, if not included, will be randomly generated by the client. |
» expiration | body | string | true | Date and time at which the withdrawal expires if it has not been completed. Expiration must be at least seven days in the future. |
» asset | body | string | true | Asset(in USDC) being withdrawn. |
» signature | body | string | true | The signature for the transfer, signed with the account's STARK private key. |
» erc20Address | body | string | true | USDC address |
» chainId | body | string | true | Randomized clientId |
» fee | body | string | true | Fees |
» lpAccountId | body | string | true | Attach documents to retrieve fast_withdraw_account_id |
Successful Response Generation
{
"id": "1234455",
"type": "CROSS_WITHDRAW"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | true | none | none |
» type | string | true | none | Withdrawal type |
GET Fast & Cross-Chain Withdrawal Fees
GET /v1/uncommon-withdraw-fee
curl https://pro.apex.exchange/api/v1/uncommon-withdraw-fee?amount={amount}&chainId={chainId} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
feeRes = client.uncommon_withdraw_fee(amount='1003',chainId='56')
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
amount | query | string | false | USDC |
chainId | query | string | false | chainId |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"fee": "1.1",
"poolAvailableAmount": "10"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» fee | string | true | none | Fees calculated |
» poolAvailableAmount | string | true | none | Available balance in pool |
GET Withdrawal & Transfer Limits
GET /v1/transfer-limit
curl https://pro.apex.exchange/api/v1/transfer-limit -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
transfer_limitRes = client.transfer_limit(currencyId="USDC")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
currencyId | query | string | true | USDC |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"withdrawAvailableAmount": "100.1",
"transferAvailableAmount": "100.1"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» withdrawAvailableAmount | string | true | none | Withdraw available amount |
» transferAvailableAmount | string | true | none | Transfer available amount |
GET Trade History
GET /v1/fills
curl https://pro.apex.exchange/api/v1/fills?limit=100&page=0&symbol=BTC-USDC&side=BUY -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
fillsRes = client.fills(limit=100,page=0,symbol="BTC-USDC",side="BUY")
Order Type
"UNKNOWN_ORDER_TYPE"
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | Symbol |
side | query | string | false | BUY or SELL |
limit | query | string | false | default at 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | orderType |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | Total order size |
GET Worst Price
GET /v1/get-worst-price
get market price from orderbook
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | true | Symbol |
size | query | string | true | Order open size |
side | query | string | true | BUY or SELL order |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"worstPrice": "123.00",
"bidOnePrice": "123.00",
"askOnePrice": "123.00"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» worstPrice | string | true | none | Lowest price |
» bidOnePrice | string | true | none | Bid price |
» askOnePrice | string | true | none | Ask price |
POST Creating Orders
POST /v1/create-order
Signature content:
orderToSign:
OrderWithClientId = {
humanSize: params.size,
humanPrice: params.price,
limitFee: params.limitFee,
symbol: params.symbol,
side: params.side,
expirationIsoTimestamp: params.expiration,
clientOrderId,
positionId, };
TimeInForce (
GOOD_TIL_CANCEL // Effective until canceled, default.
FILL_OR_KILL // Immediately and completely filled or canceled.
IMMEDIATE_OR_CANCEL // Immediately executed or canceled.
)
example
curl https://pro.apex.exchange/api/v1/create-order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={symbol}&side={side}&type={type}&size={size}&price={price}&limitFee={limitFee}&expiration={expiration}&timeInForce={timeInForce}&triggerPrice={triggerPrice}&trailingPercent={trailingPercent}&clientOrderId={clientOrderId}&signature={signature}&reduceOnly=false'
from apexpro.http_private_stark_key_sign import HttpPrivateStark
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
public_key = '0x1cf0000000000'
public_key_y_coordinate = '0x7615000000000'
private_key = '0x488a6000000000'
client = HttpPrivateStark(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN,
stark_public_key=public_key,
stark_private_key=private_key,
stark_public_key_y_coordinate=public_key_y_coordinate,
api_key_credentials={'key': key, 'secret': secret, 'passphrase': passphrase})
currentTime = time.time()
createOrderRes = client.create_order(symbol="BTC-USDC", side="BUY",
type="LIMIT", size="0.01",
price="20001", limitFee="0.001",
accountId="330547708362228116",reduceOnly=False,
expirationEpochSeconds= currentTime, timeInForce="GOOD_TIL_CANCEL")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | Symbol |
» side | body | string | true | BUY or SELL |
» type | body | string | true | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT", "TAKE_PROFIT_MARKET" |
» size | body | string | true | Size |
» price | body | string | true | Price |
» limitFee | body | string | true | limitFee = price * size * takerFeeRate( from GET /v1/account) |
» expiration | body | string | true | Order expiry time |
» timeInForce | body | string | false | "GOOD_TIL_CANCEL", "FILL_OR_KILL", "IMMEDIATE_OR_CANCEL", "POST_ONLY" |
» triggerPrice | body | string | false | Trigger price |
» trailingPercent | body | string | false | Conditional order trailing-stop |
» clientOrderId | body | string | true | Randomized client id |
» signature | body | string | true | starkKey signature |
» reduceOnly | body | string | false | Reduce-only |
Successful Response Generation
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel Order
POST /v1/delete-order
curl https://pro.apex.exchange/api/v1/delete-order -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrderRes = client.delete_order(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | false | none |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
POST Cancel Order By ClientOrderId
POST /v1/delete-client-order-id
curl https://pro.apex.exchange/api/v1/delete-client-order-id` -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'id={id}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrderRes = client.delete_order_by_client_order_id(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» id | body | string | false | none |
Successful Response Generation
{
"data": "123456"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Order ID |
GET Open Orders
GET /v1/open-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://pro.apex.exchange/api/v1/open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
openOrdersRes = client.open_orders()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
Successful Response Generation
{
"data": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
POST Cancel all Open Orders
POST /v1/delete-open-orders
Body Request Parameters
symbol: BTC-USDC,ETH-USDC
curl https://pro.apex.exchange/api/v1/delete-open-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***' -X POST -d 'symbol={BTC-USDC,ETH-USDC}'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
deleteOrdersRes = client.delete_open_orders(symbol="BTC-USDC,ETH-USDC")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | false | "BTC-USDC,ETH-USDC", Cancel all orders if none |
Successful Response Generation
{
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
GET All Order History
GET /v1/history-orders
Order type
"UNKNOWN_ORDER_TYPE",
"LIMIT", //Limit price
"MARKET", //Market price
"STOP_LIMIT", //Stop limit order
"STOP_MARKET", //Stop market order
"TAKE_PROFIT_LIMIT",//Take profit limit orders
"TAKE_PROFIT_MARKET",//Take profit market orders
Order Status
"PENDING", // Order submitted but not yet processesd
"OPEN", // Order pending, partially filled
"FILLED", // Order has been completely filled
"CANCELED", //Order is canceled and may have been partially filled.
"EXPIRED", // Order has expired and may have been partially filled.
"UNTRIGGERED", // Order conditions have not been triggered
Order Cancelation Reason {
"UNKNOWN_ORDER_CANCEL_REASON" // Unknown
"EXPIRED" // Order has expired
"USER_CANCELED" // User manually canceled order
"COULD_NOT_FILL" // Unable to fill FOK/IOC/Post-only orders
"REDUCE_ONLY_CANCELED" // Unable to fulfil reduce-only orders
"LIQUIDATE_CANCELED" // Account or orders triggered liquidation resulting in automatic order cancelation
"INTERNAL_FAILED" // Internal processing issues including order matching failure or L2 validation failure
}
example
curl https://pro.apex.exchange/api/v1/history-orders -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historyOrdersRes = client.history_orders()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | none |
status | query | string | false | none |
side | query | string | false | BUY or SELL |
type | query | string | false | "LIMIT", "MARKET","STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT","TAKE_PROFIT_MARKET" |
limit | query | string | false | default 100 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
page | query | string | false | Page numbers start from 0 |
orderType | query | string | false | "ACTIVE","CONDITION","HISTORY" |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"orders": [
{
"id": "1234",
"clientOrderId": "1234",
"accountId": "12345",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"limitFee": "100",
"fee": "100",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"updatedTime": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"reduceOnly": false,
"latestMatchFillPrice": "reason",
"cumMatchFillSize": "0.1",
"cumMatchFillValue": "1000",
"cumMatchFillFee": "1",
"cumSuccessFillSize": "0.1",
"cumSuccessFillValue": "1000",
"cumSuccessFillFee": "1"
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» orders | [object] | true | none | none |
»» id | string | false | none | Order id |
»» orderId | string | false | none | Order id |
»» clientOrderId | string | false | none | Client create the Randomized id |
»» accountId | string | false | none | Account ID |
»» symbol | string | false | none | Symbol |
»» side | string | false | none | BUY or SELL |
»» price | string | false | none | Order open price |
»» limitFee | string | false | none | Order open max. fee |
»» fee | string | false | none | Order open actual fee |
»» triggerPrice | string | false | none | Conditional order trigger price |
»» trailingPercent | string | false | none | Conditional order trailing-stop |
»» size | string | false | none | Order open size |
»» type | string | false | none | Order type |
»» createdAt | integer | false | none | Order create at |
»» updatedTime | integer | false | none | Order update time |
»» expiresAt | integer | false | none | Order expires at |
»» status | string | false | none | Order status |
»» timeInForce | string | false | none | Open order timeInForce |
»» postOnly | boolean | false | none | Open Post-only order |
»» reduceOnly | boolean | false | none | Open Reduce-only order |
»» latestMatchFillPrice | string | false | none | Latest match fill price |
»» cumMatchFillSize | string | false | none | Cumulative match fill size |
»» cumMatchFillValue | string | false | none | Cumulative match fill value |
»» cumMatchFillFee | string | false | none | Cumulative match fill fee |
»» cumSuccessFillSize | string | false | none | Cumulative success fill size |
»» cumSuccessFillValue | string | false | none | Cumulative success fill value |
»» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
» totalSize | integer | true | none | total order size |
GET Order ID
GET /v1/get-order
curl https://pro.apex.exchange/api/v1/get-order?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
getOrderRes = client.get_order(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Order by clientOrderId
GET /v1/order-by-client-order-id"
curl https://pro.apex.exchange/api/v1/order-by-client-order-id?id={id} -h 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
getOrderRes = client.get_order_by_client_order_id(id="123456")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
id | query | string | true | none |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"id": "123456",
"clientOrderId": "1234",
"accountId": "afoo",
"symbol": "BTC-USD",
"side": "SELL",
"price": "18000",
"triggerPrice": "1.2",
"trailingPercent": "0.12",
"size": "100",
"type": "LIMIT",
"createdAt": 1647502440973,
"unfillableAt": 1647502440973,
"expiresAt": 1647502440973,
"status": "PENDING",
"timeInForce": "GOOD_TIL_CANCEL",
"postOnly": false,
"cancelReason": "reason"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» id | string | false | none | Order id |
» orderId | string | false | none | Order id |
» clientOrderId | string | false | none | Client create the Randomized id |
» accountId | string | false | none | Account ID |
» symbol | string | false | none | Symbol |
» side | string | false | none | BUY or SELL |
» price | string | false | none | Order open price |
» limitFee | string | false | none | Order open max. fee |
» fee | string | false | none | Order open actual fee |
» triggerPrice | string | false | none | Conditional order trigger price |
» trailingPercent | string | false | none | Conditional order trailing-stop |
» size | string | false | none | Order open size |
» type | string | false | none | Order type |
» createdAt | integer | false | none | Order create at |
» updatedTime | integer | false | none | Order update time |
» expiresAt | integer | false | none | Order expires at |
» status | string | false | none | Order status |
» timeInForce | string | false | none | Open order timeInForce |
» postOnly | boolean | false | none | Open Post-only order |
» reduceOnly | boolean | false | none | Open Reduce-only order |
» latestMatchFillPrice | string | false | none | Latest match fill price |
» cumMatchFillSize | string | false | none | Cumulative match fill size |
» cumMatchFillValue | string | false | none | Cumulative match fill value |
» cumMatchFillFee | string | false | none | Cumulative match fill fee |
» cumSuccessFillSize | string | false | none | Cumulative success fill size |
» cumSuccessFillValue | string | false | none | Cumulative success fill value |
» cumSuccessFillFee | string | false | none | Cumulative success fill fee |
GET Verification Email Link
GET /v1/verify-email
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
userId | query | string | false | User ID |
token | query | string | false | Authentication token |
Successful Response Generation
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
POST Link Device
POST /v1/bind-device
Body Request Parameters
deviceToken: string
deviceType: 1 or 2
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» deviceToken | body | string | true | Device token |
» deviceType | body | string | true | 1 (ios_firebase), 2 (android_firebase) |
Successful Response Generation
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
GET Funding Rate
GET /v1/funding
curl https://pro.apex.exchange/api/v1/funding?limit={limit}&page={page}&symbol={symbol}&side={side} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
fundingRes = client.funding(limit=100,page=0,symbol="BTC-USDC",side="BUY")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
symbol | query | string | false | none |
limit | query | string | false | Default at 100 |
page | query | string | false | Page numbers start from 0 |
beginTimeInclusive | query | string | false | Start time |
endTimeExclusive | query | string | false | End time |
side | query | string | false | Side |
status | query | string | false | Order status |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"fundingValues": [
{
"id": "1234",
"symbol": "BTC-USD",
"fundingValue": "10000",
"rate": "0.0000125000",
"positionSize": "500",
"price": "90",
"side": "LONG",
"status": "SUCCESS",
"fundingTime": 1647502440973,
"transactionId": "1234556"
}
],
"totalSize": 11
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» fundingValues | [object] | true | none | none |
»» id | string | false | none | id |
»» symbol | string | false | none | Symbol |
»» fundingValue | string | false | none | Funding fee value |
»» rate | string | false | none | Funding rate |
»» positionSize | string | false | none | Open position size |
»» price | string | false | none | Symbol price |
»» side | string | false | none | Position side |
»» status | string | false | none | Position funding status |
»» fundingTime | integer | false | none | Funding fee time |
»» transactionId | string | false | none | Successful wallet transaction ID |
» totalSize | integer | true | none | Total size |
GET User Historial Profit and Loss
GET /v1/historical-pnl
curl https://pro.apex.exchange/api/v1/historical-pnl?limit={limit}&page={page}&beginTimeInclusive={beginTimeInclusive}&endTimeExclusive={endTimeExclusive}&type={type}&symbol={symbol} -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historicalPnlRes = client.historical_pnl(limit=100,page=0,beginTimeInclusive=1651406864000,endTimeExclusive=1657105971171,symbol="BTC-USDC")
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
beginTimeInclusive | query | string | false | StartTime |
endTimeExclusive | query | string | false | EndTime |
type | query | string | false | Position type |
symbol | query | string | false | Symbol |
page | query | string | false | Page numbers start from 0 |
limit | query | string | false | Default at 100 |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historicalPnl": [
{ "symbol": "BTC-USDC",
"size": "1.0000",
"totalPnl": "1.0000",
"price": "1.0000",
"createdAt": 1647502440973,
"type": "CLOSE_POSITION",
"isLiquidate": false,
"isDeleverage": false
}
],
"totalSize": 12
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
» historicalPnl | [object] | true | none | none |
»» size | string | false | none | Size |
»» totalPnl | string | false | none | Closing profit and loss |
»» price | string | false | none | Price |
»» exitPrice | string | false | none | Closing price |
»» createdAt | integer | false | none | Time |
»» type | string | false | none | postion type |
»» isLiquidate | boolean | false | none | Liquidate |
»» isDeleverage | boolean | false | none | ADL |
» totalSize | integer | true | none | none |
GET Yesterday's Profit & Loss
GET /v1/yesterday-pnl
curl https://pro.apex.exchange/api/v1/yesterday-pnl -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
yesterdayPnlRes = client.yesterday_pnl()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"data": "11.11"
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» data | string | true | none | Profit and loss value |
GET Historical Asset Value
GET /v1/history-value
curl https://pro.apex.exchange/api/v1/history-value -H 'APEX-SIGNATURE: ***' -H 'APEX-TIMESTAMP: ***' -H 'APEX-API-KEY: ***' -H 'APEX-PASSPHRASE: ***'
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
historyValueRes = client.history_value()
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
endTime | query | int64 | false | Start time |
startTime | query | int64 | false | End time |
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
Successful Response Generation
{
"historyValues": [
{
"accountTotalValue": "123.11",
"dateTime": 1651406864000
}
]
}
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
Status Code 200
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» historyValues | [object] | true | none | none |
»» accountTotalValue | string | false | none | Assets |
»» dateTime | integer | false | none | Assets date and time snapshot |
POST Sets the initial margin rate of a contract
POST /v1/set-initial-margin-rate
curl https://pro.apex.exchange/api/v1/set-initial-margin-rate -H "Content-Type: application/x-www-form-urlencoded" -H "APEX-SIGNATURE: ***" -H "APEX-TIMESTAMP: ***" -H "APEX-API-KEY: ***" -H "APEX-PASSPHRASE: ***" -X POST -d "symbol=BTC-USDC&initialMarginRate=0.02"
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_MAIN, NETWORKID_MAIN
key = 'f16ddxxxxxxxxxxx'
secret = 'Kvckxxxxxxxxxxx'
passphrase = 'Yjjd1xxxxxxxxxx'
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, api_key_credentials={'key': key,'secret': secret, 'passphrase': passphrase})
setInitialMarginRateRes = client.set_initial_margin_rate(symbol="BTC-USDC",initialMarginRate="0.1")
print(setInitialMarginRateRes)
Body
symbol: string
initialMarginRate: string
Request Parameters
Parameter | Position | Type | Required | Comment |
---|---|---|---|---|
APEX-SIGNATURE | header | string | true | Request signature |
APEX-TIMESTAMP | header | string | true | Request timestamp |
APEX-API-KEY | header | string | true | apiKeyCredentials.key |
APEX-PASSPHRASE | header | string | true | apiKeyCredentials.passphrase |
body | body | object | false | none |
» symbol | body | string | true | symbol |
» initialMarginRate | body | string | true | initialMarginRate(the reciprocal of the opening leverage) |
Successful Response Generation
Response Status Code
Status Code | Definition | Comment | Data Model |
---|---|---|---|
200 | OK | Success | Inline |
Response Parameters
StarkKey Signature
Several endpoints require a starkKey signature authentication, please check the list below.
Create Order
Refer to required signature content.
{
"amount_collateral": "4000000",
"amount_fee": "4000",
"amount_synthetic": "1000000",
"asset_id_collateral": "0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f",
"asset_id_synthetic": "0x0",
"expiration_timestamp": "1100000",
"is_buying_synthetic": false,
"nonce": "1001",
"order_type": "LIMIT_ORDER_WITH_FEES",
"position_id": "10000",
"public_key": "0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef",
"signature": {
"r": "0x07a15838aad9b20368dc4ba27613fd35ceec3b34be7a2cb913bca0fb06e98107",
"s": "0x05007f40fddd9babae0c7362d3b4e9c152ed3fced7fe78435b302d825489298f"
}
}
Transaction Signing & Validation
In ApeX Pro's testing environment, USDC is at 6 decimal places and BTC-USDC Perpetual Contract at 10 decimal places. For example, at the amount of 40,000 USDC and an open position of 0.0001 BTC with funding fee rate at 0.1%:
- asset_id_collateral testing environment
0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f
- asset_id_synthetic testing environment where BTC-USDC is at 0x0
- amount_synthetic 0.0001 (at 10 decimal places) would be equivalent to
0.0001 * (10 ** 10) = 1000000
- amount_collateral 0.0001 * 40000 = 4 USDC (at 6 decimal places) and would be equivalent to
40000 * 0.0001 * (10 **6) = 4000000
- amount_fee = 4 * 0.1% = 0.004 USDC (at 6 decimal places) and would be equivalent to
4000000 * 0.1 / 100 = 4000
- expiration_timestamp: "1100000",timeout calculated per hour,
unix timestamp/3600
- is_buying_synthetic: buy = true, sell = false
- nonce: "1001" and UInt32 must be the only entry — when creating orders make sure the entry for generated client_Id is nonce
Hash Value Calculation Reference
https://github.com/starkware-libs/stark-perpetual/blob/d1edb2203440b54e71458b10bf0bb646d8597caf/src/services/perpetual/public/perpetual_messages.py#L163
Hash Value Calculation
Calculated signature hash as
0x0375d83863bc2639f6a161dc96651a55d71d53230f9416ce66720243eda44722
postion_id 10000
Private Key
0x607ba3969039f3e19006ff8f40629d20a7b7dac31d4019e0965fbf7c5c068a
Public Key
0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef
Please refer to https://github.com/starkware-libs/stark-perpetual/blob/d1edb2203440b54e71458b10bf0bb646d8597caf/src/starkware/crypto/starkware/crypto/signature/signature.py#L124
Transaction Signing & Validation Result:
- r
07a15838aad9b20368dc4ba27613fd35ceec3b34be7a2cb913bca0fb06e98107
- s
05007f40fddd9babae0c7362d3b4e9c152ed3fced7fe78435b302d825489298f
Withdrawal
Refer to required signature content for withdrawal to individual Ethereum address.
{
"amount": "1000000",
"expiration_timestamp": "660000",
"nonce": "1650006339",
"position_id": "10000",
"public_key": "0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef",
"signature": {
"r": "0x056a727b30d09f393acd968917bca78d92fb63a827db25747940916aa4074938",
"s": "0x0775f575a71ff8f2c13dd522e605bd71652a709daa26db5a0f8218cc589fe8f9"
},
"type": "WITHDRAWAL"
}
Transaction Signing & Validation
USDC has 6 decimal places; timeout is calculated in hours; unix timestamp/3600, nonce UInt32 must be the only entry for generated client_Id
- amount refers to the :Withdrawal amount
1 USDC = 1 * (10 ** 6)
- expiration_timestamp:660000, timeout calculated per hour, unix timestamp/3600
- nonce: 1650006339
- position_id: 10000,postionID of the withdrawal account
Hash Value Calculation Reference
https://docs.starkware.co/starkex-v4/starkex-deep-dive/message-encodings/in-perpetual#withdrawal
- Please note that the amount stated in the above document is incorrect, the correct amount is 64 bits
Reference code:
https://github.com/starkware-libs/stark-perpetual/blob/d1edb2203440b54e71458b10bf0bb646d8597caf/src/services/perpetual/public/perpetual_messages.py#L112
Hash Value Calculation
Calculated signature hash as
0x7f8ebd70332711c35e54808d16740701b902bd03fb6a004dacb9dbbc9a8932
postion_id 10000
Private Key
0x607ba3969039f3e19006ff8f40629d20a7b7dac31d4019e0965fbf7c5c068a
Public Key
0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef
Transaction Signing & Validation Result
- r
0x056a727b30d09f393acd968917bca78d92fb63a827db25747940916aa4074938
- s
0x0775f575a71ff8f2c13dd522e605bd71652a709daa26db5a0f8218cc589fe8f9
Withdrawal to Address
Refer to required signature content for withdrawal endpoint WITHDRAWAL_TO_ADDRESS.
{
"amount": "1000000",
"eth_address": "0x724f337bf0fa934db9aa3ec6dea49b03c54ad3cc",
"expiration_timestamp": "660000",
"nonce": "1651500987",
"position_id": "10000",
"public_key": "0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef",
"signature": {
"r": "0x07edcc193f142ff8c78d700774fbccde8214c21f8fc1bd190390d367ce365696",
"s": "0x06e5b54f17f56e65e21b00e83fd2b6f3da072ed6b6df3ca50747d8a0974d5033"
},
"type": "WITHDRAWAL_TO_ADDRESS"
}
Use a new WITHDRAWAL_TO_ADDRESS and transfer your assets from L1 to a designated Ethereum address. When requesting for a withdrawal endpoint on L1, you will need to enter eth_address in the required starkKey portion. You will not need to register a corresponding starkKey to manage the Ethereum address.
Transaction Signing & Validation
USDC has 6 decimal places; timeout is calculated in hours; unix timestamp/3600, nonce UInt32 must be the only entry for generated client_Id
- amount refers to the withdrawal amount where
1 USDC = 1 * (10 ** 6)
- expiration_timestamp:660000, timeout calculated per hour, unix timestamp/3600
- nonce: 1651500987
- position_id: 10000,postion ID of the withdrawal account
- ethaddress:
0x724f337bf0fa934db9aa3ec6dea49b03c54ad3cc
- Hash Value Reference: WITHDRAWAL_TO_ADDRESS = 7
Hash Value Calculation
def get_withdrawal_to_address_msg(
asset_id_collateral: int,
position_id: int,
eth_address: str,
nonce: int,
expiration_timestamp: int,
amount: int,
hash_function: Callable[[VarArg(int)], int] = pedersen_hash,
) -> int:
assert 0 <= asset_id_collateral < 2 ** 250
assert 0 <= nonce < 2 ** 32
assert 0 <= position_id < 2 ** 64
assert 0 <= expiration_timestamp < 2 ** 32
assert 0 <= amount < 2 ** 64
assert 0 <= int(eth_address, 16) < 2 ** 160
return get_withdrawal_to_address_msg_without_bounds(
asset_id_collateral,
position_id,
eth_address,
nonce,
expiration_timestamp,
amount,
hash_function=hash_function,
)
def get_withdrawal_to_address_msg_without_bounds(
asset_id_collateral: int,
position_id: int,
eth_address: str,
nonce: int,
expiration_timestamp: int,
amount: int,
hash_function: Callable[[VarArg(int)], int] = pedersen_hash,
) -> int:
eth_address_int = int(eth_address, 16)
packed_message = WITHDRAWAL_TO_ADDRESS
packed_message = packed_message * 2 ** 64 + position_id
packed_message = packed_message * 2 ** 32 + nonce
packed_message = packed_message * 2 ** 64 + amount
packed_message = packed_message * 2 ** 32 + expiration_timestamp
packed_message = packed_message * 2 ** 49 # Padding.
return hash_function(hash_function(asset_id_collateral, eth_address_int), packed_message)
Calculated signature hash:
0x0367fa833e40d36df56df501502fe80eabf4d7f3da99169865a38fa6e3d2482c
postion_id 10000
Private Key
0x607ba3969039f3e19006ff8f40629d20a7b7dac31d4019e0965fbf7c5c068a
Public Key
0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef
Transaction Signing & Validation Result
- r
0x07edcc193f142ff8c78d700774fbccde8214c21f8fc1bd190390d367ce365696
- s
0x06e5b54f17f56e65e21b00e83fd2b6f3da072ed6b6df3ca50747d8a0974d5033
Cross-Chain Withdrawal
Refer to required signature content for this transfer endpoint, utilized for cross-chain deposits.
{
"amount": "1000000",
"asset_id": "0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f",
"expiration_timestamp": "660000",
"nonce": "1652361581",
"receiver_position_id": "30000",
"receiver_public_key": "0x2f116d013fb6ecae90765a876a5bfcf66cd6a6be1f85c9841629cd0bd080ed3",
"sender_position_id": "10000",
"sender_public_key": "0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef",
"signature": {
"r": "0xd4c14bb7bfd66785352c8b57c3864722e2137f51299e0a21dff495759c3902",
"s": "0x01a7dcd09583e3261906ad1f039848e9ace4d3cc988e56e96bb8652e9c483517"
},
"type": "TRANSFER"
}
Transaction Signing & Validation
USDC has 6 decimal places; timeout is calculated in hours; unix timestamp/3600, nonce UInt32 must be the only entry for generated client_Id
- amount refers to the transfer amount where
1 USDC = 1 * (10 ** 6)
- asset_id : asset_id for USDC on L2 in testing environment as
0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f
- expiration_timestamp:660000, timeout calculated per hour, unix timestamp/3600
- nonce: 1652361581
- receiver_position_id : 30000,postion ID of the recipient account
- receiver_public_key : starkKey of the recipient account
- sender_position_id: 10000,postion ID of the sender account
- sender_public_key: starkKey of the sender account
Hash Value Reference (TRANSFER = 4)
https://github.com/starkware-libs/stark-perpetual/blob/d1edb2203440b54e71458b10bf0bb646d8597caf/src/services/perpetual/public/perpetual_messages.py#L69
- Please note that asset_id_fee and max_amount_fee are 0 by default and you will need to enter src_fee_position_id into sender_position_id.
Hash Value Calculation
Calculated signature hash
0x0146e4cf2bfe86e8333a08f6e56f6d78debcffd393625b2d34e2e0c95c493540
postion_id 10000
Private Key
0x607ba3969039f3e19006ff8f40629d20a7b7dac31d4019e0965fbf7c5c068a
Public Key
0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef
Transaction Signing & Validation Result
- r
0xd4c14bb7bfd66785352c8b57c3864722e2137f51299e0a21dff495759c3902
- s
0x01a7dcd09583e3261906ad1f039848e9ace4d3cc988e56e96bb8652e9c483517
Conditional Transfer
Refer to required signature content for this CONDITIONAL_TRANSFER endpoint, utilized for Fast Withdrawals.
{
"amount": "1000000",
"asset_id": "0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f",
"expiration_timestamp": "660000",
"fact": "d7262d40a59d8bd081382e506f94230c73e3b81dc464bb02e7314b1afcca46d1",
"fact_registry_address": "0x5070F5d37419AEAd10Df2252421e457336561269",
"nonce": "1652361582",
"receiver_position_id": "20000",
"receiver_public_key": "0x2deb04eb807be0ec943e08d8f666521edb3f12833922fbbc7f93e1434ae810e",
"sender_position_id": "10000",
"sender_public_key": "0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef",
"signature": {
"r": "0x07dbf7b64406bd4de0439dfd79a742d1703ce44b99dfbe5a99d792c11447a952",
"s": "0x01c436232f1e938cdcfe661f580d6957cdbdb72a14e66021349dd6c2baa6ac36"
},
"type": "CONDITIONAL_TRANSFER"
}
Transaction Signing & Validation
USDC has 6 decimal places; timeout is calculated in hours; unix timestamp/3,600, nonce UInt32 must be the only entry for generated client_Id
- amount refers to the transfer amount where
1 USDC = 1 * (10 ** 6)
- asset_id :asset_id for USDC on L2 in testing environment as
0xa21edc9d9997b1b1956f542fe95922518a9e28ace11b7b2972a1974bf5971f
- expiration_timestamp: 660000, timeout calculated per hour, unix timestamp/3600
- nonce: 1652361581
- receiver_position_id: 30000, postion ID of the recipient account
- receiver_public_key: starkKey of the recipient account
- sender_position_id: 10000,postion ID of the sender account
- sender_public_key: starkKey of the sender account
- fact: L1 fact hash value
- fact_registry_address: L1 fact registered contract address
Hash Value Reference (CondTransferType = 5)
https://github.com/starkware-libs/stark-perpetual/blob/d1edb2203440b54e71458b10bf0bb646d8597caf/src/services/perpetual/public/perpetual_messages.py#L24
- Please note that asset_id_fee and max_amount_fee are 0 at default and you will need to enter src_fee_position_id into sender_position_id.
Hash Value Calculation
Calculated signature hash as
0x9677d1aee45206f66b46826de80b25ad06ce58c09c63adc5f65e04c4a5da90
postion_id 10000
Private Key
0x607ba3969039f3e19006ff8f40629d20a7b7dac31d4019e0965fbf7c5c068a
Public Key
0xf8c6635f9cfe85f46759dc2eebe71a45b765687e35dbe5e74e8bde347813ef
Transaction Signing & Validation Result
- r
0x07dbf7b64406bd4de0439dfd79a742d1703ce44b99dfbe5a99d792c11447a952
- s
0x01c436232f1e938cdcfe661f580d6957cdbdb72a14e66021349dd6c2baa6ac36
Websocket V3 for Omni
Websocket V3 Endpoint:
Timestamp = Current Unix Timestamp
Testnet:
Public Websocket API
wss://qa-quote.omni.apex.exchange/realtime_public?v=2×tamp=1661415017232
Private Websocket API
wss://qa-quote.omni.pro.apex.exchange/realtime_private?v=2×tamp=1661415017233
Mainnet:
Public Websocket API
wss://quote.omni.apex.exchange/realtime_public?v=2×tamp=1661415017232
Private Websocket API
wss://quote.omni.apex.exchange/realtime_private?v=2×tamp=1661415017233
Public Websocket V3
Due to network complexity, your may get disconnected at any time. Please follow the instructions below to ensure that you receive WebSocket messages on time:
- Keep connection alive by sending heartbeat packet
- Reconnect as soon as possible if disconnected
Heartbeat Packet
To avoid networks or program issues, we recommend that you send the ping heartbeat packet every 15 seconds to maintain the WebSocket connection.
How to Send
ws.send('{"op":"ping","args":["1661415022821"]}');
Response Example
'{"op":"pong","args":["1661415030233"]}'
When receiving a ping message from the server, a pong message needs to be returned to the server.
ws.send('{"op":"pong","args":["1661415022821"]}');
Server Check With Ping Pong Test:
- Check the connection ever 15 seconds and look at the client timestamp
- If the difference between the client timestamp and the current timestamp exceeds 150s, the connection will be closed
How to Subscribe to Topics
Understanding Websocket Filters
After establishing the connection, one can subscribe to a new topic by sending a JSON request. The specific formats are as follows:
ws.send('{"op": "subscribe", "args": ["topic.filter"]}');
The topic indicates the data you would like to receive whilst the filter parses for the specific data you desire, for example, the symbol. The topic is mandatory but the filter is optional.
To subscribe to more than one topic, simply list multiple topics out like this:
ws.send('{"op": "subscribe", "args": ["topic.filter", "topic.filter"]}');
Unsubscribing From Websocket Topics
You can dynamically subscribe and unsubscribe from topics (with or without filters) without websocket disconnection as follows:
ws.send('{"op": "unsubscribe", "args": ["topic.filter", "topic.filter"]}');
Intervals
Some topics are pushed out at specific intervals. If the args contains a millisecond parameter, such as 100ms, this topic is pushed at intervals. Otherwise, topis will be pushed constantly.
Understanding Subscription Response
Each subscription will have a response. You can determine whether the subscription is successful based on the response.
{
"success":true,
"ret_msg":"",
"conn_id":"647c3de8-6f66-44ab-a323-72067589372e",
"request":{
"op":"subscribe",
"args":[
"instrumentInfo.H.BTCUSDT"
]
}
}
Depth
Fetches the orderbook with a depth of 25 or 200 orders per side.
After the subscription response, the first response will be the snapshot response. This shows the entire order book. The data is sorted by price, starting with the lowest buys and ending with the highest sells.
Following this, all responses are in the delta format, which represents updates to the order book relative to the last response.
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Order book |
» limit | string | true | 25 or 200 |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["orderBook200.H.BTCUSDT"]}');
response
{
"topic":"orderBook200.H.BTCUSDT",
"type":"delta",
"data":{
"s":"BTCUSDT",
"b":[
[
"18990.5",
"0"
],
[
"18979.5",
"0"
]
],
"a":[
[
"19010.5",
"0"
],
[
"19037.5",
"0"
]
],
"u":249003
},
"cs":44132980,
"ts":1661416027956272
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
» s | string | Symbol |
» u | int | Update ID: According to whether the Update ID is continuous, the client will need to determine if there is a packet loss in the process of receiving data. Snapshot resets the Update ID and it will start counting again from 1. |
» b | array | Buy[price,size], size set as 0 will delete this item |
» a | array | Sell[price,size], size set as 0 will delete this item |
Trade
Get Trades for symbol.
TickDirection {
"PlusTick"
"ZeroPlusTick"
"MinusTick"
"ZeroMinusTick"
}
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Recently trade |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["recentlyTrade.H.BTCUSDT"]}');
response
{
"topic":"recentlyTrade.H.BTCUSDT",
"type":"snapshot",
"data":[
{
"T":1647502440973,
"s":"BTCPERP",
"S":"Buy",
"v":"1.000",
"p":"43513.00",
"L":"PlusTick",
"i":"a3afbef7-d8de-5b87-a32f-d06f041a249d"
}
],
"cs":44132980,
"ts":1661416027956272
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot |
» s | string | Symbol |
» T | int | Timestamp |
» S | string | Buy or Sell |
» v | string | Volume |
» p | string | Price |
» L | string | Tick direction |
» i | string | Order ID |
Ticker
Get latest information for symbol.
This topic only utilizes the update field. Both the delete and insert fields are null. If a key is not found in the update field, its value has not changed.
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Instrument info |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["instrumentInfo.H.BTCUSDT"]}')
response
{
"topic":"instrumentInfo.H.BTCUSDT",
"type":"snapshot",
"data":{
"symbol":"BTCUSDT",
"lastPrice":"21572.5",
"price24hPcnt":"-0.0194318181818182",
"highPrice24h":"25306.5",
"lowPrice24h":"17001.5",
"turnover24h":"1334891.4545",
"volume24h":"64.896",
"nextFundingTime":"2022-08-26T08:00:00Z",
"oraclePrice":"21412.060000000002752512",
"indexPrice":"21409.82",
"openInterest":"49.598",
"tradeCount":"0",
"fundingRate":"0.0000125",
"predictedFundingRate":"0.0000125"
},
"cs":44939063,
"ts":1661500091955487
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
»» symbol | string | Symbol |
»» price24hPcnt | string | 24H change (%) |
»» lastPrice | string | Last price |
»» highPrice24h | string | 24H highest price |
»» lowPrice24h | string | 24H lowest price |
»» oraclePrice | string | Oracle price |
»» indexPrice | string | Index price |
»» openInterest | string | Open interest |
»» turnover24h | string | 24H turnover |
»» volume24h | string | 24H trading volume |
»» fundingRate | string | Funding rate |
»» predictedFundingRate | string | Predicted funding rate |
»» nextFundingTime | string | Next funding rate |
»» tradeCount | string | 24H trade count |
Candlestick Chart
Currently supported intervals:
- 1 3 5 15 30
- 60 120 240 360 720
- D
- W
- M
If confirm
is true, this will indicate the last ticker price within the specified interval.
request
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Candle |
» interval | string | true | Interval |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["candle.1.BTCUSDT"]}')
response data
{
"topic":"candle.1.BTCUSDT",
"data":[
{
"start":1647511440000,
"end":1647511499999,
"interval":"1",
"open":"44111",
"close":"44111",
"high":"44111",
"low":"44111",
"volume":"0",
"turnover":"0",
"confirm":true,
"time":1647511500752
}
],
"ts":1647511500752,
"type":"snapshot"
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
»» start | integer | Start time |
»» symbol | string | Symbol |
»» interval | string | Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W" |
»» low | string | Low price |
»» high | string | High price |
»» open | string | Open price |
»» close | string | Close price |
»» volume | string | Trading volume |
»» turnover | string | Turnover |
»» confirm | string | If it is the last tick of this candle |
»» time | string | Current time |
All Tickers
Get latest information for all symbols.
This topic only utilizes the update field. Both the delete and insert fields are null. If a key is not found in the update field, its value has not changed.
Request
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Instrument info |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["instrumentInfo.all"]}')
response
{
"topic":"instrumentInfo.all",
"data":[
{
"s":"LINKUSDT",
"p":"6.966",
"pr":"-0.0510829587249694",
"h":"7.401",
"l":"6.931",
"op":"6.966",
"xp":"6.965",
"to":"37279.7137",
"v":"5128.7",
"fr":"0.0000125",
"o":"5647.1",
"tc":"0"
},
{
"s":"BTCUSDT",
"p":"21572.5",
"pr":"-0.0194318181818182",
"h":"25306.5",
"l":"17001.5",
"op":"21412.060000000002752512",
"xp":"21409.83",
"to":"1334891.4545",
"v":"64.858",
"fr":"0.0000125",
"o":"49.598",
"tc":"0"
},
{
"s":"ETHUSDT",
"p":"1680.45",
"pr":"-0.0150631538844767",
"h":"1805.65",
"l":"1680.45",
"op":"1654.64",
"xp":"1654.1",
"to":"664502.346",
"v":"389.16",
"fr":"0.0000125",
"o":"375.87",
"tc":"0"
},
{
"s":"DOGEUSDT",
"p":"0.0621",
"pr":"-0.1013024602026049",
"h":"0.1481",
"l":"0.0501",
"mp":"0.06773",
"xp":"0.0677",
"to":"5007.69",
"v":"70977",
"fr":"0.0000125",
"o":"43216",
"tc":"0"
}
],
"type":"snapshot",
"ts":1661500091389816
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
»» s | string | Symbol |
»» pr | string | 24H change (%) |
»» p | string | Last price |
»» h | string | 24H highest price |
»» l | string | 24H lowest price |
»» mp | string | Mark price |
»» xp | string | Index price |
»» o | string | Open interest |
»» to | string | 24H turnover |
»» v | string | 24H trading volume |
»» fr | string | Funding rate |
»» tc | string | 24H trade count |
Private Websocket V3
Send Authority Request
- Use apiKeyCredentials.secret sign, the rule as code
- The topic can be subscribed to during authentication
- Send authority request
- After each successful subscription, the client will receive the snapshot (full data)
- Type : snapshot means full data, delta means incremental data. If it is none, type will default to snapshot.
const apiKeyCredentials = {"key":"f6c1e736-fa6b-01df-2822-b9359b3918ae","secret":"sAVchdqy_n9zY7TOIDsqkyg0we3uF0_gGbvyIoob","passphrase":"Ri08mFrOt2Uaiym"}
const timestamp = 1647502440973;
const request_path = '/ws/accounts';
const http_method = 'GET';
const messageString: string = (
timestamp +
http_method +
request_path);
const key = Buffer.from(this.apiKeyCredentials.secret).toString('base64');
const hash = cryptojs.HmacSHA256(messageString, key);
const signature = hash.toString(cryptojs.enc.Base64);
//auth sign
const req = {
'type': 'login',
'topics': ['ws_notify_v1','ws_zk_accounts_v3'],
'httpMethod':http_method,
'requestPath':request_path,
'apiKey': apiKeyCredentials['key'],
'passphrase': apiKeyCredentials['passphrase'],
'timestamp': timestamp,
'signature': signature,
}
sendStr = {
"op": "login",
"args": [JSON.stringify(req)]
}
websocket.send(JSON.stringify(sendStr));
//add subscribe
websocket.send(JSON.stringify({"op":"subscribe","args":["ws_zk_accounts_v3", "ws_notify_v1"]}));
//cancel subscribe
websocket.send({"op":"unsubscribe","args":["ws_zk_accounts_v3","ws_notify_v1"]});
Response Errors:
request param error
{"success":false,"ret_msg":"msg param error","conn_id":"xxxxxxxxxxsasad"}
user authority error
{"success":false,"ret_msg":"login authority err,"conn_id":"xxxxxxxxxxsasad"}
Subscription Success Push Data
{
"contractAccounts": [
{
"l2Key": "0x711df5ffc57b033b22c65e38e4b3d8b1947eaee7403aaa4ff5847d31ca0b0700",
"accountId": "584232029671915612",
"createdAt": 1717953051513,
"makerFeeRate": "0.00000000",
"takerFeeRate": "0.00025",
"unrealizePnlPriceType": "MARKET_PRICE",
"userId": "1213724853023293440",
"updatedAt": 1718452222267,
"status": "NORMAL"
}
],
"spotWallets": [
{
"accountId": "584232029671915612",
"pendingDepositAmount": "0.000000000000000000",
"subAccountId": "0",
"balance": "28994.971947673600000001",
"pendingWithdrawAmount": "0.000000000000000000",
"pendingTransferInAmount": "0.000000000000000000",
"pendingTransferOutAmount": "0.000000000000000000",
"userId": "1213724853023293440",
"token": "USDT"
}
],
"spotAccounts": [
{
"accountId": "584232029671915612",
"createdAt": 1717128570381,
"subAccounts": [
{
"l2Key": "0x711df5ffc57b033b22c65e38e4b3d8b1947eaee7403aaa4ff5847d31ca0b0700",
"nonceVersion": 0,
"changePubKeyStatus": "FINISH",
"subAccountId": "0",
"nonce": 10
}
],
"defaultSubAccountId": "0",
"zkAccountId": "229",
"userId": "1213724853023293440",
"ethAddress": "0xc4c5036b68a42d8f1c6ba9ba8e5dd49ad5c1ef5c",
"nonce": 1,
"updatedAt": 1718789127665,
"status": "NORMAL"
}
],
"transfers": [],
"positionClosedTransactions": [],
"orders": [
{
"cumSuccessLiquidateFee": "0",
"symbol": "BTC-USDT",
"openSlParams": {
"triggerSize": "",
"triggerPrice": "",
"triggerPriceType": "UNKNOWN_PRICE_TYPE"
},
"cumSuccessFillFee": "0",
"type": "STOP_MARKET",
"isPositionTpsl": true,
"isDeleverage": false,
"createdAt": 1718104870661,
"isSetOpenTp": false,
"price": "52200.0",
"cumSuccessFillValue": "0",
"id": "588326929847812444",
"cancelReason": "UNKNOWN_ORDER_CANCEL_REASON",
"timeInForce": "IMMEDIATE_OR_CANCEL",
"updatedAt": 1718104870661,
"limitFee": "0.270000000000000000",
"side": "SELL",
"clientId": "4171300479007599",
"triggerPrice": "58000",
"triggerPriceType": "MARKET",
"expiresAt": 1720523854,
"openTpParams": {
"triggerSize": "",
"triggerPrice": "",
"triggerPriceType": "UNKNOWN_PRICE_TYPE"
},
"cumSuccessFillSize": "0",
"accountId": "584232029671915612",
"size": "0.010",
"reduceOnly": true,
"isSetOpenSl": false,
"isLiquidate": false,
"remainingSize": "0.010",
"status": "UNTRIGGERED"
},
{
"cumSuccessLiquidateFee": "0",
"symbol": "BTC-USDT",
"openSlParams": {
"triggerSize": "",
"triggerPrice": "",
"triggerPriceType": "UNKNOWN_PRICE_TYPE"
},
"cumSuccessFillFee": "0",
"type": "TAKE_PROFIT_MARKET",
"isPositionTpsl": true,
"isDeleverage": false,
"createdAt": 1718104870651,
"isSetOpenTp": false,
"price": "86900.0",
"cumSuccessFillValue": "0",
"id": "588326929805869404",
"cancelReason": "UNKNOWN_ORDER_CANCEL_REASON",
"timeInForce": "IMMEDIATE_OR_CANCEL",
"updatedAt": 1718104870651,
"limitFee": "0.440000000000000000",
"side": "SELL",
"clientId": "8086734464495621",
"triggerPrice": "79000",
"triggerPriceType": "MARKET",
"expiresAt": 1720523854,
"openTpParams": {
"triggerSize": "",
"triggerPrice": "",
"triggerPriceType": "UNKNOWN_PRICE_TYPE"
},
"cumSuccessFillSize": "0",
"accountId": "584232029671915612",
"size": "0.010",
"reduceOnly": true,
"isSetOpenSl": false,
"isLiquidate": false,
"remainingSize": "0.010",
"status": "UNTRIGGERED"
}
],
"positions": [
{
"symbol": "BTC-USDT",
"exitPrice": "0",
"side": "LONG",
"openValue": "710.000000000000000000",
"sumOpen": "0.011",
"fundingFee": "-2.094765226613730193",
"sumClose": "0",
"entryPrice": "64545.454545454545454545",
"accountId": "584232029671915612",
"customImr": "0.05000",
"size": "0.011",
"realizedPnl": "0",
"updatedAt": 1718104870634
},
{
"symbol": "BTC-USDT",
"exitPrice": "0",
"side": "SHORT",
"openValue": "0.000000000000000000",
"sumOpen": "0",
"fundingFee": "0",
"sumClose": "0",
"entryPrice": "0",
"accountId": "584232029671915612",
"customImr": "0.05000",
"size": "0.000",
"realizedPnl": "0",
"updatedAt": 1718099221473
}
],
"experienceMoney": [
{
"totalAmount": "0.000000000000000000",
"totalNumber": "0",
"recycledAmount": "0.000000000000000000",
"availableAmount": "0.000000000000000000",
"token": "USDT"
}
],
"contractWallets": [
{
"pendingDepositAmount": "0.000000000000000000",
"balance": "281.891287099786269807",
"pendingWithdrawAmount": "0.000000000000000000",
"pendingTransferInAmount": "0",
"pendingTransferOutAmount": "0",
"token": "USDT"
}
],
"deleverages": [
{
"symbol": "BTC-USDT",
"lightNumber": "5",
"side": "LONG"
}
],
"fills": []
}
Response Parameters
Parameter | Type | Required | Limit | Comment |
---|---|---|---|---|
» contents | object | true | none | |
»» contractAccounts | [object] | true | none | |
»»» l2Key | string | false | none | User's account l2Key |
»»» accountId | string | false | none | User's account ID |
»»» createdAt | integer | false | none | User's account create time |
»»» makerFeeRate | string | false | none | Maker fee rate |
»»» takerFeeRate | string | false | none | Taker fee rate |
»»» unrealizePnlPriceType | string | false | none | User unrealize Pnl price type, as 'MARKET_PRICE' |
»»» userId | string | false | none | User's user ID |
»»» updatedAt | integer | false | none | User's account update time |
»»» status | string | false | none | User's account status |
»» spotWallets | [object] | true | none | User's spot account |
»»» accountId | string | false | none | User's account ID |
»»» pendingDepositAmount | string | false | none | Pending deposit amount |
»»» subAccountId | string | false | none | User's sub account ID |
»»» balance | string | false | none | Asset balance |
»»» pendingWithdrawAmount | string | false | none | Pending withdraw amount |
»»» pendingTransferInAmount | string | false | none | Pending transfer in amount |
»»» pendingTransferOutAmount | string | false | none | Pending transfer out amount |
»»» userId | string | false | none | User's user ID |
»»» token | string | false | none | Asset token name |
»» spotAccounts | [object] | true | none | |
»»» accountId | string | false | none | User's account ID |
»»» createdAt | integer | false | none | User's spot account create time |
»»» subAccounts | [object] | false | none | User's sub accounts |
»»»» l2Key | string | false | none | User's sub account l2Key |
»»»» nonceVersion | integer | false | none | User's sub account nonce version |
»»»» changePubKeyStatus | string | false | none | User's sub account change pubKey status |
»»»» subAccountId | string | false | none | User's sub account ID |
»»»» nonce | integer | false | none | User's sub account nonce |
»»» defaultSubAccountId | string | false | none | User's zk default sub account ID |
»»» zkAccountId | string | false | none | User's zk account ID |
»»» userId | string | false | none | User's user ID |
»»» ethAddress | string | false | none | User's ethereum address |
»»» nonce | integer | false | none | User's account nonce |
»»» updatedAt | integer | false | none | User's account update time |
»»» status | string | false | none | User's account status |
»» transfers | [string] | true | none | |
»» positionClosedTransactions | [string] | true | none | |
»» orders | [object] | true | none | |
»»» cumSuccessLiquidateFee | string | true | none | Cumulative liquidate fee |
»»» symbol | string | true | none | Symbol |
»»» openSlParams | object | true | none | Open Sl order params |
»»»» triggerSize | string | true | none | Order trigger size |
»»»» triggerPrice | string | true | none | Order trigger price |
»»»» triggerPriceType | string | true | none | Order trigger type |
»»» cumSuccessFillFee | string | true | none | Cumulative fill fee |
»»» type | string | true | none | order type |
»»» isPositionTpsl | boolean | true | none | If the order is position Tpsl |
»»» isDeleverage | boolean | true | none | If the order is deleverage |
»»» createdAt | integer | true | none | The order created time |
»»» isSetOpenTp | boolean | true | none | If the order is set open Tp |
»»» price | string | true | none | Order Price |
»»» cumSuccessFillValue | string | true | none | Cumulative fill value |
»»» id | string | true | none | Order ID |
»»» cancelReason | string | true | none | Order cancel reason |
»»» timeInForce | string | true | none | Order timeInForce |
»»» updatedAt | integer | true | none | Order updated time |
»»» limitFee | string | true | none | Order limit fee |
»»» side | string | true | none | Order side |
»»» clientId | string | true | none | Order client ID |
»»» triggerPrice | string | true | none | Condition order trigger price |
»»» triggerPriceType | string | true | none | Condition order trigger type |
»»» expiresAt | integer | true | none | Order expired time |
»»» openTpParams | object | true | none | Open Tp order params |
»»»» triggerSize | string | true | none | Order trigger size |
»»»» triggerPrice | string | true | none | Order trigger price |
»»»» triggerPriceType | string | true | none | Order trigger type |
»»» cumSuccessFillSize | string | true | none | umulative fill size |
»»» size | string | true | none | Order size |
»»» reduceOnly | boolean | true | none | If the order is reduce only |
»»» isSetOpenSl | boolean | true | none | If the order is set open Sl |
»»» isLiquidate | boolean | true | none | If the order is liquidate |
»»» remainingSize | string | true | none | The order remaining size |
»»» status | string | true | none | The order's status |
»» positions | [object] | true | none | Open positions |
»»» symbol | string | true | none | Symbol |
»»» exitPrice | string | true | none | |
»»» side | string | true | none | Side |
»»» openValue | string | true | none | Position open value |
»»» sumOpen | string | true | none | Position cumulative opened size |
»»» fundingFee | string | true | none | Position funding fee |
»»» sumClose | string | true | none | Position cumulative closed size |
»»» entryPrice | string | true | none | Position cumulative entry price |
»»» accountId | string | true | none | User's account ID |
»»» customImr | string | true | none | Symbol's custom initial margin rate |
»»» size | string | true | none | Position size |
»»» realizedPnl | string | true | none | Postion realized Pnl |
»»» updatedAt | integer | true | none | Postion update time |
»» experienceMoney | [object] | true | none | Experience money |
»»» totalAmount | string | false | none | Total experience money value |
»»» totalNumber | string | false | none | Total experience money number |
»»» recycledAmount | string | false | none | Recycled experience money value |
»»» availableAmount | string | false | none | Available experience money amount |
»»» token | string | false | none | Experience money token |
»» contractWallets | [object] | true | none | |
»»» pendingDepositAmount | string | false | none | Pending deposit amount |
»»» balance | string | false | none | Wallet balance |
»»» pendingWithdrawAmount | string | false | none | Pending withdrawal amount |
»»» pendingTransferInAmount | string | false | none | Pending inbound transfer amount |
»»» pendingTransferOutAmount | string | false | none | Pending outbound transfer amount |
»»» token | string | false | none | Asset token name |
»» deleverages | [object] | true | none | |
»»» symbol | string | false | none | Symbol name |
»»» lightNumber | string | false | none | ADL ranking |
»»» side | string | false | none | Open side |
»» fills | [string] | true | none | Fills |
» topic | string | true | none | Subscribe topic |
» type | string | true | none | |
» timestamp | integer | true | none | Message time |
Order Submission Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"orders":[
{
"symbol":"ETH-USDT",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"PENDING"
}
]
}
}
Post-Submission of Maker Order Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
{
"symbol":"ETH-USDT",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"OPEN"
}
],
"accounts":[
],
"transfers":[
]
}
}
Post-Cancel Order Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
{
"symbol":"ETH-USDT",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"CANCELED"
}
],
"accounts":[
],
"transfers":[
]
}
}
Successful Order Execution Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"fills":[
{
"symbol":"ETH-USDT",
"side":"BUY",
"orderId":"2048046080",
"fee":"0.625000",
"liquidity":"TAKER",
"accountId":"1024000",
"createdAt":1652185521361,
"isOpen":true,
"size":"0.500",
"price":"2500.0",
"quoteAmount":"1250.0000",
"id":"2048000182272",
"updatedAt":1652185678345
}
],
"positions":[
{
"symbol":"ETH-USDT",
"exitPrice":"0",
"side":"LONG",
"maxSize":"2820.000",
"sumOpen":"1.820",
"sumClose":"0.000",
"netFunding":"0.000000",
"entryPrice":"2500.000000000000000000",
"accountId":"1024000",
"createdAt":1652179377769,
"size":"1.820",
"realizedPnl":"0",
"closedAt":1652185521392,
"updatedAt":1652185521392
}
],
"orders":[
{
"symbol":"ETH-USDT",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"1250.0000",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0.500",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"FILLED"
}
],
"accounts":[
],
"transfers":[
]
}
}
Deposit Success Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
],
"wallets":[
{
"balance":"438.486000",
"asset":"USDT"
}
]
}
}
Withdrawal Request Submission Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_zk_accounts_v3",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
],
"accounts":[
],
"transfers":[
{
"status":"QUEUED",
"transactionId":"39190120",
"id":"89abf9d72432",
"type":"WITHDRAWAL",
"creditAsset":"USDT",
"creditAmount":"100",
"transactionHash":null,
"confirmedAt":null,
"createdAt":1647502440973,
"expiresAt":1647502440973
}
]
}
}
Notify Message Push
{
"contents": {
"unreadNum": 24,
"notifyMsgList": [
{
"id": "1145486332832022528",
"category": 1,
"lang": "en",
"title": "Deposit success ",
"content": "Your deposit of 100.000000 USDT has been confirmed.",
"androidLink": "",
"iosLink": "",
"webLink": "",
"read": false,
"createdTime": 1682357834534
}
...
]
},
"topic": "ws_notify_v1",
"type": "snapshot"
}
Response Parameters
Parameter | Type | Comment |
---|---|---|
» notifyMsgList | object | Notification message list |
»» id | string | Notification ID |
»» category | int | Notification category |
»» lang | string | Language |
»» title | string | Title |
»» content | string | Content |
»» androidLink | string | Android link |
»» iosLink | string | Ios link |
»» webLink | string | Web link |
»» read | bool | If notification has been read |
»» createdTime | int | Created time |
New Notification Message Push
Response
{
"contents": {
"notify_list": [
{
"id": "1145486332832022528",
"category": "NOTIFY_CATEGORY_ACCOUNT",
"lang": "en",
"title": "Deposit success ",
"content": "Your deposit of 100.000000 USDT has been confirmed.",
"androidLink": "",
"iosLink": "",
"webLink": "",
"read": false,
"createdTime": 1682357834534
}
]
},
"topic": "ws_notify_v1",
"type": "delta"
}
Websocket V2 for Pro
Websocket Endpoint:
Timestamp = Current Unix Timestamp
Testnet:
Public Websocket API
wss://quote-testnet.pro.apex.exchange/realtime_public?v=2×tamp=1661415017232
Private Websocket API
wss://quote-testnet.pro.apex.exchange/realtime_private?v=2×tamp=1661415017233
Mainnet:
Public Websocket API
wss://quote.pro.apex.exchange/realtime_public?v=2×tamp=1661415017232
Private Websocket API
wss://quote.pro.apex.exchange/realtime_private?v=2×tamp=1661415017233
Public Websocket V2
Due to network complexity, your may get disconnected at any time. Please follow the instructions below to ensure that you receive WebSocket messages on time:
- Keep connection alive by sending heartbeat packet
- Reconnect as soon as possible if disconnected
Heartbeat Packet
To avoid networks or program issues, we recommend that you send the ping heartbeat packet every 15 seconds to maintain the WebSocket connection.
How to Send
ws.send('{"op":"ping","args":["1661415022821"]}');
Response Example
'{"op":"pong","args":["1661415030233"]}'
When receiving a ping message from the server, a pong message needs to be returned to the server.
ws.send('{"op":"pong","args":["1661415022821"]}');
Server Check With Ping Pong Test:
- Check the connection ever 15 seconds and look at the client timestamp
- If the difference between the client timestamp and the current timestamp exceeds 150s, the connection will be closed
How to Subscribe to Topics
Understanding Websocket Filters
After establishing the connection, one can subscribe to a new topic by sending a JSON request. The specific formats are as follows:
ws.send('{"op": "subscribe", "args": ["topic.filter"]}');
The topic indicates the data you would like to receive whilst the filter parses for the specific data you desire, for example, the symbol. The topic is mandatory but the filter is optional.
To subscribe to more than one topic, simply list multiple topics out like this:
ws.send('{"op": "subscribe", "args": ["topic.filter", "topic.filter"]}');
Unsubscribing From Websocket Topics
You can dynamically subscribe and unsubscribe from topics (with or without filters) without websocket disconnection as follows:
ws.send('{"op": "unsubscribe", "args": ["topic.filter", "topic.filter"]}');
Intervals
Some topics are pushed out at specific intervals. If the args contains a millisecond parameter, such as 100ms, this topic is pushed at intervals. Otherwise, topis will be pushed constantly.
Understanding Subscription Response
Each subscription will have a response. You can determine whether the subscription is successful based on the response.
{
"success":true,
"ret_msg":"",
"conn_id":"647c3de8-6f66-44ab-a323-72067589372e",
"request":{
"op":"subscribe",
"args":[
"instrumentInfo.H.BTCUSDC"
]
}
}
Depth
Fetches the orderbook with a depth of 25 or 200 orders per side.
After the subscription response, the first response will be the snapshot response. This shows the entire order book. The data is sorted by price, starting with the lowest buys and ending with the highest sells.
Following this, all responses are in the delta format, which represents updates to the order book relative to the last response.
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Order book |
» limit | string | true | 25 or 200 |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["orderBook200.H.BTCUSDC"]}');
response
{
"topic":"orderBook200.H.BTCUSDC",
"type":"delta",
"data":{
"s":"BTCUSDC",
"b":[
[
"18990.5",
"0"
],
[
"18979.5",
"0"
]
],
"a":[
[
"19010.5",
"0"
],
[
"19037.5",
"0"
]
],
"u":249003
},
"cs":44132980,
"ts":1661416027956272
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
» s | string | Symbol |
» u | int | Update ID: According to whether the Update ID is continuous, the client will need to determine if there is a packet loss in the process of receiving data. Snapshot resets the Update ID and it will start counting again from 1. |
» b | array | Buy[price,size], size set as 0 will delete this item |
» a | array | Sell[price,size], size set as 0 will delete this item |
Trade
Get Trades for symbol.
TickDirection {
"PlusTick"
"ZeroPlusTick"
"MinusTick"
"ZeroMinusTick"
}
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Recently trade |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["recentlyTrade.H.BTCUSDC"]}');
response
{
"topic":"recentlyTrade.H.BTCUSDC",
"type":"snapshot",
"data":[
{
"T":1647502440973,
"s":"BTCPERP",
"S":"Buy",
"v":"1.000",
"p":"43513.00",
"L":"PlusTick",
"i":"a3afbef7-d8de-5b87-a32f-d06f041a249d"
}
],
"cs":44132980,
"ts":1661416027956272
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot |
» s | string | Symbol |
» T | int | Timestamp |
» S | string | Buy or Sell |
» v | string | Volume |
» p | string | Price |
» L | string | Tick direction |
» i | string | Order ID |
Ticker
Get latest information for symbol.
This topic only utilizes the update field. Both the delete and insert fields are null. If a key is not found in the update field, its value has not changed.
Request Parameters
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Instrument info |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["instrumentInfo.H.BTCUSDC"]}')
response
{
"topic":"instrumentInfo.H.BTCUSDC",
"type":"snapshot",
"data":{
"symbol":"BTCUSDC",
"lastPrice":"21572.5",
"price24hPcnt":"-0.0194318181818182",
"highPrice24h":"25306.5",
"lowPrice24h":"17001.5",
"turnover24h":"1334891.4545",
"volume24h":"64.896",
"nextFundingTime":"2022-08-26T08:00:00Z",
"oraclePrice":"21412.060000000002752512",
"indexPrice":"21409.82",
"openInterest":"49.598",
"tradeCount":"0",
"fundingRate":"0.0000125",
"predictedFundingRate":"0.0000125"
},
"cs":44939063,
"ts":1661500091955487
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
»» symbol | string | Symbol |
»» price24hPcnt | string | 24H change (%) |
»» lastPrice | string | Last price |
»» highPrice24h | string | 24H highest price |
»» lowPrice24h | string | 24H lowest price |
»» oraclePrice | string | Oracle price |
»» indexPrice | string | Index price |
»» openInterest | string | Open interest |
»» turnover24h | string | 24H turnover |
»» volume24h | string | 24H trading volume |
»» fundingRate | string | Funding rate |
»» predictedFundingRate | string | Predicted funding rate |
»» nextFundingTime | string | Next funding rate |
»» tradeCount | string | 24H trade count |
Candlestick Chart
Currently supported intervals:
- 1 3 5 15 30
- 60 120 240 360 720
- D
- W
- M
If confirm
is true, this will indicate the last ticker price within the specified interval.
request
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Candle |
» interval | string | true | Interval |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["candle.1.BTCUSDC"]}')
response data
{
"topic":"candle.1.BTCUSDC",
"data":[
{
"start":1647511440000,
"end":1647511499999,
"interval":"1",
"open":"44111",
"close":"44111",
"high":"44111",
"low":"44111",
"volume":"0",
"turnover":"0",
"confirm":true,
"time":1647511500752
}
],
"ts":1647511500752,
"type":"snapshot"
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
» type | string | Snapshot or delta |
»» start | integer | Start time |
»» symbol | string | Symbol |
»» interval | string | Candlestick chart time indicators: Numbers represent minutes, D for Days, M for Month and W for Week — 1 5 15 30 60 120 240 360 720 "D" "M" "W" |
»» low | string | Low price |
»» high | string | High price |
»» open | string | Open price |
»» close | string | Close price |
»» volume | string | Trading volume |
»» turnover | string | Turnover |
»» confirm | string | If it is the last tick of this candle |
»» time | string | Current time |
All Tickers
Get latest information for all symbols.
This topic only utilizes the update field. Both the delete and insert fields are null. If a key is not found in the update field, its value has not changed.
Request
Parameter | Type | Limit | Comment |
---|---|---|---|
» op | string | true | Subscribe |
» args | string | true | Instrument info |
» frequency | string | true | H means High frequency, M means middle frequency |
» symbol | string | true | Symbol |
How to Subscribe
ws.send('{"op":"subscribe","args":["instrumentInfo.all"]}')
response
{
"topic":"instrumentInfo.all",
"data":[
{
"s":"LINKUSDC",
"p":"6.966",
"pr":"-0.0510829587249694",
"h":"7.401",
"l":"6.931",
"op":"6.966",
"xp":"6.965",
"to":"37279.7137",
"v":"5128.7",
"fr":"0.0000125",
"o":"5647.1",
"tc":"0"
},
{
"s":"BTCUSDC",
"p":"21572.5",
"pr":"-0.0194318181818182",
"h":"25306.5",
"l":"17001.5",
"op":"21412.060000000002752512",
"xp":"21409.83",
"to":"1334891.4545",
"v":"64.858",
"fr":"0.0000125",
"o":"49.598",
"tc":"0"
},
{
"s":"ETHUSDC",
"p":"1680.45",
"pr":"-0.0150631538844767",
"h":"1805.65",
"l":"1680.45",
"op":"1654.64",
"xp":"1654.1",
"to":"664502.346",
"v":"389.16",
"fr":"0.0000125",
"o":"375.87",
"tc":"0"
},
{
"s":"DOGEUSDC",
"p":"0.0621",
"pr":"-0.1013024602026049",
"h":"0.1481",
"l":"0.0501",
"op":"0.06773",
"xp":"0.0677",
"to":"5007.69",
"v":"70977",
"fr":"0.0000125",
"o":"43216",
"tc":"0"
}
],
"type":"snapshot",
"ts":1661500091389816
}
Response data
Parameter | Type | Comment |
---|---|---|
» topic | string | Same as request args |
»» s | string | Symbol |
»» pr | string | 24H change (%) |
»» p | string | Last price |
»» h | string | 24H highest price |
»» l | string | 24H lowest price |
»» op | string | Oracle price |
»» xp | string | Index price |
»» o | string | Open interest |
»» to | string | 24H turnover |
»» v | string | 24H trading volume |
»» fr | string | Funding rate |
»» tc | string | 24H trade count |
Private Websocket V2
Send Authority Request
- Use apiKeyCredentials.secret sign, the rule as code
- The topic can be subscribed to during authentication
- Send authority request
- After each successful subscription, the client will receive the snapshot (full data)
- Type : snapshot means full data, delta means incremental data. If it is none, type will default to snapshot.
const apiKeyCredentials = {"key":"f6c1e736-fa6b-01df-2822-b9359b3918ae","secret":"sAVchdqy_n9zY7TOIDsqkyg0we3uF0_gGbvyIoob","passphrase":"Ri08mFrOt2Uaiym"}
const timestamp = 1647502440973;
const request_path = '/ws/accounts';
const http_method = 'GET';
const messageString: string = (
timestamp +
http_method +
request_path);
const key = Buffer.from(this.apiKeyCredentials.secret).toString('base64');
const hash = cryptojs.HmacSHA256(messageString, key);
const signature = hash.toString(cryptojs.enc.Base64);
//auth sign
const req = {
'type': 'login',
'topics': ['ws_notify_v1','ws_accounts_v2'],
'httpMethod':http_method,
'requestPath':request_path,
'apiKey': apiKeyCredentials['key'],
'passphrase': apiKeyCredentials['passphrase'],
'timestamp': timestamp,
'signature': signature,
}
sendStr = {
"op": "login",
"args": [JSON.stringify(req)]
}
websocket.send(JSON.stringify(sendStr));
//add subscribe
websocket.send(JSON.stringify({"op":"subscribe","args":["ws_accounts_v1", "ws_notify_v1"]}));
//cancel subscribe
websocket.send({"op":"unsubscribe","args":["ws_accounts_v1","ws_notify_v1"]});
Response Errors:
request param error
{"success":false,"ret_msg":"msg param error","conn_id":"xxxxxxxxxxsasad"}
user authority error
{"success":false,"ret_msg":"login authority err,"conn_id":"xxxxxxxxxxsasad"}
Subscription Success Push Data
{
"topic":"ws_accounts_v2",
"type":"snapshot",
"timestamp":1652185029033,
"contents":{
"transfers":[
{
"createdAt":1652185839042,
"creditAsset":"USDC",
"id":"2048047104",
"type":"DEPOSIT",
"creditAmount":"100.000000",
"confirmedAt":1652185839042,
"transactionHash":"0x7369d3f8d860b10a443c6a6d55c0ea4f2ab106f264a8ad28b822a33cba6aead8",
"status":"SUCCESS_L2_APPROVED"
}
],
"orders":[
{
"symbol":"ETH-USDC",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"1250.0000",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"cumSuccessFillSize":"0.500",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"status":"FILLED"
}
],
"positions":[
{
"symbol":"ETH-USDC",
"entryPrice":"2500.0000",
"exitPrice":"0",
"size":"1.820",
"side":"LONG",
"maxSize":"2820.000",
"sumOpen":"1.820",
"sumClose":"0.000",
"netFunding":"0.000000",
"accountId":"1024000",
"createdAt":1652179377769,
"realizedPnl":"0",
"updatedAt":1652185521392
}
],
"wallets":[
{
"balance":"438.486000",
"asset":"USDC"
"pendingDepositAmount": "5000",
"pendingTransferInAmount": "2000",
"pendingTransferOutAmount": "3003",
"pendingWithdrawAmount": "3233",
}
],
"accounts":[
{
"createdAt":1652174136588,
"positionId":"1024000",
"starkKeyYCoordinate":"0x070880c806d8adfc6ea3fafeb9ea269022f8d8aa797849d9f98660006f33e44f",
"userId":"1144093794426437632",
"starkKey":"0x0408e25bcadc4a25412258f851d171cb8cb9dfe529f69f2e1b93a9caaf983bc2",
"updatedAt":1652174136588,
"status":"NORMAL"
}
],
"fills": [
{
"symbol":"ETH-USDC",
"side":"BUY",
"orderId":"2048046080",
"fee":"0.625000",
"liquidity":"TAKER",
"accountId":"1024000",
"createdAt":1652185521361,
"isOpen":true,
"status":"SUCCESS",
"size":"0.500",
"price":"2500.0",
"quoteAmount":"1250.0000",
"id":"2048000182272",
"updatedAt":1652185678345
},
"positionClosedTransactions": [{
""
}]
],
"deleverages": [
{
account_id = "1";
symbol = "BTC-USDC";
side = "LONG";
profit_rate = "20";
light_numbers = 5;
created_time = 1652185678345;
}
]
}
}
Response Parameters
Parameter | Type | Comment |
---|---|---|
» account | object | none |
»» starkKey | string | User starkKey |
»» starkKeyYCoordinate | string | User starkKeyYCoordinate |
»» positionId | string | User accountid |
»» userId | string | User ID |
»» makerFeeRate | string | Maker fee rate |
»» takerFeeRate | string | Taker fee rate |
»» createdAt | integer | Created at |
»» status | string | Account status |
» wallets | [object] | User wallet |
»» asset | string | Asset |
»» balance | string | Wallet balance |
»» pendingDepositAmount | string | Pending deposit amount |
»» pendingWithdrawAmount | string | Pending withdrawal amount |
»» pendingTransferOutAmount | string | Pending outbound transfer amount |
»» pendingTransferInAmount | string | Pending inbound transfer amount |
» openPositions | [object] | Open positions |
»» symbol | string | Symbol |
»» side | string | Side |
»» size | string | Size |
»» entryPrice | string | Entry price |
»» fee | string | Order fee |
»» createdAt | integer | Created at |
»» updatedTime | integer | Updated time |
»» netFunding | string | Funding fee |
»» maxSize | string | Max position size |
»» realizedPnl | string | Close profit and loss |
» fills | [object] | |
»» symbol | string | Symbol |
»» side | string | Order side |
»» size | string | Fill size |
»» price | string | Fill price |
»» fee | string | Fill fee |
»» createdAt | integer | Open order fill time |
»» updatedAt | integer | Open order fill update time |
»» isOpen | bool | Is this an open order? |
»» id | string | Fill ID |
»» orderId | string | Order ID |
»» liquidity | string | Taker or Maker |
»» status | string | Fill status |
» orders | [object] | |
»» symbol | string | Symbol |
»» side | string | Order side |
»» size | string | Order size |
»» price | string | Order open price |
»» type | string | Order Type |
»» createdAt | integer | Open order time |
»» updatedAt | integer | Order update time |
»» isDeleverage | bool | Deleverage order? |
»» isLiquidate | bool | Liquidate order? |
»» reduceOnly | bool | Open reduce order only |
»» unfillableAt | int | Order expired time |
»» id | string | ID |
»» orderId | string | Order ID |
»» liquidity | string | Taker or MAKER |
»» status | string | Order status |
»» cumSuccessFillFee | string | Cumulative success fill fee |
»» trailingPercent | string | Trailing-stop |
»» cumSuccessFillValue | string | Cumulative success fill value |
»» cancelReason | string | Reason for cancelation |
»» timeInForce | string | Open order timeInForce |
»» limitFee | string | Open order max. fee |
»» clientOrderId | string | Client to create randomized ID |
»» triggerPrice | string | Trigger Price |
»» cumSuccessFillSize | string | Cumulative Success Fill Size |
» transfers | [object] | Withdraw and deposit |
»» createdAt | integer | Created time |
»» confirmedAt | integer | Confirm time |
»» creditAsset | string | Asset |
»» type | bool | Transfer type |
»» id | string | Transfer ID |
»» creditAmount | string | Transfer amount |
»» transactionHash | string | Tx hash |
»» status | string | Status |
» deleverages | [object] / deleverages | |
»» symbol | string | Symbol |
»» side | string | Postion side |
»» profit_rate | string | Postion profit rate |
»» light_numbers | string | ADL ranking |
»» created_time | int | Created time |
Order Submission Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"orders":[
{
"symbol":"ETH-USDC",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"PENDING"
}
]
}
}
Post-Submission of Maker Order Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
{
"symbol":"ETH-USDC",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"OPEN"
}
],
"accounts":[
],
"transfers":[
]
}
}
Post-Cancel Order Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
{
"symbol":"ETH-USDC",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"0",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"CANCELED"
}
],
"accounts":[
],
"transfers":[
]
}
}
Successful Order Execution Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"fills":[
{
"symbol":"ETH-USDC",
"side":"BUY",
"orderId":"2048046080",
"fee":"0.625000",
"liquidity":"TAKER",
"accountId":"1024000",
"createdAt":1652185521361,
"isOpen":true,
"size":"0.500",
"price":"2500.0",
"quoteAmount":"1250.0000",
"id":"2048000182272",
"updatedAt":1652185678345
}
],
"positions":[
{
"symbol":"ETH-USDC",
"exitPrice":"0",
"side":"LONG",
"maxSize":"2820.000",
"sumOpen":"1.820",
"sumClose":"0.000",
"netFunding":"0.000000",
"entryPrice":"2500.000000000000000000",
"accountId":"1024000",
"createdAt":1652179377769,
"size":"1.820",
"realizedPnl":"0",
"closedAt":1652185521392,
"updatedAt":1652185521392
}
],
"orders":[
{
"symbol":"ETH-USDC",
"cumSuccessFillFee":"0.625000",
"trailingPercent":"0",
"type":"LIMIT",
"unfillableAt":1654779600000,
"isDeleverage":false,
"createdAt":1652185521339,
"price":"2500.0",
"cumSuccessFillValue":"1250.0000",
"id":"2048046080",
"cancelReason":"",
"timeInForce":1,
"updatedAt":1652185521392,
"limitFee":"0.625000",
"side":"BUY",
"clientOrderId":"522843990",
"triggerPrice":"",
"expiresAt":1654779600000,
"cumSuccessFillSize":"0.500",
"accountId":"1024000",
"size":"0.500",
"reduceOnly":false,
"isLiquidate":false,
"remainingSize":"0.000",
"status":"FILLED"
}
],
"accounts":[
],
"transfers":[
]
}
}
Deposit Success Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
],
"wallets":[
{
"balance":"438.486000",
"asset":"USDC"
}
]
}
}
Withdrawal Request Submission Push
{
"type":"delta",
"timestamp":1647502440973,
"topic":"ws_accounts_v1",
"contents":{
"fills":[
],
"positions":[
],
"orders":[
],
"accounts":[
],
"transfers":[
{
"status":"QUEUED",
"transactionId":"39190120",
"id":"89abf9d72432",
"type":"WITHDRAWAL",
"creditAsset":"USDC",
"creditAmount":"100",
"transactionHash":null,
"confirmedAt":null,
"createdAt":1647502440973,
"expiresAt":1647502440973
}
]
}
}
Notify Message Push
{
"contents": {
"unreadNum": 24,
"notifyMsgList": [
{
"id": "1145486332832022528",
"category": 1,
"lang": "en",
"title": "Deposit success ",
"content": "Your deposit of 100.000000 USDC has been confirmed.",
"androidLink": "",
"iosLink": "",
"webLink": "",
"read": false,
"createdTime": 1682357834534
}
...
]
},
"topic": "ws_notify_v1",
"type": "snapshot"
}
Response Parameters
Parameter | Type | Comment |
---|---|---|
» notifyMsgList | object | Notification message list |
»» id | string | Notification ID |
»» category | int | Notification category |
»» lang | string | Language |
»» title | string | Title |
»» content | string | Content |
»» androidLink | string | Android link |
»» iosLink | string | Ios link |
»» webLink | string | Web link |
»» read | bool | If notification has been read |
»» createdTime | int | Created time |
New Notification Message Push
Response
{
"contents": {
"notify_list": [
{
"id": "1145486332832022528",
"category": "NOTIFY_CATEGORY_ACCOUNT",
"lang": "en",
"title": "Deposit success ",
"content": "Your deposit of 100.000000 USDC has been confirmed.",
"androidLink": "",
"iosLink": "",
"webLink": "",
"read": false,
"createdTime": 1682357834534
}
]
},
"topic": "ws_notify_v1",
"type": "delta"
}
Gnosis Multi-Sig Wallet Endpoint for Market Makers
v1.0.0
Creating a Gnosis Safe Multi-Sig Wallet
Click on https://gnosis-safe.io/app/
to access the application on desktop. Refer to the document gnosis_safe and create your multi-sig wallet according to the following steps:
- Select the Ethereum network
- You will need to connect an existing wallet to Gnosis Safe to create an account and ensure that you have some ETH in the wallet to pay for transaction fees that may be incurred during the setup
- Enter the wallet name and include the names, addresses and number of stakeholders involved in the authentication of withdrawals from this multi-sig wallet. Once you're certain that all information entered is accurate, you can proceed with the creation of the Gnosis Safe wallet
- Transfer funds into the Gnosis Safe wallet
StarkWare Smart Contract ABI Code
[
{
"inputs": [
{
"internalType": "uint256",
"name": "starkKey",
"type": "uint256"
},
{
"internalType": "uint256", "name": "assetType",
"type": "uint256"
},
{
"internalType": "uint256", "name": "vaultId",
"type": "uint256"
},
{
"internalType": "uint256", "name": "quantizedAmount", "type": "uint256"
}
],
"name": "depositERC20",
"outputs": [], "stateMutability": "nonpayable", "type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "starkKey",
"type": "uint256"
}
],
"name": "getEthKey",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "starkKey",
"type": "uint256"
},
{
"internalType": "uint256", "name": "assetId",
"type": "uint256"
}
],
"name": "getWithdrawalBalance",
"outputs": [
{
"internalType": "uint256", "name": "balance",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "ethKey",
"type": "address"
},
{
"internalType": "uint256", "name": "starkKey",
"type": "uint256"
},
{
"internalType": "bytes", "name": "starkSignature", "type": "bytes"
}
],
"name": "registerEthAddress",
"outputs": [], "stateMutability": "nonpayable", "type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "starkKey",
"type": "uint256"
},
{
"internalType": "uint256", "name": "assetId",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [], "stateMutability": "nonpayable", "type": "function"
}
]
Generating ApexPro L2key Account
- Use Apex Pro's python SDK: Authorize your Ethereum private keys to create corresponding public and private Stark Keys — refer to python codes
Generating starkKey
from apexpro.http_private import HttpPrivate
from apexpro.constants import APEX_HTTP_TEST, NETWORKID_TEST, APEX_HTTP_MAIN, NETWORKID_MAIN
priKey = "your eth private key"
client = HttpPrivate(APEX_HTTP_MAIN, network_id=NETWORKID_MAIN, eth_private_key=priKey)
configs = client.configs()
stark_key_pair_with_y_coordinate = client.derive_stark_key(client.default_address)
- - Use Apex Pro's python SDK: Proceed with the register_user method and enter the gnosis-safe multi-sig wallet address in eth_mul_address to generate the account ID — Refer to python codes
register_user method to generate account ID
nonceRes = client.generate_nonce(starkKey=stark_key_pair_with_y_coordinate['public_key'],ethAddress=client.default_address,chainId=NETWORKID_MAIN)
regRes = client.register_user(nonce=nonceRes['data']['nonce'],starkKey=stark_key_pair_with_y_coordinate['public_key'],stark_public_key_y_coordinate=stark_key_pair_with_y_coordinate['public_key_y_coordinate'],ethereum_address=client.default_address,
eth_mul_address="your mul eth address")
print(regRes['data']['account']['positionId']) #account ID
- Trigger the StarkWare contract interaction via the gnosis-safe multi-sig wallet by using the registerEthAddress method under StarkWare's contract, then linking the user's L2 data with the Gnosis Safe wallet
- starkware Contract Address:
0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb
- ethKey: Corresponding Gnosis Safe multi-sig wallet address
- starkKey: L2 account stark_key_pair public_key
stark_key_pair_with_y_coordinate['public_key']
- starkSignature: Authentication signature needs to be generated, refer to python codes
- starkware Contract Address:
Generating Stark Signature
from apexpro.helpers.request_helpers import calc_bind_owner_key_sig_hash, starkex_sign, starkex_verify
hash = calc_bind_owner_key_sig_hash("your stark_key_pair pubic key", "your eth address")
print(hash.hex())
signature = starkex_sign(hash, "your stark_key_pair private key")
print("signature:" + signature)
- - After the Gnosis Safe wallet is linked, all transactions (L2) will require authentication by the Gnosis Safe multi-sig wallet
Authorize StarkWare Contract to Transfer USDC via Gnosis Safe
As deposits will be processed through StarkWare, you will need to authorize the StarkWare contract to transfer your USDC assets.
- Proceed with a new transaction via Gnosis Safe
- Enter transaction details:
- Enter the USDC contract address:
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
- Enter the USDC contract ABI and select the approve method
- Enter the USDC contract address:
USDC Contract ABI
[{
"inputs": [{
"internalType": "address",
"name": "spender",
"type": "address" }, {
"internalType": "uint256", "name": "value",
"type": "uint256"
}],
"name": "approve", "outputs": [{
"internalType": "bool", "name": "",
"type": "bool"
}],
"stateMutability": "nonpayable", "type": "function"
}]
- Spender address (Enter StarkWare's contract address):
0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb
- value: For accuracy, we recommend that you enter the correct deposit amount (to 6 decimal places), e.g. 100 USDC should be entered as 100000000
Deposit via Gnosis Safe
- Trigger a new transaction on Gnosis Safe
- Enter transaction details:
- StarkWare Contract Address:
0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb
- StarkWare Contract ABI: Refer to the complete StarkWare contract ABI code
- Select
depositErc20
method and enter the corresponding amount - starkKey: L2 account stark_key_pair public_key
stark_key_pair_with_y_coordinate['public_key']
- assetType: Corresponding asset type
0x02893294412a4c8f915f75892b395ebbf6859ec246ec365c3b1f56f47c3a0a5d
- valutId: L2 account to asset pool, account_id:
351667704786059600
- quantizeAmount: USDC deposit amount, to 6 decimal places e.g. 100 USDC should be entered as 100000000
- StarkWare Contract Address:
- After reviewing the parameters and ensuring that they are correct, confirm the deposit transaction
- For other stakeholders involved in the Gnosis Safe wallet, use your personal wallet to authorize the transaction and complete the deposit process
Checking for Withdrawable Balance With Gnosis Safe
- Trigger a new transaction on Gnosis Safe
- Enter transaction details:
- StarkWare Contract Address:
0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb
- StarkWare Contract ABI: Refer to the complete StarkWare contract ABI code
- Select the
getWithdrawalBalance
method and enter the corresponding parameters; you can check the available withdrawable balance (you will need to remove 6 zeros from the amount) - starkKey: Enter the gnosis-safe multi-sig wallet address, please ensure that this is not the L2 account stark_key_pair public_key
- assetType: Corresponding asset type
0x02893294412a4c8f915f75892b395ebbf6859ec246ec365c3b1f56f47c3a0a5d
- StarkWare Contract Address:
Initiating Withdrawals With Gnosis Safe
- Trigger a new transaction on Gnosis Safe
- Enter transaction details:
- Starkware Contract Address:
0xA1D5443F2FB80A5A55ac804C948B45ce4C52DCbb
- StarkWare Contract ABI: Refer to the complete StarkWare contract ABI code
- Select the
withdraw
method and fill up the corresponding parameters; this will withdraw all of your assets from L2 into your gnosis-safe wallet - starkKey: Enter the gnosis-safe multi-sig wallet address, please ensure that this is not the L2 account stark_key_pair public_key
- assetType: Corresponding asset type
0x02893294412a4c8f915f75892b395ebbf6859ec246ec365c3b1f56f47c3a0a5d
- Starkware Contract Address:
Q & A
1. Q: What is the easiest way to get started with the API SDK?
A: Refer to Python sdk readme. It's the quickest way to learn how to install and use the Python SDK, including instructions on registering, creating orders, retrieving quote data, making withdrawals, and more.
Open-API SDK
- OpenApi-Python-SDK - Official OpenApi Python SDK
- OpenApi-Java-SDK - Official OpenApi JAVA SDK
- OpenApi-Node.JS-SDK - Official OpenApi Node JS SDK
2. Q: What is an APIKey? What is a StarkKey?
A: Generally, CEX APIs have only one APIKey. However, ApeX introduces StarkKey. Both the order creation API and withdrawal API require the use of StarkKey signatures. Stark signatures are verified on the L1 chain to ensure the security of users' assets.
3. Q: What is a Limit Fee? What is a Limit Fee Rate?
A: Limit Fee is the maximum fee that users can accept. This field is not present in CEX. However, in order to prevent the platform from manipulating handling fees, DEX allows users to set this value and sign it for verification. In the Python SDK's create-order API, users can use the taker fee rate to set the LimitFeeRate parameter, and the SDK will assist in calculating the Limit Fee.
4. Q: What is the expiration time?
A: An expiration time is set when creating an order and withdrawal. It determines the validity period for both actions. The recommended expiration time is 28 days. For L2 signatures, the expiration time is calculated in hours, while for the API, it is measured in seconds.
L2 expiration: (current timestamp in milliseconds + 28 days) / (3,600 * 1,000)
API expiration: L2 expiration * 3,600 * 1,000
5. Q: What is a clientId?
A: When creating an order or withdrawing funds, the client needs to generate a clientId. This clientId enables the user to record the ID and conduct local idempotent processing. Additionally, when signing L2, the clientId is used to convert it into the nonce field of the signature for verification. Please refer to the algorithm for further details: https://api-docs.pro.apex.exchange/#general-client_id-and-nonce-generation
6. Q: Is the StarkKey generated consistently every time?
A: Yes, the StarkKey generated in the web, app, or SDK is consistent because they all utilize the same signature format. However, if the user manually modifies the signature format, it may result in a different StarkKey. It's important to note that each StarkKey corresponds to a unique account ID in the system.
7. Q: Is Apikey generated consistently every time?
A: No, the generated APIKey is not consistent every time. Before calling the onboarding interface to generate an APIKey, the generate-nonce interface must be called to create a nonce for use in the onboarding request. Since each nonce value is unique, the resulting APIKey returned by the server is also unique. However, each APIKey corresponds to the same account ID. It's important to note that the APIKey generated and returned by the server is valid each time, provided that the web, app, and SDK are online simultaneously.
8. Q: Are there any rate limits on request frequency?
A: Yes, there are rate limits on request frequency. The frequency request limit mechanism for ordinary API users is detailed in the reference document at https://api-docs.pro.apex.exchange/#general-rate-limits. Market makers have the option to apply to customer service to be added to the IP whitelist and API interface whitelist, which allows them to increase their request limit.
9. Q: Why do I have to fill in the price when creating a market order?
A: Unlike CEX, which doesn't mandate users to input the price for market orders, ApeX requires users to specify the order price due to the Starkware signature mechanism. Users can calculate the order price manually using the order quantity and market depth, or they can utilize the get_worst_price interface to obtain the order price calculated by the backend. It's important for the market order price to be worse than the index price; otherwise, the order will be canceled.
10. Q: How to calculate user's total assets, available balance, maintenance margin, etc?
A: Please refer to the SDK documentation: https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/account_value.py
Total user assets (totalAccountValue)
Available balance (availableValue)
Maintenance margin (totalMaintenanceMarginRequirement)
11. Q: In which region is the server located in AWS?
A: "RegionName": "ap-southeast-1",
"ZoneName": "ap-southeast-1a",
"ZoneId": "apse1-az1",
"GroupName": "ap-southeast-1",
"NetworkBorderGroup": "ap-southeast-1",
"ZoneType": "availability-zone"
12. Q: How do I set LimitFee when creating orders using the Python SDK?
A: When creating an order using either client.create_order or client.create_order_v2, you can refer to the demo and utilize the LimitFeeRate field. Set the value to the user's takerFeeRate (note that the fee rate cannot exceed 6 decimal places). The SDK will assist in calculating the LimitFee to prevent errors in the user's calculations. It's important to note that the fee calculated by the SDK is not the actual fee charged to the user. Instead, it ensures that when pushed to L1 for verification, the fee charged by the backend cannot exceed the fee provided by the user. This mechanism prevents backend cheating and safeguards the user's assets.
13. Q: How many APIKeys can be created at most for one account?
A: A maximum of 30 APIKeys can be created for one account.
14. Q: When creating an order using the Python SDK, what happens if you fill in numbers directly?
A: All numerical values in the order for the Python SDK API client.create_order or client.create_order_v2 must be in string format. This ensures avoidance of numeric precision and length issues, which could lead to calculation errors.
15. Q: Which Python version does the Python SDK use?
A: Python 3.6-3.9
16. Q: Can I use a USDT account directly if I have used a USDC account before?
A: You need to register again using the v2 interface, client.register_user_v2, and specify the token parameter as token="USDT"
17. Q: Can token deposits and withdrawals be performed through the API?
A: Yes, withdrawals can be initiated through the API, including fast withdrawals and cross-chain withdrawals, but only on the ETH chain. These actions require the use of the user's starkkey pair. Withdrawals are limited to addresses registered by the user. For more information, refer to the following resources: - https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_deposit.py - https://github.com/ApeX-Protocol/apexpro-openapi/blob/main/tests/demo_stark_key_sign.py
18. Q: Is it necessary to obtain configuration information?
A: Yes, when using the Python SDK, you must call the client.configs_v2() interface after initializing the client to obtain relevant configuration information.
Errors
The API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request : Your request is invalid. |
403 | IP banned : Your IP is banned. |
404 | Not Found : The request path could not be found. |
500 | Internal Server Error: We're experiencing issues with our server. Please try again later. |
503 | Service Unavailable: We're temporarily offline for maintenance. Please try again later. |
10001 | Failed : error request. |
10002 | Requires Login : Your API key is wrong. |
10003 | Too Many Requests : Slow down! |
10004 | Request Timeout |
Error Key | Meaning |
---|---|
UNKNOWN | ("Service Error ."), |
INVALID_L2_SIGNATURE | ("Invalid L2 signature."), |
INVALID_ETH_ADDRESS | ("Invalid ethAddress."), |
INVALID_LP_ACCOUNT | ("Invalid lp account id. {accountId}"), |
INVALID_FEE | ("Invalid fee request {fee}"), |
INVALID_L2_TX | ("Invalid l2 txhash"), |
INVALID_USER_ID | ("Invalid userId. {userId}"), |
INVALID_ACCOUNT_ID | ("Invalid accountId. {accountId}"), |
INVALID_CURRENCY_ID | ("invalid currencyId. {currencyId} "), |
INVALID_CLIENT_WITHDRAW_ID | ("Invalid clientWithdraw Id. {clientWithdrawId}"), |
INVALID_CLIENT_TRANSFER_ID | ("Invalid clientTransfer Id. {clientTransferId}"), |
INVALID_PAGE_SIZE | ("Invalid page size. {size}"), |
EMPTY_CHAIN_ID | ("Empty chainId."), |
EMPTY_CLIENT_FAST_WITHDRAW_ID | ("Empty clientFastWithdraw Id."), |
EMPTY_PARAM | ("{name}Empty request param."), |
EMPTY_CLIENT_WITHDRAW_ID | ("Empty clientWithdraw Id."), |
EMPTY_CLIENT_TRANSFER_ID | ("Empty clientTransfer Id."), |
AMOUNT_MUST_GREETER_ZERO | ("Amount must greater than 0. {amount}"), |
ACCOUNT_NOT_FOUND | ("The account does not exist. {accountId}"), |
ACCOUNT_NOT_FOUND_L2KEY | ("The account does not exist. {l2Key}"), |
ACCOUNT_NOT_FOUND_LP | ("The account does not exist. {lpAccountId}"), |
ACCOUNT_CONFLICT_L2KEY | ("The account already exists. Please select another account. {l2Key}"), |
ORDER_NOT_FOUND | ("This order does not exist. {orderId}"), |
ORDER_NOT_CANCEL_MATCHED | ("Order processing, please do not cancel. {orderId}"), |
ORDER_NOT_CANCEL_FILLED | ("Order successful, please do not cancel. {orderId}"), |
ORDER_NOT_CANCEL_INVALID_STATUS | ("Invalid order, please do not cancel. {orderId}"), |
ORDER_INVALID_ORDER_TYPE | ("This order type is invalid. {orderType}"), |
ORDER_INVALID_TIME_IN_FORCE | ("Invalid time-in-force. {timeInForce}"), |
ORDER_INVALID_STATUS | ("This order status is invalid. {orderStatus}"), |
ORDER_INVALID_ORDER_SIDE | ("This order direction is invalid. {orderSide}"), |
ORDER_LIMIT_FEE_NOT_ENOUGH | ("Insufficient gas fees on this order. {limitFee}"), |
ORDER_FILL_TRANSACTION_ID_NOT_FOUND | ("This order does not exist.{transactionId}"), |
ORDER_FILL_TRANSACTION_CENSOR_ROUND_CONFLICT | ("Order submission error. {censorRound}"), |
ORDER_FILL_TRANSACTION_INVALID_STATUS | ("Order submission status is invalid. {transactionStatus}"), |
ORDER_EMPTY_CLIENT_ORDER_ID | ("Empty clientOrderId."), |
ORDER_INVALID_CLIENT_ORDER_ID | ("Invalid clientOrderId. {clientOrderId}"), |
ORDER_LIQUIDATE_ORDER_FAILED | ("Liquidation Unsuccessful."), |
ORDER_DELEVERAGE_WITH_SAME_ACCOUNT | ("The deleveraging account and the liquidation account are the same, transaction has failed."), |
ORDER_CLIENT_ORDER_DATA_CONFLICT | ("Please resubmit your order. {clientOrderId}"), |
ORDER_PRICE_MUST_GREETER_ZERO | ("Price must greater than 0. {price}"), |
ORDER_SIZE_MUST_GREETER_ZERO | ("Size must greater than 0. {size}"), |
ORDER_VALUE_MUST_GREETER_ZERO | ("Value must greater than 0. {value}"), |
ORDER_LIMIT_FEE_MUST_GREETER_ZERO | ("LimitFee must greater than or equal 0. {limitFee}"), |
ORDER_TRIGGER_PRICE_MUST_GREETER_ZERO | ("TriggerPrice must greater than 0. {triggerPrice}"), |
ORDER_SYMBOL_DISABLE_TRADE | ("Symbol {symbol} disable trade"), |
ORDER_SIZE_SMALLER_THAN_SYMBOL_MIN_ORDER_SIZE | ("Order size {size} smaller than symbol {symbol} min order size {minOrderSize}"), |
ORDER_SIZE_GREATER_THAN_SYMBOL_MAX_ORDER_SIZE | ("Order size {size} greater than symbol {symbol} max order size {maxOrderSize}"), |
ORDER_LIQUIDATING_ACCOUNT_CANNOT_CREATE_ORDER | ("Account is liquidating, cannot create order"), |
ORDER_OPEN_ORDER_COUNT_LIMIT_EXCEED | ("You have {openOrderCount} open orders, cannot create new order"), |
ORDER_WITH_THIS_PRICE_CANNOT_REDUCE_POSITION_ONLY | ("Order with this price {price} cannot reduce position only"), |
ORDER_SYMBOL_DISABLE_OPEN_POSITION | ("Symbol '{symbol}' disable open position"), |
ORDER_IS_REDUCE_ONLY_CANNOT_OPEN_POSITION | ("Order is reduce-only, cannot open position"), |
ORDER_IS_LIQUIDATE_ONLY_CANNOT_OPEN_POSITION | ("Order liquidated, cannot open position"), |
ORDER_IS_DELEVERAGE_ONLY_CANNOT_OPEN_POSITION | ("Order auto deleveraged, cannot open position"), |
ORDER_POSSIBLE_GREATER_THAN_SYMBOL_MAX_POSITION | ("If order is filled, it can be greater than symbol '{symbol}' max. position size {maxPositionSize}"), |
ORDER_IS_LIQUIDATE_NOT_MATCH_PRE_CONDITION | ("Liquidation order not match pre-condition: beforeTV({beforeTV}) < beforeTR({beforeTR})"), |
ORDER_IS_LIQUIDATE_AND_DELEVERAGE_NOT_MATCH_PRE_CONDITION | ("Liquidation and ADL order not match pre-condition:beforeTV({beforeTV}) < 0"), |
ORDER_POSSIBLE_LEAD_TO_ACCOUNT_LIQUIDATED | ("If order is filled, your account may be liquidated."), |
ORDER_POSSIBLE_LEAD_TO_ACCOUNT_LIQUIDATED_TV_TR_RATE_NOT_IMPROVED | ("If order is filled and TV/TR does not improve, your account may be liquidated."), |
ORDER_THERE_IS_NOT_ENOUGH_MARGIN_TO_OPEN_POSITION | ("If order is filled, there is insufficient margin to open position"), |
CROSS_DEPOSIT_DATA_ERROR | ("Deposit error"), |
CROSS_DEPOSIT_CURRENCY_ID_AMOUNT_CHANGED | ("Deposit error. {currencyId}, {amount}"), |
CROSS_WITHDRAW_WALLET_BALANCE_NOT_ENOUGH | ("Insufficient wallet balance."), |
CROSS_WITHDRAW_DATA_ERROR | ("Cross-chain withdrawal error"), |
CROSS_WITHDRAW_ID_NOT_FOUND | ("Cross-chain withdrawal error. {withdrawId}"), |
CROSS_WITHDRAW_INVALID_STATUS | ("Cross-chain withdrawal error. {status}"), |
CROSS_WITHDRAW_GREETER_MAX_ABLE_AMOUNT | ("Your withdrawal amount has exceeded the max. withdrawal limit, please try again."), |
CROSS_WITHDRAW_RISK_CHECK_FAILED | ("Cross-chain withdrawal error"), |
CROSS_WITHDRAW_INVALID_ARGUMENT | ("Cross-chain withdrawal error"), |
FAST_WITHDRAW_DATA_ERROR | ("Fast withdrawal error."), |
FAST_WITHDRAW_GREETER_MAX_ABLE_AMOUNT | ("Your withdrawal amount has exceeded the max. withdrawal limit, please try again."), |
FAST_WITHDRAW_RISK_CHECK_FAILED | ("Fast withdrawal error."), |
FAST_WITHDRAW_INVALID_ARGUMENT | ("Fast withdrawal error."), |
FAST_WITHDRAW_ID_NOT_FOUND | ("Fast withdrawal error. {withdrawId}"), |
FAST_WITHDRAW_INVALID_STATUS | ("Fast withdrawal error. {status}"), |
FAST_WITHDRAW_WALLET_BALANCE_NOT_ENOUGH | ("Fast withdrawal unsuccessful, insufficient wallet balance."), |
DEPOSIT_ASSET_ID_INVALID | ("Deposit error. {assetId}"), |
DEPOSIT_AMOUNT_INVALID | ("Invalid deposit amount. {amount}"), |
DEPOSIT_ASSET_ID_AMOUNT_CHANGED | ("Data error! Incorrect deposit amount.. {assetId},{amount}"), |
DEPOSIT_STATUS_INVALID | ("Data error! Incorrect deposit status. {status}"), |
DEPOSIT_CENSOR_ROUND_CONFLICT | (" Deposit censor round conflict. {censorRound}"), |
DEPOSIT_ID_NOT_FOUND | ("Data error! Incorrect deposit ID. {depositId}"), |
WITHDRAW_INVALID_ARGUMENT | ("Client withdrawal data conflict."), |
WITHDRAW_WALLET_BALANCE_NOT_ENOUGH | ("Withdrawal unsuccessful, insufficient wallet balance."), |
WITHDRAW_CANNOT_FIND_WITHDRAW | ("Withdrawal error. ${withdrawId}"), |
WITHDRAW_CENSOR_ROUND_CONFLICT | ("Withdraw censor round conflict. ${censorRound}"), |
WITHDRAW_INVALID_STATUS | ("Withdrawal status invalid. ${status}"), |
TRANSFER_WITH_SAME_ACCOUNT | ("invalid parameters, transfer with same account. ${accountId}"), |
TRANSFER_CONDITION_FACT_REG_ADDRESS_EMPTY | ("conditionFactRegistryAddress is empty"), |
TRANSFER_CONDITION_FACT_EMPTY | ("conditionFact is empty"), |
NOT_CONDITION_TRANSFER_IN | ("Not condition transferIn. ${transferInId}"), |
NOT_CONDITION_TRANSFER_OUT | ("Not condition transferOut. ${transferOutId}"), |
TRANSFER_IN_STATUS_INVALID | ("transferIn status invalid. ${status}"), |
TRANSFER_OUT_STATUS_INVALID | ("transferOut status invalid. {status}"), |
TRANSFER_OUT_CENSOR_ROUND_CONFLICT | ("transferOut censor round conflict. ${censorRound}"), |
TRANSFER_IN_CENSOR_ROUND_CONFLICT | ("transferIn censor round conflict. {censorRound}"), |
CLIENT_TRANSFER_OUT_DATA_CONFLICT | ("Client transfer out data conflict. ${clientTransferId}"), |
TRANSFER_WALLET_BALANCE_NOT_ENOUGH | ("Cannot transfer out, wallet balance not enough."), |