MENU
LIVE SUPPORT
  • ISTANBUL12:56:03
  • NEW YORK7:48:06
  • LONDON12:47:17
  • MOSCOW15:47:33
  • TOKYO21:47:45

Trough ICRYPEX API, you can access market information, account movements and balance, enter market and limit orders, and cancel your orders.

TRADING COMMISSIONS BY VOLUME

API

API (APPLICATION PROGRAM INTERFACE)

It is the interface that enables the functions of an application to be accessed and used externally or remotely. API enables the application on a server to be accessed from different platforms and to produce transactions by answering the queries it asks. Icrypex provides access to the information you need with related API queries. In this way, you can buy and sell, and monitor the prices and volumes of cryptocurrencies without being connected to the Icrypex platform.

General API Information

  • Some endpoints will require an API Key.
  • The base endpoint is: https://api.icrypex.com
  • All endpoints return a JSON object.
  • Data is returned in ascending order. Oldest first, newest last.
  • All time and timestamp related fields are in milliseconds.

HTTP Return Codes

  • HTTP 4XX return codes are used for malformed requests; the issue is on the sender's side.
  • HTTP 403 return code is used when the WAF Limit (Web Application Firewall) has been violated.
  • HTTP 429 return code is used when breaking a request rate limit.
  • HTTP 5XX return codes are used for internal errors; the issue is on Server's side. It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success.

Response fields description

Name Type Mandatory Description
code Number Yes Error Code,0 is success,else is fail
msg String Yes error message
timestamp Number Yes server timestamp
data Object No response data

General Information on Endpoints

  • For GET,POST endpoints, parameters must be sent as a query string.
  • Parameters may be sent in any order.

LIMITS

General Info on Limits

  • The following intervalLetter values for headers:
    • SECOND => S
    • MINUTE => M
    • HOUR => H
    • DAY => D
  • intervalNum describes the amount of the interval. For example, intervalNum 5 with intervalLetter M means "Every 5 minutes".
  • A 429 will be returned when either rate limit is violated.

IP Limits

  • When a 429 is received, it's your obligation as an API to back off and not spam the API.
  • Repeatedly violating rate limits and/or failing to back off after receiving 429s will result in an automated IP ban (HTTP status 418).
  • IP bans are tracked and scale in duration for repeat offenders, from 2 minutes to 3 days.
  • A Retry-After header is sent with a 418 or 429 responses and will give the number of seconds required to wait, in the case of a 418, to prevent a ban, or, in the case of a 429, until the ban is over.
  • The limits on the API are based on the IPs, not the API keys.

We recommend using the httpclient, webclient for getting data as much as possible, as this will not count to the request rate limit.

Order Rate Limits

  • The order rate limit is counted against each account.

Endpoint security type

  • Each endpoint has a security type that determines the how you will interact with it. This is stated next to the NAME of the endpoint.

    • If no security type is stated, assume the security type is NONE.
  • API-keys are passed into the Rest API via the x-access-token header or in query string via via the api_key parameter.
  • API-keys are case sensitive.
  • API-keys can be configured to only access certain types of secure endpoints.
Security Type Description
NONE Endpoint can be accessed freely.
API KEY Endpoint requires sending a valid API-Key.

Timing security

  • A SIGNED endpoint also requires a parameter, timestamp, to be sent which should be the millisecond timestamp of when the request was created and sent.
  • An additional parameter, recvWindow, may be sent to specify the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000.
  • The logic is as follows:
    if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow)
    {
        // process request
    }
    else
    {
        // reject request
    }
                                
  • Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.

It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!

SIGNED Endpoint Examples for GET/open/v1/orders

Here is a step-by-step example of how to send a vaild signed payload.

Key Value
api_key cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV

Parameter Value
symbol BTC/TRY
side 1 1 - Buy 2 - Sell
type 1 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
quantity '0.16'
price '7500'
recvWindow 5000
timestamp 1581720670624

Example 1: As a query string

  • Query String:symbol=BTC/TRY&side=1&type=1&quantity=0.16&price=7500&timestamp=1581720670624&recvWindow=5000&api_key=cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV
    - api_key can be send in x-access-token request header instead of query string too.

Public API Definitions

Terminology

  • base asset refers to the asset that is the quantity of a symbol.
  • quote asset refers to the asset that is the price of a symbol.

ENUM definitions

