MT4Server is a REST API proxy between brokers who support MetaTrader4 platform. It provides such operations as listing of orders, buy and sell, balanse and ways to obtain ticker data via HTTP or web sockets(obtains a particular ticker from a broker).
It uses API key for authentication and JWT.
AVA Trade
ICMarkets
FXOpen
ForexClub
Just2Trade
In the cURLs below youll see placeholders like <this>. These are describes below
<mt4server> - is at 52.164.255.82
<API key> - is 280EC427-5184-4AB4-8A12-EF4140057437
<broker id> - is the name by which MT4Server recongnises the broker. Currently the names are [fxclub, fxopen, ava, icmarkets, demo]
<JWT access token> - is the access token you receive as a response from Auth endpoint
<order_id> - is an ID of an existing order. All orders can be listed by calling the Fetching all orders endpoint
Note: demo is the name for a demo account with Just2Trade broker
Use this to obtain the JWT token
curl -X POST \
https://<mt4server>/token \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: text/plain' \
-d <API key>
The response would be a JWT token which should be included in all the requests to endpoints below as an 'Authorization' header
curl -X GET \
https://<mt4server>/exchanges/<broker id>/orders \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
- Buy order
curl -X POST \
https://<mt4server>/exchanges/<broker id>/orders \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"pair": "BTCUSD",
"amount": 0.11,
"op": "buy"
}'
- Sell order
curl -X POST \
https://<mt4server>/exchanges/<broker id>/orders \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"pair": "BTCUSD",
"amount": 0.11,
"op": "sell"
}'
curl -X DELETE \
https://<mt4server>/exchanges/<broker id>/orders/<order_id> \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
curl -X GET \
https://<mt4server>/exchanges/<broker id>/balance \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
curl -X GET \
'https://<mt4server>/exchanges/<broker id>/tickers?tickers=BTCUSD,ETHUSD' \
-H 'Authorization: <JWT access token> \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
wss://<mt4server>/exchanges/<broker id>/ticker?ticker=BTCUSD
curl -X GET \
https://<mt4server>/
-H 'Content-Type: application/json' \
Below are the brokers with their supported tickers:
-
AVA Trade - [ EURUSD, USDJPY, BCHUSD, BTCEUR, BTCJPY, BTCUSD, BTGUSD ]
-
ForexClub - [ BTCEUR*, EURUSD, USDJPY, BTCUSD, ETCUSD, LTCBTC, LTCUSD, NEOUSD, ETHUSD, DSHUSD, XRPUSD, BCHUSD, BTGUSD, XMRUSD, ZECUSD ]
-
FXOpen - [ EURUSD*, USDJPY*, DSHBTC, DSHUSD, BCHUSD, BTCEUR, BTCUSD, BTCJPY, LTCBTC, LTCEUR, LTCJPY, LTCUSD, ETHEUR, ETHJPY, ETHUSD, XRPEUR, XRPUSD ]
-
ICMarkets - [ EURUSD, USDJPY, BCHUSD, BTCUSD, DSHUSD, ETHUSD, LTCUSD, XRPUSD ]
-
Just2Trade - [ XRPUSD*, BTCUSD, ETHUSD]
Note: the '*'-ed tickers are supported by the broker, it is possible to obtain their ticks however the broker diabled the trading for these tickers