Introduction
Welcome to the Cryptex24 trade API! You can use our API to perform trading operations.
V1 HTTP API
All HTTP endpoints endpoints available on https://api.cryptex24.io/trade. All responses with body are application/json content-type.
Rate limit
Current rate limit for trade api endpoints is 10 requests per second for one API key.
Authorization
To generate private key for signing requests, you can use openssl toolkit by next bash command:
openssl ecparam -name secp521r1 -genkey -noout -out private_key_file.pem
After that, you can generate public key from private by next bash command:
openssl ec -in private_key_file.pem -pubout -out public_key_file.pem
Some languages, like Java, uses pkcs8 formatted private key. You can format key by next bash command:
openssl pkcs8 -topk8 -inform pem -in private_key_file.pem -outform pem -nocrypt -out private_key_file_pkcs8.key
Example of hex encoded signature generation (dependencies - Apache Commons Codec and Bouncy Castle):
package abc;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Security;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
public class SignatureGenerator {
static {
Security.addProvider(new BouncyCastleProvider());
}
private static final String KEY_FACTORY_ALGORITHM = "EC";
private static final String SIGNATURE_ALGORITHM = "SHA256withPLAIN-ECDSA";
private static final String SECURITY_PROVIDER_NAME = BouncyCastleProvider.PROVIDER_NAME;
//private key from file without first and last line, for example: "MIHuAgEA...kQlw=="
public static String generateHexSignature(String privateKey, String dataToSign) throws Exception {
byte[] encodedKey = Base64.getDecoder().decode(privateKey);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);
PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(encodedKey);
PrivateKey pk = keyFactory.generatePrivate(encodedKeySpec);
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM, SECURITY_PROVIDER_NAME);
signature.initSign(pk);
signature.update(dataToSign.getBytes(StandardCharsets.UTF_8));
byte[] resultSignature = signature.sign();
return Hex.encodeHexString(resultSignature);
}
}
Cryptex24 uses API keys and request signatures to allow access to the secured API endpoints.
Signature should be created by ecdsa
(P-521
/secp521r1
curve) algorithm with sha256
hash-function.
You can contact us to receive an API key and give us your public key that will be used to verify your signatures.
All endpoints parameters are sent as a query parameters.
You should sign your request path with query params included (for example, /trade/v1/stock-order?orderId=162c88330edc9b54788d069bf
).
When performing request, send with each request next information:
- header
X-API-KEY
- this header should contain your api-key that you received from us. - header
X-SIGNATURE
- this header should contain signature of request. Signature should be hex formatted.
Account balance
Response example:
[
{
"currency": "C24",
"active": 300.8,
"blocked": 55.24
},
{
"currency": "BTC",
"active": 0.5,
"blocked": 0.0
}
]
This endpoint retrieves all account balances. Active balance represents available amount that can be used for orders, blocked balance is balance in active orders, withdraw processing, C24 codes.
Http request
GET https://api.cryptex24.io/trade/v1/balances/all
Response list element parameters
Parameter | Type | Description |
---|---|---|
currency | String | Balance currency, for example C24 . |
active | Double | Active balance you can use. |
blocked | Double | Balance in active orders, withdraw processing, C24 codes. |
Orders
ENUM defenitions
Order status | Description |
---|---|
NEW |
New order. |
PARTIALLY_FILLED |
Order was partially filled. |
IN_PROCESS |
Order is placed on market, has being executed right now. |
DONE |
Order has been completed. |
CANCELLED |
Order has been cancelled by user. |
FAILED |
Order failed, contact support for details. |
Order types:
LIMIT
STOP_LIMIT
MARKET_TO_LIMIT
Operation type:
BUY
SELL
Definition of base and quote currency:
base currency
refers to the currency that is theamount
(quantity) of a symbol.quote currency
refers to the currency that is theprice
of a symbol.
Please, note that order minimal total must be > 0.00001 in BTC.
Fee for orders will be calculated and added on top of amount (for SELL
order) you send, or total (for BUY
order).
Create limit order
Response example:
{
"orderId": "6080324622dcb62ce97273cf"
}
Http request
POST https://api.cryptex24.io/trade/v1/stock-order/limit
In response, you receive order identifier string.
Query parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
price | Double | Price in quote currency for base currency. |
amount | Double | Amount of base currency. |
operationType | String (ENUM) | BUY or SELL . |
Create market-to-limit order
Response example:
{
"orderId": "6090324622dcb62ce97273dg"
}
Http request
POST https://api.cryptex24.io/trade/v1/stock-order/market-to-limit
In response, you receive order identifier string.
Query parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
amount | Double | Amount of base currency. |
operationType | String (ENUM) | BUY or SELL . |
Create stop-limit order
Response example:
{
"orderId": "6100324622dcb62ce97273eh"
}
- When you create
BUY
order, it will be triggered when price >= stop. - When you create
SELL
order, it will be triggered when price <= stop.
If trigger condition already satisfied by market price during order creation, it will be be placed to market immediately.
Http request
POST https://api.cryptex24.io/trade/v1/stock-order/stop-limit
In response, you receive order identifier string.
Query parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
stop | Double | Stop price, when it's reached - order will be placed on market. |
price | Double | Price in quote currency for base currency. |
amount | Double | Amount of base currency. |
operationType | String (ENUM) | BUY or SELL . |
Cancel order
Response example:
{
"orderCancelled": true
}
Http request
POST https://api.cryptex24.io/trade/v1/stock-order/cancel
If order cancelled, you will receive success response. Order can't be cancelled if it's already done/cancelled or in process right now.
Query parameters (all required)
Parameter | Type | Description |
---|---|---|
orderId | String | Identifier for order you want to cancel. |
Get single order
Response example:
{
"orderId": "60806beefb4de26a1e366f57",
"quoteCurrency": "USDT",
"baseCurrency": "C24",
"stop": 5.0,
"price": 10.0,
"initialPrice": 10.0,
"amount": 1.0,
"initialAmount": 2.0,
"total": 10.0,
"operationType": "BUY",
"orderType": "STOP_LIMIT",
"timestamp": 1619028974760,
"status": "PARTIALLY_FILLED",
"triggerCondition": ">= 5.0",
"isOrderTriggered": true
}
Http request
GET https://api.cryptex24.io/trade/v1/stock-order
In response, you receive order information. You can find only your orders.
Query parameters (all required)
Parameter | Type | Description |
---|---|---|
orderId | String | Order identifier you received in response on create order request. |
Resposne body parameters
Parameter | Type | Description |
---|---|---|
orderId | String | Order identifier. |
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
stop | Double | Stop price, optional field (exists only for STOP_LIMIT order). |
price | Double | Actual price in quote currency for base currency. (Can be different from initial in case of market order, or when maker order closes your taker order and has better price for you). |
amount | Double | Actual amount of base currency. This value equals to 0 when order has DONE status. |
initialPrice | Double | Initial price of order. |
initialAmount | Double | Initial amount of base currency. |
total | Double | Price multipled by amount. This value equals to 0 when order has DONE status. |
operationType | String (ENUM) | BUY or SELL . |
orderType | String (ENUM) | Type that order belongs to. |
triggerCondition | String | String representation of trigger condition, optional field (exists only for STOP_LIMIT order). Example: >= 2.1 . |
isOrderTriggered | Boolean | Indicates whether the order has been triggered and placed on market, optional field (exists only for STOP_LIMIT order). |
status | String (ENUM) | Current order status. |
timestamp | Long | Order creation timestamp milliseconds (UTC). |
Get all orders
Response example:
{
"body": [
{
"orderId": "60806beefb4de26a1e366f57",
"quoteCurrency": "USDT",
"baseCurrency": "XRP",
"stop": 5.0,
"price": 10.0,
"initialPrice": 10.0,
"amount": 1.0,
"initialAmount": 2.0,
"total": 10.0,
"operationType": "BUY",
"orderType": "STOP_LIMIT",
"timestamp": 1619028974760,
"status": "PARTIALLY_FILLED",
"triggerCondition": ">= 5.0",
"isOrderTriggered": true
},
{
"orderId": "607db6243e5c67777cd1ff96",
"quoteCurrency": "USDT",
"baseCurrency": "C24",
"price": 2.0,
"initialPrice": 2.0,
"amount": 2.0,
"initialAmount": 2.0,
"total": 4.0,
"operationType": "SELL",
"orderType": "LIMIT",
"timestamp": 1618851364467,
"status": "CANCELLED"
}
],
"totalElements": 19,
"totalPages": 10
}
Http request
GET https://api.cryptex24.io/trade/v1/stock-order/all
In response, you receive orders page. You will receive only your orders in response.
Query parameters (all parameters are optional)
Parameter | Type | Default value | Description |
---|---|---|---|
orderStatuses | List of strings (ENUM) | All order statuses | Filter by order statuses. |
orderTypes | List of strings (ENUM) | All order types | Filter by order type. |
quoteCurrency | String | All currencies | Filter by quote currency. |
baseCurrency | String | All currencies | Filter by base currency. |
createDateSortDirection | String | DESC | Sort by order creation time. By default, from newer orders to older. Possible values: DESC , ASC . |
operationType | String (ENUM) | All operation types | Filter by operation type. |
page | Integer | 0 | Page number, starts from 0. |
size | Integer | 100 | Size of page (min = 1, max = 1000). |
from | Long | None | Filter by creation timestamp milliseconds (UTC) from specified value, inclusive. |
to | Long | None | Filter by creation timestamp milliseconds (UTC) to specified value, inclusive. |
Resposne body parameters
Parameter | Type | Description |
---|---|---|
totalPages | Integer | Number of total pages. |
totalElements | Integer | Number of total elements. |
body | List of orders | List of orders (check previous endpoint description to see order structure). |
Trade history
Trade history represents all trades that was made with your orders. If your maker order was matched to multiple other orders, you will have different trade history records for each of opposite orders. If your taker order matched orders with different prices, your trade history will have multiple records for each price.
Get trade history
Response example:
{
"body": [
{
"publicTradeId": "6079cc02c0404029d0eaa859",
"tradeId": "6082fb8842c1a975a9c4237a",
"orderId": "6079cc012d11eb3a68e089a9",
"quoteCurrency": "USDT",
"baseCurrency": "C24",
"price": 5.0,
"amount": 1.0,
"total": 5.0,
"operationType": "BUY",
"timestamp": 1618594817903,
"isMaker": false
},
{
"tradeId": "6082fb89913dd62f1114b98e",
"orderId": "6079c8c02d11eb3a68e0899e",
"quoteCurrency": "USDT",
"baseCurrency": "C24",
"price": 5.0,
"amount": 1.0,
"total": 5.0,
"operationType": "SELL",
"timestamp": 1618593984492,
"isMaker": true
}
],
"totalElements": 19,
"totalPages": 10
}
Http request
GET https://api.cryptex24.io/trade/v1/stock-order/trade-history
In response, you receive trade history page. You will receive only your orders trade records in response.
Query parameters (all parameters are optional)
Parameter | Type | Default value | Description |
---|---|---|---|
quoteCurrency | String | All currencies | Filter by quote currency. |
baseCurrency | String | All currencies | Filter by base currency. |
createDateSortDirection | String | DESC | Sort by order execution time. By default, from newer trade records to older. Possible values: DESC , ASC . |
operationType | String (ENUM) | All operation types | Filter by operation type. |
makerTakerFilter | String (ENUM) | Both sides | Filter records by maker or taker trade side. Possible values: MAKER , TAKER . |
orderId | String | All orders | Filter records by order identifier. |
page | Integer | 0 | Page number, starts from 0. |
size | Integer | 100 | Size of page (min = 1, max = 1000). |
from | Long | None | Filter by creation timestamp milliseconds (UTC) from specified value, inclusive. |
to | Long | None | Filter by creation timestamp milliseconds (UTC) to specified value, inclusive. |
Resposne body parameters
Parameter | Type | Description |
---|---|---|
totalPages | Integer | Number of total pages. |
totalElements | Integer | Number of total elements. |
body | List of trade history records | List of trade history records (described below). |
Trade history record parameters
Note: for taker order operations, trade history records contain publicTradeId
field, that can be used to bind this record with public API trade history record.
Soon this field will be removed, and tradeId
will be used for this purpose. publicTradeId
should be considered as optional.
Trade history record contains next fields:
Parameter | Type | Description |
---|---|---|
publicTradeId | String | Public API trade identifier. Soon will be removed (check note above). |
tradeId | String | Unique trade identifier. |
orderId | String | Related order identifier. |
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
price | Double | Price in quote currency for base currency. |
amount | Double | Amount of base currency. |
total | Double | Price multipled by amount. |
operationType | String (ENUM) | BUY or SELL . |
timestamp | Long | Trade timestamp milliseconds (UTC). |
isMaker | Boolean | Indicates whether your order was maker or taker in this trade (Can be different for the same order in multiple trade records). |
V1 HTTP API Errors
Failed request error-body example:
{
"status": 400,
"messages": [
"Some parameters are absent, or invalid."
],
"code": 40001
}
When error occured, you will receive object that describes error. In case if you reached rate limit, you will receive 429 HTTP status with no body.
Response body parameters
Parameter | Type | Description |
---|---|---|
code | Integer | Error identifier. |
messages | List of string | List of error description messages. Contains at least one default message. |
status | Integer | HTTP status code. |
Possible errors
HTTP status code | Error Code | Meaning |
---|---|---|
400 | 40001 | Some parameters are absent, or invalid. |
400 | 40002 | Not enough balance. |
400 | 40003 | Order not found. |
400 | 40004 | Order can't be cancelled. |
400 | 40005 | Order's total should be bigger. |
400 | 40006 | Account's balance blocked. |
400 | 40007 | Currency precision exceeded. |
401 | 40101 | API key or signature header not present. |
401 | 40102 | Wrong API key. |
401 | 40103 | Signature not verified. |
500 | 50001 | Issue with internal service. |
500 | 99999 | Unknown error. |
V1 WebSocket API
Success subscription response example:
{
"status": "SUCCESS"
}
Failed subscription response example:
{
"status": "FAILED",
"message": "Error message",
"code": 123
}
Topic message structure:
{
"topic": "NAME_OF_TOPIC",
"data": "{...}"
}
We provide WebSocket API that you can use to receive market updates in real-time. You can subscribe to different topics to listen for specific updates.
There are public and private WebSockets available - private WebSockets contain just your account related orders, trades etc. You need to provide an API key to subsribe to private topic. For public and private WebSocket updates receiving, use different connections. Timeout for WebSockets is 2 hours, you should reconnect after disconnect again.
Public WebSocket endpoints: wss://api.cryptex24.io/trade/ws/v1/updates.
Private WebSocket endpoints: wss://api.cryptex24.io/trade/ws/v1/updates/private.
ENUM defenitions
Websocket topics
Topic | Type | Description |
---|---|---|
ORDER_UPDATES |
Private topic | Provides order updates information along with new orders by pair. |
ORDER_BOOK |
Public topic | Provides order book updates by pair. |
TRADE_HISTORY |
Public and private topic | Provides new trade history by pair. |
BALANCE_CHANGES |
Private topic | Provides account balance changes. |
Subscription response status
Topic | Description |
---|---|
SUCCESS |
You successfully subscribed to topic. |
FAILED |
Some error occured. Check websocket errors for details. |
Each WebSocket message should be sent as a JSON object.
Each topic message contains two fields - topic
and data
. Field topic
indicates what message you have received, and data
field contains payload.
See detailed information and examples for each topic below.
Order updates
Subscription request example:
{
"topic": "ORDER_UPDATES",
"apiKey": "api key value",
"baseCurrency": "C24",
"quoteCurrency": "USDT"
}
Topic message example:
{
"topic": "ORDER_UPDATES",
"data": {
"orderId": "6086f558ce165d707c742220",
"baseCurrency": "C24",
"quoteCurrency": "USDT",
"operationType": "BUY",
"orderType": "LIMIT",
"price": 5.00000000,
"initialPrice": 5.00000000,
"amount": 1.00000000,
"initialAmount": 1.00000000,
"total": 5.00000000,
"status": "NEW"
}
}
Subscription message parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example USDT . |
apiKey | String | Your API key. |
topic | String (ENUM) | Topic name, ORDER_UPDATES . |
Subscription resposne message parameters
Parameter | Type | Description |
---|---|---|
status | String (ENUM) | Subscription response status. SUCCESS if successful subscription, FAILED otherwise. |
message | String | Optional field, present for FAILED subscription only. Error message. |
code | Integer | Optional field, present for FAILED subscription only. Error code. |
Topic message data
field parameters
Parameter | Type | Description |
---|---|---|
orderId | String | Order identifier. |
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
stop | Double | Stop price, optional field (exists only for STOP_LIMIT order). |
price | Double | Actual price in quote currency for base currency. (Can be different from initial in case of market order, or when maker order closes your taker order and has better price for you). |
amount | Double | Actual amount of base currency. This value equals to 0 when order has DONE status. |
initialPrice | Double | Initial price of order. |
initialAmount | Double | Initial amount of base currency. |
total | Double | Price multipled by amount. This value equals to 0 when order has DONE status. |
operationType | String (ENUM) | BUY or SELL . |
orderType | String (ENUM) | Type that order belongs to (check HTTP API documentation). |
triggerCondition | String | String representation of trigger condition, optional field (exists only for STOP_LIMIT order). Example: >= 2.1 . |
isOrderTriggered | Boolean | Indicates whether the order has been triggered and placed on market, optional field (exists only for STOP_LIMIT order). |
status | String (ENUM) | Current order status (check HTTP API documentation). |
Order book
Subscription request example:
{
"topic": "ORDER_BOOK",
"baseCurrency": "C24",
"quoteCurrency": "USDT"
}
Topic message example:
{
"topic": "ORDER_BOOK",
"data": {
"baseCurrency": "C24",
"quoteCurrency": "USDT",
"side": "BUY",
"price": 5.00000000,
"amount": 3.00000000,
"total": 15.00000000
}
}
Subscription message parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example USDT . |
topic | String (ENUM) | Topic name, ORDER_BOOK . |
Subscription resposne message parameters
Parameter | Type | Description |
---|---|---|
status | String (ENUM) | Subscription response status. SUCCESS if successful subscription, FAILED otherwise. |
message | String | Optional field, present for FAILED subscription only. Error message. |
code | Integer | Optional field, present for FAILED subscription only. Error code. |
Topic message data
field parameters
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example USDT . |
side | String (ENUM) | Order book side. Possible values: BUY , SELL . |
price | Double | Price in quote currency for base currency. |
amount | Double | Amount of base currency. |
total | Double | Price multipled by amount. |
Trade history
Public WebSocket subscription request example:
{
"topic": "TRADE_HISTORY",
"baseCurrency": "C24",
"quoteCurrency": "USDT"
}
Private WebSocket subscription request example:
{
"topic": "TRADE_HISTORY",
"apiKey": "api key value",
"baseCurrency": "C24",
"quoteCurrency": "USDT"
}
Public WebSocket topic message example:
{
"topic": "TRADE_HISTORY",
"data": {
"publicTradeId": "60881dde0b6ac5418ac1be51",
"tradeId": "60881dde0b6ac5418ac1be53",
"baseCurrency": "C24",
"quoteCurrency": "USDT",
"operationType": "SELL",
"price": 5.00000000,
"amount": 1.00000000,
"total": 5.00000000,
"isMaker": false
}
}
Private WebSocket topic message example:
{
"topic": "TRADE_HISTORY",
"data": {
"orderId": "60881ddde6405d082c530521",
"publicTradeId": "60881dde0b6ac5418ac1be51",
"tradeId": "60881dde0b6ac5418ac1be53",
"baseCurrency": "C24",
"quoteCurrency": "USDT",
"operationType": "SELL",
"price": 5.00000000,
"amount": 1.00000000,
"total": 5.00000000,
"isMaker": false
}
}
Public topic subscription message parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example USDT . |
topic | String (ENUM) | Topic name, TRADE_HISTORY . |
Private topic subscription message parameters (all required)
Parameter | Type | Description |
---|---|---|
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example USDT . |
apiKey | String | Your API key. |
topic | String (ENUM) | Topic name, TRADE_HISTORY . |
Subscription resposne message parameters
Parameter | Type | Description |
---|---|---|
status | String (ENUM) | Subscription response status. SUCCESS if successful subscription, FAILED otherwise. |
message | String | Optional field, present for FAILED subscription only. Error message. |
code | Integer | Optional field, present for FAILED subscription only. Error code. |
Topic message data
field parameters
Note: for taker order operations, trade history records contain publicTradeId
field, that can be used to bind this record with public API trade history record.
Soon this field will be removed, and tradeId
will be used for this purpose. publicTradeId
should be considered as optional.
Parameter | Type | Description |
---|---|---|
publicTradeId | String | Public API trade identifier. Soon will be removed. |
tradeId | String | Unique trade identifier. |
orderId | String | Related order identifier. Note: present only for private WebSocket. |
baseCurrency | String | Base currency, for example C24 . |
quoteCurrency | String | Quote currency, for example BTC . |
price | Double | Price in quote currency for base currency. |
amount | Double | Amount of base currency. |
total | Double | Price multipled by amount. |
operationType | String (ENUM) | BUY or SELL . |
isMaker | Boolean | Indicates whether your order was maker or taker in this trade (Can be different for the same order in multiple trade records). |
Balance changes
Subscription request example:
{
"topic": "BALANCE_CHANGES",
"apiKey": "api key value"
}
Topic message example:
{
"topic": "BALANCE_CHANGES",
"data": {
"currency": "C24",
"active": 954.97000000,
"blocked": 30.03000000
}
}
Subscription message parameters (all required)
Parameter | Type | Description |
---|---|---|
apiKey | String | Your API key. |
topic | String (ENUM) | Topic name, BALANCE_CHANGES . |
Subscription resposne message parameters
Parameter | Type | Description |
---|---|---|
status | String (ENUM) | Subscription response status. SUCCESS if successful subscription, FAILED otherwise. |
message | String | Optional field, present for FAILED subscription only. Error message. |
code | Integer | Optional field, present for FAILED subscription only. Error code. |
Topic message data
field parameters
Parameter | Type | Description |
---|---|---|
currency | String | Changed balance currency, for example C24 . |
active | Double | Active balance you can use. |
blocked | Double | Balance in active orders, withdraw processing, C24 codes. |
V1 WebSocket Errors
Failed subscription error-response example:
{
"status": "FAILED",
"message": "Some parameters are absent, or invalid.",
"code": 40001
}
If error occured during subscription, you will receive object that describes error.
Response body parameters
Parameter | Type | Description |
---|---|---|
status | String | Subscription response status, in case of error - FAILED . |
message | String | Error description message. |
code | Integer | Error identifier. |
Possible errors
Error Code | Meaning |
---|---|
40001 | Some parameters are absent, or invalid. |
40002 | Error when parsing income message. |
40102 | Wrong API key. |
99999 | Unknown error. |