Order status (status):
  • 1 NEW
  • 2 FILLED
  • 3 CANCELED
  • 4 PARTIALLY FILLED
  • 5 REJECTED
  • 6 EXPIRED
Order types (orderTypes, type):
  • 1 LIMIT
  • 2 MARKET
  • 3 TAKE PROFIT
  • 4 STOP LOSS
Order side (side):
  • 1 BUY
  • 2 SELL

General endpoints

Check server time

GET /open/v1/common/time

Test connectivity to the Rest API and get the current server time.

Parameters: NONE

Response:
{
    "code": 0,
    "msg": "success",
    "timestamp": 1572265137927
}
                    

Get all Supported Trading Symbol

GET /open/v1/common/symbols

This endpoint returns all Exchange's supported trading symbol.

Parameters: NONE

Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "symbol": "BTC/TRY",
                "baseAsset": "",BTC
                "baseAssetname": "Bitcoin",
                "basePrecision": 8,
                "quoteAsset": "TRY",
                "quatoAssetname": "Turkish Lira",
                "quotePrecision": 8,
                "quotePrecisionShow": 8,
                "status": 1 // 0: inactive , 1: active,
                "description": "Bitcoin, eşten eşe ağ teknolojisini kullanarak herhangi..."
            }
        ]
    },
    "timestamp": 1571921637091
}
                    

Market Data endpoints

Order book

GET /open/v1/market/depth

Parameters:

Name Type Mandatory Description
symbol STRING YES
limit INT NO Default 100; max 5000. Valid limits:[5, 10, 20, 50, 100, 500]

Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "lastUpdateId": 1027024,
        "bids": [
         "price": "4.00000000",
         "amount": "431.00000000"
        ],
        "asks": [
         "price":"4.00000200",
         "amount":"12.00000000"
        ]
    },
    "timestamp": 1571921637091
}
                    

Recent trades list

GET /open/v1/market/trades

Get recent trades (up to last 500).

Parameters:

Name Type Mandatory Description
symbol STRING YES
fromId LONG NO ID to get trades from INCLUSIVE.
limit INT NO Default 500; max 1000.
Response:
{
    "code": 0,
    "msg": "success",
    "data": [
        {
            "id": 238457, // transaction id
            "price": "4.00000100", 
            "qty": "12.00000000", // Quantity
            "time": 1499865549590,
            "isBuyerMaker": true,
            "isBestMatch": true
        }
    ],
    "timestamp": 1571921637091
}
                    

Compressed/Aggregate trades list

GET /open/v1/market/agg-trades

Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

Parameters:

Name Type Mandatory Description
symbol STRING YES
fromId LONG NO ID to get aggregate trades from INCLUSIVE.
startTime LONG NO Timestamp in ms to get aggregate trades from INCLUSIVE.
endTime LONG NO Timestamp in ms to get aggregate trades until INCLUSIVE.
limit INT NO Default 500; max 1000.
  • If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.

Response:
{
    "code": 0,
    "msg": "success",
    "data": [
        {
            "a": 261429, // transaction id
            "p": "0.01633102", // Price
            "q": "4.70443515", // Quantity
            "f": 27781, // first fill order id
            "l": 27781, // last fill order id
            "T": 1498793709153, // Fill Datetime
            "m": true, // is Maker
            "M": true
        }
    ],
    "timestamp": 1571921637091
}
                    

Account endpoints

New order (SIGNED)

POST /open/v1/orders  (HMAC SHA256)

Send in a new order.

Parameters:

Name Type Mandatory Description
symbol STRING YES
side ENUM YES 1 - Buy, 2 - Sell
type ENUM YES 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
quantity STRING NO
quoteOrderQty STRING NO
price STRING NO
clientId STRING NO Client's custom ID for the order, Server does not check it's uniqueness. Automatically generated if not sent.
stopPrice STRING NO Used with STOP LOSS, TAKE PROFIT
icebergQty STRING NO For future use.
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Additional mandatory parameters based on type:

Type Additional mandatory parameters
1 quantity, price
2 quantity, quoteOrderQty (sell) or quantity (buy)
3 quantity, stopPrice
4 quantity, stopPrice

Other info:

  • STOP LOSS and TAKE PROFIT will execute a MARKET order when the stopPrice is reached.
  • MARKET orders using quantity specifies how much a user wants to buy or sell based on the market price.
  • MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) of the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty.

Trigger order price rules against market price for both MARKET and LIMIT versions:

  • Price above market price: STOP LOSS BUY, TAKE PROFIT SELL
  • Price below market price: STOP LOSS SELL, TAKE PROFIT BUY

