MT4 REST API Documentation
New demo environment and documentation
All method you can test on API with address http://mt4.mtapi.be.
Next articles examples reference to this instance.
Examples tested with well-known utility SOAPUI, which has free version.
Login to MT4 server
If you try to connect without token you will get «Unauthorized».
You should add header with name «Authorization» and value «Bearer <token>» (with space).
API return response with login_id (keep this id) of MT4 server connection and some data.
If something goes wrong with API you will get Error. E.x. wrong login
Login to MT4 server via proxy
Some MT4 servers deny more than several connection from one IP.
In this case you should find free SOCKS5 proxy or build yourself.
Find free socks5 proxy is hard task. So we will build ourselves for example.
Now method exist, but proxy doesn’t.
Get login info
If you logged to MT4 server, API would keep that connection. You can check connection existing by user_id returned by method “new”.
Get quote from connection by user id and tiker
Open orders from connection
Get order history
Please, use exactly exampled datetime format
You should see properly exception, because market was closed, when I am writing this document
But when it switched on, you will see like this
Close connection to MT4 server
When you work is done, you should disconnect by user id
If connection was closed earlier