# MT4 API documentation: REST and WebSocket in 2026

> Tickwire gives MetaTrader 4 a documented REST and WebSocket API on a hosted terminal. This guide maps the MT4 API docs: endpoints, streams, errors and limits.

Source: https://tickwire.io/blog/mt4-api-documentation-guide/

Tickwire blog, published 2026-10-26. General information, not investment advice.

MetaTrader 4 has no official API for traders, so "MT4 API documentation" usually means the docs of a service that runs the terminal for you. Tickwire is one: it hosts a real MT4 terminal for each account and documents a REST and WebSocket API for it, the same one MT5 uses. This guide shows where each part of the MT4 API lives in the [Tickwire docs](https://tickwire.io/docs/), with working examples.

If you only want the summary of what works on MT4 and what doesn't, read the [MetaTrader 4 API](https://tickwire.io/mt4-api/) page. This post is the developer's map.

## Two kinds of "MT4 API"

Searches for "MT4 API" mix up two different things.

- **Server-side APIs for brokers.** The maker of MetaTrader sells server, manager, web services and report interfaces to brokers that run their own MT4 servers. They manage a whole server: create clients, set groups, read every account. A trader's login can't use them, and a retail trader can't buy them.
- **Trader-side APIs.** These act for one trading account, with its own login: read the balance, place and close orders, stream prices. MT4 has no built-in one. You either write code inside the terminal yourself or use a hosted service that does it for you.

Tickwire is the second kind. It works with any broker, because it logs in to your account the same way the desktop terminal does. You give the server name from the terminal's login dialog, and that's all the broker setup there is.

## Three ways to call the same MT4 terminal

| Surface | Paths | Good for |
|---|---|---|
| Account REST API | `/users/current/accounts/{id}/…` | New code, with camelCase fields shared with MT5 |
| Terminal routes | `/mt4/{id}/…` | Code that already uses `AccountSummary`, `OrderSend` and similar calls |
| MCP server | `https://api.tickwire.io/mcp` | Claude, ChatGPT and other AI apps |

All three reach the same terminal, so you can mix them. The [docs home](https://tickwire.io/docs/) explains when to pick which, and the [API reference](https://tickwire.io/docs/reference/) lists every endpoint.

## Start in the sandbox

The free [sandbox](https://tickwire.io/docs/sandbox/) gives you an MT4 account in one call. No card, no broker login.

```bash
export TW=https://api.tickwire.io
curl -s -X POST "$TW/v1/sandbox/signup" -H "content-type: application/json" -d '{"platform": "mt4"}'
```

The answer has a `twsk_` key, shown once, and an account id such as `acc_7Qx`. Set the key as `TW_KEY`. Sandbox MT4 accounts behave as MT4 does, including the features it lacks.

## Ask the account what it supports

```bash
curl -s "$TW/users/current/accounts/acc_7Qx/capabilities" -H "auth-token: $TW_KEY"
```

On MT4 the `features` object says `marketDepth`, `historicalTicks` and `stopLimitOrders` are `false`, and `closeBy` is `broker_dependent`. It also lists the nine MT4 timeframes: `1m 5m 15m 30m 1h 4h 1d 1w 1mn`. Code written for both platforms can branch on this instead of catching errors.

## Read the account

```bash
curl -s "$TW/users/current/accounts/acc_7Qx/account-information" -H "auth-token: $TW_KEY"
curl -s "$TW/users/current/accounts/acc_7Qx/positions" -H "auth-token: $TW_KEY"
```

`brokerTime` in the first answer is the broker's local time. It is not UTC. See [Time zones](https://tickwire.io/docs/time-zones/).

## Place and close an order

Every order takes an `Idempotency-Key`. Send the same key again and you get the first answer back, never a second order. `X-Actor` and `X-Reason` go into the audit log.

```bash
curl -s -X POST "$TW/users/current/accounts/acc_7Qx/trade" \
  -H "auth-token: $TW_KEY" \
  -H "Idempotency-Key: mt4-first-order-1" \
  -H "X-Actor: docs-guide" -H "X-Reason: first MT4 order" \
  -H "content-type: application/json" \
  -d '{"actionType": "ORDER_TYPE_BUY", "symbol": "EURUSD", "volume": 0.01}'
```

The answer carries `outcome`: `applied`, `no_change`, `rejected` or `unknown`. After `unknown`, read positions before you do anything else. See [Idempotency](https://tickwire.io/docs/idempotency/).

The same order on the terminal routes looks like this:

```bash
curl -s -X POST "$TW/mt4/acc_7Qx/OrderSend" \
  -H "X-API-Key: $TW_KEY" \
  -H "Idempotency-Key: mt4-first-order-2" \
  -H "X-Actor: docs-guide" -H "X-Reason: first MT4 order" \
  -H "content-type: application/json" \
  -d '{"symbol": "EURUSD", "operation": "Buy", "volume": 0.01}'
```

The terminal routes also include `AccountSummary`, `OpenedOrders`, `OrderHistory`, `PriceHistory`, `SymbolInfo`, `OrderModify`, `OrderClose` and `CloseAll`.

## Stream with WebSocket

```bash
websocat "wss://api.tickwire.io/users/current/accounts/acc_7Qx/ws?auth-token=$TW_KEY"
{"type":"subscribe","marketData":[{"symbol":"EURUSD","subscriptions":[{"type":"quotes"}]}]}
```

You get a full sync, then price and health frames. Position changes arrive on the same socket. Live MT4 ticks are captured from the moment you subscribe, so there is no tick history to read back. See [Streaming](https://tickwire.io/docs/streaming/).

## What MT4 can't do

These calls answer `not_supported_on_mt4` instead of fake data:

- market depth;
- historical ticks;
- stop-limit orders;
- `DAY` and `SPECIFIED_DAY` expiry on pending orders.

MT4 accounts are hedging only. Close-by depends on the broker. History comes from closed orders, which Tickwire turns into deals and history orders with the same fields as MT5. The [platforms page](https://tickwire.io/docs/platforms/) has the full list, and [MT4 vs MT5 for algo trading](https://tickwire.io/blog/mt4-vs-mt5-for-algo-trading/) explains the differences.

## Errors and limits

Errors share one envelope with an `error` code and a `message`. Each code has its own page under [Errors](https://tickwire.io/docs/errors/), with the likely cause and what to do. Limits are plain token buckets per key and per account, and a trade refused by a limit says `"sent": false`. See [Rate limits](https://tickwire.io/docs/rate-limits/).

## Frequently asked questions

### Does MetaTrader 4 have an official API?

Not for traders. The MT4 server, manager and web APIs are for brokers that run their own MT4 servers, and a trader's login can't use them. To call a single MT4 account from code, you use a hosted service such as Tickwire, which runs the terminal and gives it a REST and WebSocket API.

### Is there an MT4 REST API?

Yes, through Tickwire. Each account gets REST endpoints for account information, positions, orders, trading, quotes, candles and history, plus terminal routes under /mt4/{id}/ and a WebSocket stream.

### Is the MT4 API the same as the MT5 API?

Almost. Tickwire uses the same endpoints and fields for both. The few MT5 features MT4 lacks, such as market depth and tick history, answer not_supported_on_mt4. You choose the platform when you add the account.

### Can I use the MT4 API from Python, Node or any language?

Yes. It is plain HTTPS and WebSocket, so any language with an HTTP client works. The docs use curl, and the guides show Python.

### Where is the full MT4 API reference?

In the [API reference](https://tickwire.io/docs/reference/), generated from the OpenAPI file. The [quickstart](https://tickwire.io/docs/quickstart/) walks through the first calls, and the [platforms page](https://tickwire.io/docs/platforms/) lists what differs on MT4.

### How much does the MT4 API cost?

The same as MT5: from $12 per account a month, after a 7-day free trial. The sandbox is free. See [pricing](https://tickwire.io/pricing/).