Response:
{
    "code": 0,
    "message": "success",
    "data": {
        "orderId": "452367",
        "createTime": 1550130502385
    },
    "timestamp": 1550130502489
}
                    

Query order (SIGNED)

GET /open/v1/orders/detail (HMAC SHA256)

Check an order's status.

Parameters:

Name Type Mandatory Description
orderId LONG YES
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Response:
{
    "code": 0,
    "message": "success",
    "data": {
        "orderId": 456123,
        "orderListId": -1, // Future use
        "clientId": "142334", // Customer Id
        "symbol": "BTC/TRY",
        "side": 1, // Buy : 1 - Sell : 2
        "type": 1, // 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
        "price": 110,
        "status": 0 , //Terminology > ENUM definitions > Order status (status)
        "origQty": 10.88, // Base Quantity
        "origQuoteQty": 0, // Quato Quantity
        "executedQty": 0, // for future use
        "executedPrice": 0, // for future use
        "executedQuoteQty": 0, // for future use
        "createTime": 1550130502000
    },
    "timestamp": 1550130554182
}
                    

Cancel order (SIGNED)

POST /open/v1/orders/cancel  (HMAC SHA256)

Cancel an active order.

Parameters:

Name Type Mandatory Description
orderId LONG YES
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Response:
{
    "code": 0,
    "message": "success",
    "data": {
        "orderId": 456712,
        "orderListId": -1,
        "clientId": "myOrder1",
        "symbol": "BTC/TRY",
        "side": 1, // Buy : 1 - Sell : 2
        "type": 1, // 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
        "price": 1,
        "status": 0, // Terminology > ENUM definitions > Order status (status)
        "origQty": 10.88, // Base Quantity
        "origQuoteQty": 0, // Quato Quantity
        "executedQty": 0, // for future use
        "executedPrice": 0, // for future use
        "executedQuoteQty": 0, // for future use
        "createTime": 1550130502000
        },
    "timestamp": 1550130554182
}
                    

All orders (SIGNED)

GET /open/v1/orders/list (HMAC SHA256)

Get all account orders; active, canceled, or filled.

Parameters:

Name Type Mandatory Description
symbol STRING YES
type ENUM NO 1 - Open, 2 - History
side ENUM NO
startTime LONG NO
endTime LONG NO
fromId String NO For future use.
direct ENUM NO For future use.
limit INT NO Default 500; max 1000.
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES
Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "orderId": "213456",
                "clientId": "13242", // Customer ID
                "symbol": "BTC/TRY",
                "symbolType": 1,  // for future use
                "side": 1, // Buy : 1 - Sell : 2
                "type": 1, // 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
                "price": "0.1",
                "origQty": "10", // Base Quantity
                "origQuoteQty": "1", // Quato Quantity
                "executedQty": "0", // for future use
                "executedPrice": "0", // for future use
                "executedQuoteQty": "0", // for future use
                "timeInForce": 1, // for future use
                "stopPrice": "0.0000000000000000", // Price for Stop Loss or Take Profit Order Tpes
                "icebergQty": "0.0000000000000000", // for future use
                "status": 0, //Terminology > ENUM definitions > Order status (status)
                "isWorking": 0,
                "createTime": 1572692016811
            }
        ]
    },
    "timestamp": 1572860756458
}
                    

Open orders (SIGNED)

GET /open/v1/openOrders (HMAC SHA256)

Get account all or symbol based open orders.

Parameters:

Name Type Mandatory Description
symbol STRING NO
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES
Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "orderId": "213456",
                "clientId": "13453", // Customer ID
                "symbol": "BTC/TRY",
                "symbolType": 1, // for future use
                "side": 1,/ / Buy : 1 - Sell : 2
                "type": 1,// 1 - Limit, 2 - Market, 3 - Take Profit, 4 - Stop Loss
                "price": "0.1",
                "origQty": "10", // Base Quantity
                "origQuoteQty": "1",/ / Quato Quantity
                "executedQty": "0", // for future use
                "executedPrice": "0", // for future use
                "executedQuoteQty": "0", // for future use
                "timeInForce": 1,  // for future use
                "stopPrice": "0.0000000000000000", // Price for Stop Loss or Take Profit Order Tpes
                "icebergQty": "0.0000000000000000", // for future use
                "status": 0, //Terminology > ENUM definitions > Order status (status)
                "isWorking": 0,
                "createTime": 1572692016811
            }
        ]
    },
    "timestamp": 1572860756458
}
                    

