Skip to main content

MT5 Manager API Documentation

Complete PHP SDK for MetaTrader 5 Manager API. Manage trading accounts, execute operations, and access market data programmatically.

Quick start

Get up and running with the MT5 Manager API in minutes

1

Install via Composer

Add the package to your project using Composer:
composer require dev4traders/mt5-manager-api:*@dev
Or add to your composer.json:
{
  "repositories": [{
    "type": "git",
    "url": "https://github.com/dev4traders/mt5-manager-api.git"
  }],
  "require": {
    "dev4traders/mt5-manager-api": "*@dev"
  }
}
2

Initialize the Manager Connection

Connect to your MetaTrader 5 server and obtain an authentication token:
<?php
require_once(__DIR__ . '/vendor/autoload.php');

use D4T\MT5Sdk\MT5Manager\BasicApi;
use GuzzleHttp\Client;

$apiInstance = new BasicApi(new Client());

try {
    $result = $apiInstance->initGet(
        '127.0.0.1:443',  // MT5 server IP:port
        'manager_login',   // Manager login
        'manager_password' // Manager password
    );
    
    $token = $result->getToken();
    echo "Connected! Token: " . $token;
} catch (Exception $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
The token returned by initGet() is required for all subsequent API calls. Store it securely and use it in your API configuration.
3

Configure API Authentication

Set up your configuration with the authentication token:
<?php
use D4T\MT5Sdk\Configuration;
use D4T\MT5Sdk\MT5Manager\AccountApi;

// Create configuration with your token
$config = Configuration::getDefaultConfiguration()
    ->setAccessToken($token);

// Initialize API clients with configuration
$accountApi = new AccountApi(new Client(), $config);
4

Make Your First API Call

Retrieve account information for a user:
<?php
try {
    $account = $accountApi->accountLoginGet(12345);
    
    echo "Login: " . $account->getLogin() . "\n";
    echo "Balance: " . $account->getBalance() . "\n";
    echo "Equity: " . $account->getEquity() . "\n";
    echo "Margin: " . $account->getMargin() . "\n";
    echo "Free Margin: " . $account->getMarginFree() . "\n";
} catch (Exception $e) {
    echo 'API call failed: ' . $e->getMessage();
}
{
  "login": 12345,
  "balance": 10000.00,
  "profit": 150.50,
  "equity": 10150.50,
  "margin": 1000.00,
  "margin_free": 9150.50,
  "margin_level": 1015.05,
  "leverage": 100,
  "volume": 1.5
}

Explore by topic

Dive deeper into specific areas of the MT5 Manager API

Account Management

Retrieve account information, balances, equity, and margin details

User Management

Create, update, and manage trading users, deposits, and withdrawals

Trading Operations

Access positions, orders, deals, and execute trading operations

Market Data

Get symbols, groups, and market information from your MT5 server

Core features

Everything you need to integrate with MetaTrader 5

Bearer Authentication

Secure token-based authentication for all API operations

Complete Type Definitions

Full model classes for all API request and response objects

PHP 7.4+ & 8.0+ Support

Modern PHP compatibility with Guzzle HTTP client

API reference

Comprehensive documentation for all API classes and models

BasicApi

Initialize connections and ping the API

AccountApi

Retrieve account information by login

UserApi

Manage users, deposits, and withdrawals

TradeApi

Access positions, orders, and deals

GroupApi

Retrieve group configurations

SymbolApi

Get market symbols and specifications

Ready to get started?

Install the SDK and start managing your MetaTrader 5 platform programmatically in minutes.

View Quickstart Guide