IQ Help Center

API Documentation

Getting Started

By following this documentation, you can find all the necessary tools for managing trading accounts.

This documentation includes the following account management functions: user authentification, opening trading positions, installation of market orders, management of financial instruments, obtaining transaction history, changing account details and much more.

For each request, examples of implementation and lists of parameters have been added to the documentation.

If you arise any questions during the development, our dedicated support will be happy to answer them.

We wish you good luck in the development of successful projects!

Prerequisites

Before you proceed with this documentation, we are assuming that, regardless of the programming language used, you are already aware about the basic API programming conventions and understanding of the WebSocket protocol. If you are not well aware of these concepts, then we will suggest you to go with the REST-API version.

Key prerequisites in this context are:

  1. A WebSocket-Friendly Programming Language
    A WebSocket client application can be written in any programming language that is capable of Berkeley sockets, such as C, C++, C#, Go, Java, Python, PHP, Rust, or server-side JavaScript.
  2. A Reliable WebSocket Library
    We advise to go with any of the following WebSocket libraries: C / Libwebsockets, C++ / uWebSockets, C# / Fleck, Go / Gorilla, Java / Java-WebSocket, NodeJS / uWebsSocket, PHP / Ratchet, Python / websockets, Rust / rust-websocket.
  3. An API-enabled IQDAX Trading Account
    In order to start using the IQDAX TradeSocket API protocol, a valid API-enabled trading account is required.

API Endpoints

To communicate with the TradeSocket API, a client must obtain a valid API Endpoint. When transmitting requests to an Endpoint, the Content-Type header must be present with the value of "application/json" for any initial WebSocket and all subsequent REST-API requests.

To request an Endpoint and an Authentification Token, a client must provide valid login credentials.

Example Request:

	                                    
	                                        POST /v1/endpoints HTTP/1.1
											Host: api.iqdax.com
											Content-Type: application/json
											Content-Length: 50
	                                    
	                                
	                                    
	                                        {
												"user": "user1",
												"password": "password1"
											}
	                                    
	                                

Returned Result:

	                                    
	                                        {
												"result": "OK",
												"endpoint": "endpoint1.iqdax.com",
												"token": "ABCDEF1234567890"
											}
	                                    
	                                

In the above example, the "endpoint" is an Endpoint server name for working with TradeSocket API, and the token is a valid Authentification Token.

Authentification

After obtaining a valid Endpoint/Token pair, a client can establish an TLS-encrypted client-endpoint WebSocket connection on port 443 to authentificate and immediately begin performing any account-specific operations.

Example Endpoint Access URL:

	                                    
	                                        wss://endpoint1.iqdax.com:443/
	                                    
	                                

Authentificating A Client

To successfully authenticate a client, a TLS-encrypted connection must be established as follows before sending/receiving any messages.

Example Endpoint Authentification URL:

		                                    
		                                        wss://ENDPOINT:443/session/TOKEN
		                                    
		                                

Where ENDPOINT is a valid API Endpoint, and TOKEN is an Authentification Token.

Two-Factor Authentification

Not Implemented

Two-factor authentification is not implemented in TradeSocket API V1

Changing A Password

Change the current Investor or Trader password.

Example Request:

		                                    
		                                        {
								                    "command": "changePassword",
								                    "transactionKey": String, // Current Transaction Key
								                    "newPassword": String, // New password to set
								                    "isInvestorPassword": Boolean // Password type (Investor or Master)
								                }
		                                    
		                                

Example Response:

		                                    
		                                        {
								                    "result": "OK"
								                }
		                                    
		                                

Re-Setting Passwords

Reset the current Investor Password, Trader Password and Transaction Key.

Example Request:

		                                    
		                                        {
								                    "command": "resetPasswords",
								                    "transactionKey": String // Current Transaction Key
								                }
		                                    
		                                

Example Response:

		                                    
		                                        {
								                    "result": "OK",
								                    "masterPassword": String, // New Master Password
								                    "investorPassword": String, // New Investor Password
								                    "transactionKey": String // New Transaction Key
								                }
		                                    
		                                