Account information (SIGNED)

GET /open/v1/account/spot (HMAC SHA256)

Get current account information.

Parameters:

Name Type Mandatory Description
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES
Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "makerCommission": "10.00000000",
                "takerCommission": "10.00000000",
                "buyerCommission": "0.00000000",
                "sellerCommission": "0.00000000",
                "asset": "BTC",
                "free": "0.5550000000000000",
                "locked": "0000000000000000"
            }
        ]
    },
    "timestamp": 1572514387348
}
                   

Daily Account information (SIGNED)

GET /open/v1/accountSnapshot (HMAC SHA256)

Get time based account information.

Parameters:

Name Type Mandatory Description
type STRING NO Currently support only SPOT
startTime LONG NO
endTime LONG NO
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES
Response:
{
    "code": 0,
    "msg": "success",
    "snapShotVos":[{
        "balances": [
            {
                "asset": "BTC",
                "free": "0.5550000000000000",
                "locked": "0000000000000000"
            },
            {
                "asset": "LTC",
                "free": "200.430000000000000",
                "locked": "0000000000000000"
            }]}]
	    "type": "SPOT",
	    "timestamp": 1572514387348
}
                    

Account Asset information (SIGNED)

GET /open/v1/account/spot/asset (HMAC SHA256)

Get current account information for a specific asset.

Parameters:

Name Type Mandatory Description
asset STRING YES
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES
Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "asset": "BTC",
        "free": "0.5550000000000000",
        "locked": "0000000000000000"
    },
    "timestamp": 1572514387348
}
                    

Account trade list (SIGNED)

GET /open/v1/orders/trades  (HMAC SHA256)

Get trades for a specific account and symbol.

Parameters:

Name Type Mandatory Description
symbol STRING YES
orderId String NO
startTime LONG NO
endTime LONG NO
fromId LONG NO TradeId to fetch from. Default gets most recent trades.
direct ENUM NO For future use.
limit INT NO Default 500; max 1000.
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Notes:

  • if field "fromId" is defined, this field "direct" becomes mandatory.
Response:
{
    "code": 0,
    "msg": "success",
    "data": {
        "list": [
            {
                "tradeId": "X-241568",
                "orderId": "241568",
                "symbol": "BTC/TRY",
                "price": "0.04398",
                "qty": "0.0001",
                "quoteQty": "520.989",
                "commission": "0.000025",
                "commissionAsset": "BTC",
                "isBuyer": 1,
                "isMaker": 0,
                "isBestMatch": 1,
                "time": "1572920872276"
            }
        ]
    },
    "timestamp": 1573723498893
}
                    

