Introduction
Specifications relating to derivatives products including perpetual futures are provided solely for members of EDXM International. Derivatives, including perpetual futures, and related services provided by EDXM International are not available to US persons or institutions or in any other jurisdiction where prohibited by law.
Endpoints
| Endpoints | Authenticated | /market-data | /order-entry |
|---|---|---|---|
public-api.trade.* | No | Yes | No |
api.trade.* | Yes | Yes | Yes |
- UAT
- EDX Markets
- EDXM Global
API
The Web Gateways communicate using text over WebSocket. All client-to-service and service-to-client messages are
encoded as JSON objects. The structure of these messages adheres to a
FIX-like format, with a MsgType property indicating the type of message
being sent.
API Evolution
Changes to the WS API in the following forms are considered backwards compatible and must be handled by the client application:
- Adding new fields to an existing response
- Adding new optional fields to an existing request
Client applications must not fail to deserialize responses with new properties (for example, using 'strict' JSON parsers).
Authentication
User Agent
A User-Agent header must be included in the initial WebSocket handshake request for both authenticated and public
endpoints. The header should reasonably identify the application that is initiating the request.
API Credentials
API Credentials can be generated on the Clearing Member Portal via the API Apps tab with the desired permissions.
With the client id and secret obtained from the clearing member portal, access tokens must be generated
following OAuth2.0 standards using the client_credentials grant type.
A POST request will need to be made to https://auth.{server-url}/oauth/token with the following x-www-form-urlencoded parameters:
audience:https://{server-url}/apigrant_type:client_credentialsclient_id:{your-client-id}client_secret:{your-client-secret}
You can test that you can receive an access token using your credentials in UAT by making the following request:
curl 'https://auth.uat.edxclearing.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id={your-client-id}' \
--data-urlencode 'client_secret={your-client-secret}' \
--data-urlencode 'audience=https://uat.edxclearing.com/api' \
--data-urlencode 'grant_type=client_credentials'
The server-url will be based on the environment:
- Prod:
clearing.edxmarkets.com - UAT:
uat.edxclearing.com
This will then return a json object with one of the fields being the access_token.
Provide this token in the API requests as the Authorization header with the string Bearer prepended to the token string.
Token Refresh
Bearer tokens expire after 24 hours. When a token expires, any active WebSocket connection established with that token will be disconnected. Clients may choose to generate a new Bearer token and re-establish the WebSocket connection to avoid a forced disconnection.
Rate Limit
Market Data
A rate limit is imposed on messages sent to the market data endpoint. Exceeding the rate limit will lead to the client application being disconnected. Given that the market data endpoint only supports a handful of requests, this rate limit is simply meant as a protection against rogue client applications.
Order Entry
A rate limit is imposed on messages sent to the order entry endpoint. Exceeding the rate limit will lead to the client application being disconnected.
Quick Start Examples
- Python
The following example uses the websocket-client library as a third-party dependency solely for
demonstration purposes. EDXM does not endorse nor require any third-party dependencies for integration.
Please conduct your own review before installing any third-party packages.
Prerequisites:
pip install websocket-client
import websocket
def on_message(ws, message):
print("Received message:", message)
def on_error(ws, error):
print("Error:", error)
def on_close(ws, close_status_code, close_msg):
print("Connection closed")
def on_open(ws):
print("Connection opened")
ws.send('''
{
"MsgType": "SecurityListRequest",
"SecurityReqID": "quick-start",
"SecurityListRequestType": "ALL_SECURITIES"
}
''')
if __name__ == "__main__":
headers = [
"User-Agent: Your User Agent",
]
ws = websocket.WebSocketApp(
"wss://public-api.trade.uat.edxmarkets.com/market-data",
header=headers,
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close,
)
ws.run_forever()
Support
Contact EDX Market Operations: marketoperations@edxmarkets.com