TradeAPI Documentation

Last Updated: February 4th, 2025 - 17:20 EST

Welcome to our Forex TradeAPI, designed to equip traders and developers with simplified access to trade on their MT4, MT5, and Trade Locker accounts.

You can access the API using GET requests. To authenticate your GET requests, include your API key in the header of your request. You can generate an API key in your profile.

Example Header:

{
    "Content-Type": "application/json",
    "Authorization": "Api-Key YOUR_API_KEY"
}
var request = URLRequest(url: URL(string: "https://www.jblanked.com/news/api/YOUR-END-POINT"))
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
string headers = "Content-Type: application/json" + "\r\n" + "Authorization: Api-Key YOUR_API_KEY";

API Endpoints

Login

Endpoint: /trade/api/login/

Method: POST

Description: Authenticates a user and returns a token for authorized access.

Parameters:
Parameter Type Required Description
platform string Yes Platform type (e.g., mt4, mt4, t-lock)
email string Conditionally Required only if using Trade Locker
account_number string Yes User's account number
account_password string Yes User's account password
account_company string Conditionally Required only if using MT4 or MT5
server string Conditionally Required only if using Trade Locker
account_type string Yes Type of account (live or demo)
Response:
{
    "status": "Success",
    "message": "YOUR_TOKEN_HERE",
}
Example Usage:
import requests

url = "https://www.jblanked.com/trade/api/login/"
payload = {
    "platform": "mt5",
    "account_number": "123456",
    "account_password": "password123",
    "account_company": "Lirunex Ltd",
    "account_type": "demo"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Api-Key YOUR_API_KEY"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
import Foundation

let url = URL(string: "https://www.jblanked.com/trade/api/login/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")

let parameters: [String: Any] = [
    "platform": "mt5",
    "account_number": "123456",
    "account_password": "password123",
    "account_company": "Lirunex Ltd",
    "account_type": "demo"
]

request.httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else { return }
    if let json = try? JSONSerialization.jsonObject(with: data, options: []) {
        print(json)
    }
}
task.resume()

#include <jb-requests.mqh>   // get from https://github.com/jblanked/MQL-Library
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   CRequests request;
   request.url = "https://www.jblanked.com/trade/api/login/";
   request.key = "YOUR_API_KEY";
   request.loader["platform"] = "mt5";
   request.loader["account_number"] = "123456";
   request.loader["account_password"] = "password123";
   request.loader["account_company"] = "Lirunex Ltd";
   request.loader["account_type"] = "demo";

   if(!request.POST())
     {
      Print("Failed to get data from the today endpoint");
      return INIT_FAILED;
     }
   
   // print result
   Print(request.result);
   
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+

Logout

Endpoint: /trade/api/logout/

Method: POST

Description: Logs out the user and invalidates the token.

Parameters:
Parameter Type Required Description
platform string Yes Platform type (e.g., mt4, mt5, t-lock)
token string Yes User's authentication token
Response:
{
    "status": "Success",
    "message": "Disconnected."
}
Example Usage:
import requests

url = "https://www.jblanked.com/trade/api/logout/"
payload = {
    "platform": "mt5",
    "token": "YOUR_TOKEN_HERE"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Api-Key YOUR_API_KEY"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
import Foundation

let url = URL(string: "https://www.jblanked.com/trade/api/logout/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")

let parameters: [String: Any] = [
    "platform": "mt5",
    "token": "YOUR_TOKEN_HERE"
]

request.httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else { return }
    if let json = try? JSONSerialization.jsonObject(with: data, options: []) {
        print(json)
    }
}
task.resume()

#include <jb-requests.mqh>   // get from https://github.com/jblanked/MQL-Library
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   CRequests request;
   request.url = "https://www.jblanked.com/trade/api/logout/";
   request.key = "YOUR_API_KEY";
   request.loader["platform"] = "mt5";
   request.loader["token"] = "YOUR_TOKEN_HERE";

   if(!request.POST())
     {
      Print("Failed to get data from the today endpoint");
      return INIT_FAILED;
     }
   
   // print result
   Print(request.result);
   
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+

New Trade

Endpoint: /trade/api/new/

Method: POST

Description: Creates a new trade order.

Parameters:
Parameter Type Required Description
platform string Yes Platform type (e.g., mt4, mt5, t-lock)
symbol string Yes Trading symbol (e.g., EURUSD)
volume float Yes Trade volume
token string Yes User's authentication token
order_type string Yes Type of order (e.g., buy, sell)
Response:
{
    "status": "Success",
    "message": "123456789.",
}
Example Usage:
import requests

url = "https://www.jblanked.com/trade/api/new/"
payload = {
    "platform": "mt5",
    "symbol": "EURUSD",
    "volume": 1.0,
    "token": "YOUR_TOKEN_HERE",
    "order_type": "buy"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Api-Key YOUR_API_KEY"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
import Foundation

let url = URL(string: "https://www.jblanked.com/trade/api/new/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")

let parameters: [String: Any] = [
    "platform": "mt5",
    "symbol": "EURUSD",
    "volume": 1.0,
    "token": "YOUR_TOKEN_HERE",
    "order_type": "buy"
]

request.httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else { return }
    if let json = try? JSONSerialization.jsonObject(with: data, options: []) {
        print(json)
    }
}
task.resume()

#include <jb-requests.mqh>   // get from https://github.com/jblanked/MQL-Library
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   CRequests request;
   request.url = "https://www.jblanked.com/trade/api/new/";
   request.key = "YOUR_API_KEY";
   request.loader["platform"] = "mt5";
   request.loader["token"] = "YOUR_TOKEN_HERE";
   request.loader["symbol"] = "EURUSD";
   request.loader["volume"] = 1.0;
   request.loader["order_type"] = "buy";

   if(!request.POST())
     {
      Print("Failed to get data from the today endpoint");
      return INIT_FAILED;
     }
   
   // print result
   Print(request.result);
   
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+

Close Trade

Endpoint: /trade/api/close/

Method: POST

Description: Closes an existing trade order.

Parameters:
Parameter Type Required Description
platform string Yes Platform type (e.g., mt4, mt5, t-lock)
ticket string Yes Order ticket number/id
Response:
{
    "status": "Success",
    "message": "Request sent."
}
Example Usage:
import requests

url = "https://www.jblanked.com/trade/api/close/"
payload = {
    "platform": "mt5",
    "ticket": "123456789"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Api-Key YOUR_API_KEY"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
import Foundation

let url = URL(string: "https://www.jblanked.com/trade/api/close/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Api-Key YOUR_API_KEY", forHTTPHeaderField: "Authorization")

let parameters: [String: Any] = [
    "platform": "mt5",
    "ticket": "123456789"
]

request.httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: [])

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    guard let data = data, error == nil else { return }
    if let json = try? JSONSerialization.jsonObject(with: data, options: []) {
        print(json)
    }
}
task.resume()

#include <jb-requests.mqh>   // get from https://github.com/jblanked/MQL-Library
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   CRequests request;
   request.url = "https://www.jblanked.com/trade/api/close/";
   request.key = "YOUR_API_KEY";
   request.loader["platform"] = "mt5";
   request.loader["ticket"] = "123456789";

   if(!request.POST())
     {
      Print("Failed to get data from the today endpoint");
      return INIT_FAILED;
     }
   
   // print result
   Print(request.result);
   
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+