General WSS information

  • The base endpoint is:wss://stream-cloud.icrypex.com and after connection is succeeded, with URLs below, a blank data must be sent to access streaming
  • Streams can be accessed either in a single raw stream or in a combined stream
  • Raw streams are accessed at /ws?<streamName>(example; wss://stream-cloud.icrypex.com/ws?btc/[email protected])
  • Combined streams are accessed at /stream?streams=<streamName1>\<streamName2>\<streamName3>(example; wss://stream-cloud.icrypex.com/stream?streams=btc/[email protected]\ltc/[email protected])
  • Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}
  • A single connection to stream-cloud.icrypex.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark
  • The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 5 minutes period, the connection will be disconnected. Unsolicited pong frames are allowed.

Live Subscribing/Unsubscribing to streams

  • The following data can be sent through the websocket instance in order to subscribe/unsubscribe from streams. Examples can be seen below.
  • The id used in the JSON payloads is an unsigned INT used as an identifier to uniquely identify the messages going back and forth.
  • In the response, if the result received is null this means the request sent was a success for non-query requests (e.g. Subscribing/Unsubscribing).

Subscribe to a stream

Unsubscribe to a stream

  • Request
    {
        "method": "UNSUBSCRIBE",
        "params": [
            "btc/[email protected]"
        ],
        "id": 312
    }
                                
  • Response
    {
        "result": null,
        "id": 312
    }
                                

Listing Subscriptions

  • Request
    {
        "method": "LIST_SUBSCRIPTIONS",
        "id": 3
    }
                                
  • Response
    {
        "result": [
            "btc/[email protected]"
        ],
        "id": 3
    }
                                

Setting Properties

Currently, the only property can be set is to set whether combined stream payloads are enabled are not. The combined property is set to false when connecting using /ws/ ("raw streams") and true when connecting using /stream/.

  • Request
    {
        "method": "SET_PROPERTY",
        "params": [
            "combined",
            true
        ],
        "id": 5
    }
                                
  • Response
    {
        "result": null,
        "id": 5
    }
                                

Retrieving Properties

  • Request
    {
        "method": "GET_PROPERTY",
        "params": [
            "combined"
        ],
        "id": 2
    }
                                
  • Response
    {
        "result": true, // Indicates that combined is set to true.
        "id": 2
    }
                                

Error Messages

Error Message
{"code": 0, "msg": "Unknown property"}
{"code": 1, "msg": "Invalid value type: expected Boolean"}
{"code": 2, "msg": "Invalid request: property name must be a string"}
{"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"}
{"code": 2, "msg": "Invalid request: unknown variant of SUBSCRIBE, UNSUBSCRIBE, LIST_SUBSCRIPTIONS, SET_PROPERTY, GET_ PROPERTY"} Possible typo in the provided method or provided method was neither of the expected values
{"code": 2, "msg": "Invalid request: too many parameters"}
{"code": 2, "msg": "Invalid request: property name must be a string"}
{"code": 2, "msg": "Invalid request: missing field method "}
{"code":3,"msg":"Invalid JSON format "}

Detailed Stream information

Aggregate Trade Streams

The Aggregate Trade Streams push trade information that is aggregated for a single taker order.

Stream Name: <symbol>@aggTrade
Update Speed: Real-time

Payload:
{
  "e": "aggTrade",  // Event type
  "E": 123456789,   // Event time
  "s": "BTC/TRY",   // Symbol
  "a": 123445,       // Aggregate trade ID
  "p": "0.001",     // Price
  "q": "100",       // Quantity
  "f": 100,         // First trade ID
  "l": 105,         // Last trade ID
  "T": 123456785,   // Trade time
  "m": true,        // Is the buyer the market maker?
  "M": true         // Ignore
}
                    

Trade Streams

The Trade Streams push raw trade information; each trade has a unique buyer and seller.

Stream Name: <symbol>@trade
Update Speed: Real-time

Payload:
{
  "e": "trade",     // Event type
  "E": 123456789,   // Event time
  "s": "BTC/TRY",   // Symbol
  "t": 12345,       // Trade ID
  "p": "0.001",     // Price
  "q": "100",       // Quantity
  "b": 88,          // Buyer order ID
  "a": 50,          // Seller order ID
  "T": 123456785,   // Trade time
  "m": true,        // Is the buyer the market maker?
  "M": true         // Ignore
}
                    

Individual Symbol Mini Ticker Stream

24hr rolling window mini-ticker statistics. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs.

Stream Name: <symbol>@miniTicker
Update Speed: 1000ms

Payload:
  {
    "e": "24hrMiniTicker",  // Event type
    "E": 123456789,         // Event time
    "s": "BTC/TRY",         // Symbol
    "c": "0.0025",          // Close price
    "o": "0.0010",          // Open price
    "h": "0.0025",          // High price
    "l": "0.0010",          // Low price
    "v": "10000",           // Total traded base asset volume
    "q": "18"               // Total traded quote asset volume
  }
                    

All Market Mini Tickers Stream

24hr rolling window mini-ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.

Stream Name: [email protected]
Update Speed: 1000ms

Payload:
[
  {
    "e": "24hrMiniTicker",  // Event type
    "E": 123456789,         // Event time
    "s": "BTC/TRY",         // Symbol
    "c": "0.0025",          // Close price
    "o": "0.0010",          // Open price
    "h": "0.0025",          // High price
    "l": "0.0010",          // Low price
    "v": "10000",           // Total traded base asset volume
    "q": "18"               // Total traded quote asset volume
  }
]
                   

Individual Symbol Ticker Streams

24hr rolling window ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.

Stream Name: <symbol>@Ticker
Update Speed: 2000ms

Payload:
{
  "e": "24hrTicker",  // Event type
  "E": 123456789,     // Event time
  "s": "BNBBTC",      // Symbol
  "p": "0.0015",      // Price change
  "P": "250.00",      // Price change percent
  "w": "0.0018",      // Weighted average price
  "x": "0.0009",      // First trade(F)-1 price (first trade before the 24hr rolling window)
  "c": "0.0025",      // Last price
  "Q": "10",          // Last quantity
  "b": "0.0024",      // Best bid price
  "B": "10",          // Best bid quantity
  "a": "0.0026",      // Best ask price
  "A": "100",         // Best ask quantity
  "o": "0.0010",      // Open price
  "h": "0.0025",      // High price
  "l": "0.0010",      // Low price
  "v": "10000",       // Total traded base asset volume
  "q": "18",          // Total traded quote asset volume
  "O": 0,             // Statistics open time
  "C": 86400000,      // Statistics close time
  "F": 0,             // First trade ID
  "L": 18150,         // Last trade Id
  "n": 18151          // Total number of trades
}
                   

Symbol Order Book Ticker

Best price/qty on the order book for a symbol or symbols..

Stream Name: <symbol>@bookTicker
Update Speed: 500ms

Payload:
  {
    "u": 823453, // Last Update id
    "s": "BTC/TRY",         // Symbol
    "b": "0.0025",          // Best bid price
    "B": "0.0010",          // Best bid Amount
    "a": "0.0025",          // Best ask price
    "A": "0.0010",          // Best ask amount
  }
                    

Partial Book Depth Streams

Stream Name: <symbol>@depth
Update Speed: 1000ms

Payload:
{
  "lastUpdateId": 160,  // Last update ID
  "bids": [             // Bids to be updated
    [
     "Price": "0.0024",         // Price level to be updated
     "Amount": "10"              // Quantity
    ]
  ],
  "asks": [             // Asks to be updated
    [
     "Price": "0.0026",         // Price level to be updated
     "Amount": "100"            // Quantity
    ]
  ]
}
                    

Diff. Depth Stream

Order book price and quantity depth updates used to locally manage an order book.

Stream Name: <symbol>@depth
Update Speed: 200ms

Payload:
{
  "e": "depthUpdate", // Event type
  "E": 123456789,     // Event time
  "s": "BTC/TRY",     // Symbol
  "U": 157,           // First update ID in event
  "u": 160,           // Final update ID in event
  "b": [              // Bids to be updated
    [
     "Price": "0.0024",       // Price level to be updated
     "Amount": "10"            // Quantity
    ]
  ],
  "a": [              // Asks to be updated
    [
     "Price": "0.0026",       // Price level to be updated
     "Amount": "100"           // Quantity
    ]
  ]
}
                    

How to manage a local order book correctly

  • 1. Open a stream to wss://stream-cloud.icrypex.com/ws?btc/[email protected].
  • 2. Buffer the events you receive from the stream.
  • 3. Get a depth snapshot from https://api.icrypex.com/open/v1/market/depth?symbol=BTC/TRY&limit=1000.
  • 4. Drop any event where u is <= lastUpdateId in the snapshot.
  • 5. The first processed event should have U <= lastUpdateId+1 AND u >= lastUpdateId+1.
  • 6. While listening to the stream, each new event's U should be equal to the previous event's u+1.
  • 7. The data in each event is the absolute quantity for a price level.
  • 8. If the quantity is 0, remove the price level.
  • 9. Receiving an event that removes a price level that is not in your local order book can happen and is normal.

Sample Codes

WebSocket Streaming

    using WebSocketSharp;
    
    WebSocket ws = null;
               
    private void WSSConenct()
    {
        try
        {
    
            // for subscribe trades first connect to wss://stream-cloud.icrypex.com and then send {"method": "SUBSCRIBE","params":["btc/[email protected]","ltc/[email protected]"],"id": 2}
            // for subscribe last orders first connect to wss://stream-cloud.icrypex.com and then send{ "method": "SUBSCRIBE","params":["btc/[email protected]","ltc/[email protected]"],"id": 2}
            // for subscribe aggregate trades first  connect to wss://stream-cloud.icrypex.com and then {"method": "SUBSCRIBE","params":["btc/[email protected]","ltc/[email protected]"],"id": 2}
            // for subscribe miniticker first connect to wss://stream-cloud.icrypex.com and then { "method": "SUBSCRIBE","params":["btc/[email protected]","ltc/[email protected]"],"id": 2}
            // for subscribe diff miniticker first connect to wss://stream-cloud.icrypex.com and then { "method": "SUBSCRIBE","params":["[email protected]"],"id": 2}
    
            // for single stream connect with total URL (for example; wss://stream-cloud.icrypex.com/ws?btc/[email protected]) and then send dummy data to start stream
            // for combined stream connect with total URL (for example; wss://stream-cloud.icrypex.com/stream?streams=btc/[email protected]\ltc/[email protected]\eth/[email protected]) and then send dummy data to start stream 
    
            string ConnectionURL = "wss://stream-cloud.icrypex.com/ws?btc/[email protected]";
    
            ws = new WebSocket(ConnectionURI);
    
            ws.OnMessage += WebSocketDataReceived;
            ws.OnOpen += WebSocketOpened;
            ws.OnError += WebSocketError;
            ws.OnClose += WebSocketClose;
            ws.Connect();
    
            if (ws != null)
                ws.Send("");
        }
        catch (Exception ex)
        {
            // Error
        }
    }
    
    private void WebSocketError(object sender, ErrorEventArgs e)
    {
    
        textBox3.AppendText(Environment.NewLine + Environment.NewLine + "Connection to server lost : " + e.Message);
        ws.Close();
        ws = null;
    }
    
    private void WebSocketClose(object sender, CloseEventArgs e)
    {
        textBox3.AppendText(Environment.NewLine + Environment.NewLine + "Connection closed with the server");
        ws = null;
    }
    
    private void WebSocketDataReceived(object sender, MessageEventArgs e)
    {
    
        textBox3.AppendText(Environment.NewLine + Environment.NewLine + e.Data);
    }	
                                

API Calls

JAVA CODE

  • 1. ASYNC CALL

    import java.net.URI;
    import java.net.URISyntaxException;
    import java.net.http.HttpClient;
    import java.net.http.HttpClient.Redirect;
    import java.net.http.HttpClient.Version;
    import java.net.http.HttpRequest;
    import java.net.http.HttpResponse;
    import java.net.http.HttpResponse.BodyHandlers;
    public class HttpClientApp {
    public void invoke() throws URISyntaxException {
    
      HttpClient client = HttpClient.newBuilder()
          .version(Version.HTTP_2)
          .followRedirects(Redirect.NORMAL)
          .build();
    
      HttpRequest request = HttpRequest.newBuilder()
         .uri(new URI("https://api.icrypex.com/open/v1/orders/list?symbol=BTC/TRY&type=1&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV"))
         .GET()
         .timeout(Duration.ofSeconds(10))
         .build();
    
    
      client.sendAsync(request, BodyHandlers.ofString())
        .thenApply(HttpResponse::body)
        .thenAccept(System.out::println)
        .join();
    }
    }
                                
  • 2. SYNC CALL

    public class HttpClientApp {
    public void invokePost() {
    
      try {
       String requestBody = prepareRequest();
       HttpClient client = HttpClient.newHttpClient();
       HttpRequest request = HttpRequest
         .newBuilder()
         .uri(URI.create("https://api.icrypex.com/open/v1/orders?symbol=BTC/TRY&type=2&side=1&quantity=0.01&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV"))
         .POST(HttpRequest.BodyPublishers.ofString(requestBody))
         .header("Accept", "application/json")
         .build();
       HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
       System.out.println(response.body());
      } catch (IOException | InterruptedException e) {
       e.printStackTrace();
      }
    }
                                
  • C#.NET CODE

    • 1. Use HttpClient

      using System;
      using System.Net.Http;
      using System.Net.Http.Headers;
      namespace ConsoleProgram
      {
          public class Class1
          {
              private const string URL = "https://api.icrypex.com/open/v1/orders";
              private string urlParameters = "?symbol=BTC/TRY&type=2&side=1&quantity=0.01&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV";
              static void Main(string[] args)
              {
                  HttpClient client = new HttpClient();
                  client.BaseAddress = new Uri(URL);
                  // Add an Accept header for JSON format.
                  client.DefaultRequestHeaders.Accept.Add(
                  new MediaTypeWithQualityHeaderValue("application/json"));
                  // List data response.
                  HttpResponseMessage response = client.GetAsync(urlParameters).Result;  // Blocking call! Program will wait here until a response is received or a timeout occurs.
                  if (response.IsSuccessStatusCode)
                  {
                      // Parse the response body.
                      var dataObjects = response.Content.ReadAsAsync<string>().Result;  //Make sure to add a reference to System.Net.Http.Formatting.dll
      
                  }
                  else
                  {
                      Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
                  }
                  // Make any other calls using HttpClient here.
                  // Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
                  client.Dispose();
              }
          }
      }
                                  
    • Use WebClient

      // Public API : Get order book
       using (WebClient wc = new WebClient())
      {
      
           try
           {
               string url = https://api.icrypex.com/open/v1/market/depth?symbol=BTC/TRY;
               string result = wc.DownloadString(url);
                                      <!--returns =>
                                         {"code":0,"msg":"success",
                                         "Data":{"lastupdateid":1639776794754,
                                         "bids":
                                         [
                                             {"price":"661858.48000000","amount":"0.00500000"},
                                             {"price":"661858.48000000","amount":"0.01000000"}
                                         ],
                                         "asks":
                                         [
                                             {"price":"24400.00000000","amount":"0.01000000"},
                                             {"price":"24400.00000000","amount":"0.01000000"}
                                         ]
                                         },
                                         "timestamp":1639776794856
                                         }-->
           }
           catch (Exception ex)
           {
               // Error
           }
      }
       // Private API (Requires api_key in query string or in request header): Get open orders
      using (WebClient wc = new WebClient())
      {
           try
           {
               string url = "https://api.icrypex.com/open/v1/orders/list?symbol=BTC/TRY&type=1&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV";
               //api_key parameter can be sent in <x-access-token> request header too
               string result = wc.DownloadString(url);
               //returns =>
                                      <!--{"code": 0,"msg": "success
                                          data":{"list":
                                          [
                                              {
                                              "orderId": "119234",
                                              "clientId": "174832",
                                              "symbol": "BTC/TRY",
                                              "symbolType": 1,
                                              "side": 1,
                                              "type": 1,
                                              "price": "1.123",
                                              "origQty": "10",
                                              "origQuoteQty": "1",
                                              "executedQty": "0",
                                              "executedPrice": "0",
                                              "executedQuoteQty": "0",
                                              "timeInForce": 0,
                                              "stopPrice": "0.0000000000000000",
                                              "icebergQty": "0.0000000000000000",
                                              "status": 0,
                                              "isWorking": 0,
                                              "createTime": 1572692016811
                                              }
                                          ]
                                      },
                                      "timestamp": 1572860756458
                                      }-->
               }
           catch (Exception ex)
           {
           // Error
           }
      }
      // Private API (Requires api_key in query string or in request header) : Insert new market order
      using (WebClient wc = new WebClient())
      {
      try
      {
           string url = "https://api.icrypex.com/open/v1/orders?symbol=BTC/TRY&type=2&side=1&quantity=0.01&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV";
           //api_key parameter can be sent in <x-access-token> request header too.
           string result = wc.DownloadString(url);
           //returns =>
                                          <!--{"code": 0,"msg": "success",
                                              "data":
                                              {
                                                  "orderId": "123456",
                                                  "createTime": 1572692016811
                                              },
                                              "timestamp": 1572860756458
                                          }-->
           }
           catch (Exception ex)
           {
           // Error
           }
      }
       // Private API (Requires api_key in query string  ror in equest header): Delete order
      using (WebClient wc = new WebClient())
      {
      try
      {
           string url = https://api.icrypex.com/open/v1/orders/cancel?orderid=119&timestamp=1639842985658&api_key=cfDC92B191b9B1223Ae0e01108CBKI6Bqewr26xr4NrPusef23d49Ze9YrmWwPFV;
           //api_key parameter can be sent in <x-access-token> request header too.
           string result = wc.DownloadString(url);
           //returns =>
                                              <!--{"code": 0,"msg": "success",
                                                  "data":
                                                  {
                                                      "orderId": 119234,
                                                      "orderListId": -1,
                                                      "clientId": "14522",
                                                      "symbol": "BTC/TRY",
                                                      "side": 1,
                                                      "type": 1,
                                                      "price": 12,454,
                                                      "status": 0,
                                                      "origQty": 10.88,
                                                      "origQuoteQty": 0,
                                                      "executedQty": 0,
                                                      "executedPrice": 0,
                                                      "executedQuoteQty": 0,
                                                      "createTime": 1550130502000
                                                  },
                                                  "timestamp": 1572860756458
                                              }-->
           }
           catch (Exception ex)
           {
           // Error
           }
      }
                                  

    WE SUPPORT TURKISH SPORTS

    We support Turkish sports with our sponsorships of Beşiktaş Icrypex Basketball Team, 1907 Fenerbahçe Disabled Stars, Altay Sports Club and Göztepe Sports Club. ICRYPEX will continue to stand by Turkish sports.

    • Beşiktaş
    • Altay
    • Göztepe
    • Fenerbahçe