Server Messages

Server messages are transmitted automatically to authenticated clients when appropriate data becomes available for a specific client.

Client Information

Message type: {clientInfo}

Provides information about the authenticated client.

Message Format:

		                                    
		                                        {
													"id": String,
													"name": String,
													"phone": String,
													"email": String,
													"registrationDate": String,
													"leverage": String,
													"tradeAllowed": String,
													"isInvestor": Boolean,
													"message": "clientInfo"
												}
		                                    
		                                

Ticker Data

Message type: {tickerData}

Provides information about the available trading instruments.

Message Format:

		                                    
		                                        {
													"tickerData": [], // Array of available trading instruments
													"message": "tickerData"
												}
		                                    
		                                

Quote Update

Message type: {quoteUpdate}

Provides an updated quote for a trading instrument.

Message Format:

		                                    
		                                        {
													"ticker": String, // Ticker name (e.g. "BTCUSD")
													"bid": Float, // Bid price
													"ask": Float, // Ask price
													"date": Int, // Timestamp of quote
													"message": "quoteUpdate"
												}
		                                    
		                                

Last Quotes

Message type: {lastQuotes}

Provides an array of last quotes for available trading instruments.

Message Format:

		                                    
		                                        {
													"lastQuotes": [], // Array of {quoteUpdate}
													"message": "lastQuotes"
												}
		                                    
		                                

Finances

Financial commands to retrieve data related to equity and margin.

Get Equity

Command type: {getEquity}

Get total equity for an account.

Example Request:

		                                    
		                                        {
													"command": "getEquity"
												}
		                                    
		                                

Returned Result:

		                                    
		                                        {
													"result": "OK",
													"equity": "12050.00",
													"message": "getEquity"
												}
		                                    
		                                

Get Free Equity

Command type: {getFreeEquity}

Get available equity for an account.

Example Request:

		                                    
		                                        {
													"command": "getFreeEquity"
												}
		                                    
		                                

Returned Result:

		                                    
		                                        {
													"result": "OK",
													"equity": "5200.00",
													"message": "getFreeEquity"
												}
		                                    
		                                

Get Free Equity

Command type: {getSumPositions}

Get sum of trading positions for an account.

Example Request:

		                                    
		                                        {
													"command": "getSumPositions"
												}
		                                    
		                                

Returned Result:

		                                    
		                                        {
													"result": "OK",
													"equity": "1030.00",
													"message": "getSumPositions"
												}
		                                    
		                                

Get Total Margin

Command type: {getMargin}

Get total margin locked in positions for an account.

Example Request:

		                                    
		                                        {
													"command": "getMargin"
												}
		                                    
		                                

Returned Result:

		                                    
		                                        {
													"result": "OK",
													"equity": "5820.00",
													"message": "getMargin"
												}
		                                    
		                                

Transactions

Transactional messages are transmitted to a client upon request or after a specific operation has been completed on request of the client. The {getHistory} command can be transmitted from client to request a transactional message.

Deposit Operations

Message type: {deposits}

Returns an array of balance (deposit) operations for a client.

Message Format:

		                                    
		                                        {
													"result": "OK",
													"deposits": [], // Array of last 100 balance operations
													"message": "deposits"
												}
		                                    
		                                

Trading Positions

Message type: {positions}

Returns an array of open trading positions for a client.

Message Format:

		                                    
		                                        {
													"result": "OK",
													"positions": [], // Array of open trading positions
													"message": "positions"
												}
		                                    
		                                

Closed Positions

Message type: {operations}

Returns an array of closed trading operations for a client.

Message Format:

		                                    
		                                        {
													"result": "OK",
													"operations": [], // Array of last 100 closed positions
													"message": "operations"
												}
		                                    
		                                

Pending Orders

Message type: {pendingOrders}

Returns an array of pending market orders for a client.

Message Format:

		                                    
		                                        {
													"result": "OK",
													"pendingOrders": [], // Array of pending orders
													"message": "pendingOrders"
												}
		                                    
		                                

Executed Orders

Message type: {executedOrders}

Returns an array of executed market orders for a client.

Message Format:

		                                    
		                                        {
													"result": "OK",
													"executedOrders": [], // Array of last 100 executed orders
													"message": "executedOrders"
												}
		                                    
		                                

Get History

Command type: {getHistory}

Requests a specified transactional message from the server.

Command Format:

		                                    
		                                        {
													"command": "getHistory",
													"type": String // Type of requested transactional message (e.g. "pendingOrders")
												}
		                                    
		                                

Position Management

Position management is available via a set of outgoing commands transmitted from client to server.

Opening A Position

Command type: {openPosition}

Opens a new trading position and returns the {positions} message on success.

Command Format:

		                                    
		                                        {
													"ticker": String, // Ticker name (e.g. "EURUSD")
													"operationType": String, // "Buy" or "Sell" position
													"volume": Float, // Volume in lots (e.g. "1.00", "0.01")
													"price": Float, // Opening price (e.g. "1.2345")
													"maxDeviation": Int, // Max deviation in points/pips (e.g. "1000")
													"TP": Float, // Take profit price (e.g. "1.2345")
													"SL": Float, // Stop loss price (e.g. "1.2345")
													"TPPips": Int, // Take profit price in points/pips (e.g. "1000")
													"SLPips": Int, // Stop loss price in points/pips (e.g. "1000")
													"command": "openPosition"
												}
		                                    
		                                

Modifying A Position

Command type: {modifyPosition}

Modifies an existing trading position and returns the {positions} message on success.

Command Format:

		                                    
		                                        {
													"positionID": Int, // PositionID obtained from the {positions} message (e.g. "222")
													"TP": Float, // Take profit price (e.g. "1.2345")
													"SL": Float, // Stop loss price (e.g. "1.2345")
													"TPPips": Int, // Take profit price in points/pips (e.g. "1000")
													"SLPips": Int, // Stop loss price in points/pips (e.g. "1000")
													"command": "modifyPosition"
												}
		                                    
		                                

Closing A Position

Command type: {closePosition}

Closes an existing trading position and returns the {positions} message on success. Closing can be either full or partial.

Command Format:

		                                    
		                                        {
													"positionID": Int, // PositionID obtained from the {positions} message (e.g. "222")
													"volume": Float, // Volume in lots for partial closing (e.g. "1.00", "0.01")
													"command": "closePosition"
												}
		                                    
		                                

Order Management

Order management is available via a set of outgoing commands transmitted from client to server.

Creating An Order

Not Implemented

Delayed orders are not implemented in TradeSocket API V1

Modifying An Order

Not Implemented

Delayed orders are not implemented in TradeSocket API V1

Canceling An Order

Not Implemented

Delayed orders are not implemented in TradeSocket API V1

Error Codes

Each command transmitted from client to server returns a result which can be a success message or an error code. The following list describes the possible result codes for a client.

Success Message:

	                                    
	                                        {
												"result": "OK",
												...
											}
	                                    
	                                

Error Message:

	                                    
	                                        {
												"result": "NO",
												"Error": String // Error code (description)
											}
	                                    
	                                

Error Codes:

	                                    
	                                        "Error": "Not implemented"
	                                    
	                                

^ The requested feature is not implemented

	                                    
	                                        "Error": "Operation forbidden"
	                                    
	                                

^ The requested operation cannot be performed by the client

	                                    
	                                        "Error": "Wrong password"
	                                    
	                                

^ The specified Password is incorrect

	                                    
	                                        "Error": "Wrong key"
	                                    
	                                

^ The specified Transaction Key is incorrect

	                                    
	                                        "Error": "Quote is changed"
	                                    
	                                

^ Market price has changed while executing the transaction

	                                    
	                                        "Error": "Invalid price"
	                                    
	                                

^ The specified price is not valid or out of range

	                                    
	                                        "Error": "Invalid volume"
	                                    
	                                

^ The specified volume is not valid or out of range

	                                    
	                                        "Error": "Margin level"
	                                    
	                                

^ There is not enough free equity for this operation