# MetaTrader 5 Python Package vs REST API: Which Should You Use?

> The official MetaTrader5 package needs Windows and a running terminal; a hosted REST API needs neither. Setup, hosting, languages and upkeep compared.

Published 2026-10-08 by fxapis. Canonical: https://fxapis.com/blog/metatrader5-python-package-vs-rest-api

## In short

- The official MetaTrader5 package is a bridge to a terminal on the same Windows machine. It is not a network client for your broker.
- That makes it a good fit for research and personal trading on a Windows PC, and an awkward one for servers, Linux, macOS and many accounts.
- A hosted REST API runs the terminals for you: any language, any operating system, many accounts, and a recorded result for every order.
- The package also gives you prices, bars and ticks. fxapis does not stream market data, so a strategy built on MT5 data needs another source for it.

Both get an order from Python to MetaTrader 5. They differ in where MetaTrader runs, and therefore in where your code can run. **Use the official package for research and personal trading on a Windows PC. Use a hosted REST API for anything that runs on a server, outside Windows, or across many accounts.**

## What the official package is

`MetaTrader5` on PyPI is MetaQuotes' own package. Its documentation describes it as getting data "via interprocessor communication directly from the MetaTrader 5 terminal" — it is a bridge to a terminal process on the same computer. `initialize()` connects to that terminal (and launches it if needed), and every call after it goes through the terminal.

Two consequences follow: you need a **running terminal** next to your script, and you need **Windows** — the files published for the package are Windows builds.

## What a hosted REST API is

A hosted API runs the MetaTrader 5 terminals on its own servers and accepts HTTPS requests. Your script does not talk to a terminal; it talks to the API, from any machine:

```python
import os, uuid, requests

API = "https://api.fxapis.com"
s = requests.Session()
s.headers["Authorization"] = f"Bearer {os.environ['FXAPIS_KEY']}"

order = s.post(
    f"{API}/v1/accounts/{os.environ['ACCOUNT_ID']}/orders/market",
    headers={"Idempotency-Key": str(uuid.uuid4())},
    json={"symbol": "EURUSD", "side": "buy", "volume": "0.01"},
    timeout=90,
).json()["data"]
print(order["state"], order["filledPrice"])
```

The account was connected once beforehand with its login, password and server. There is no `initialize()`, no terminal path, and no Windows.

## Side by side

| | MetaTrader5 package | Hosted REST API (fxapis) |
|---|---|---|
| Operating system | Windows (or Wine) | Any |
| Needs a terminal running | Yes, on the same machine | No — run by the provider |
| Languages | Python | Any language with HTTPS |
| Accounts at once | One per terminal | Many per workspace, one request for many |
| Where your code runs | Next to the terminal | Anywhere: server, container, function |
| Market data (ticks, bars) | Yes | No |
| Retry safety | Yours to build | Idempotency keys; unclear results confirmed with the broker |
| Upkeep | Terminal, machine, logins | Your code |
| Cost | Free, plus the machine | A monthly plan |

## When the package is the better choice

- You are **researching** a strategy and need MT5's historical bars and ticks.
- You trade **your own account** from a Windows machine you already keep running.
- You want no third party between you and your broker.

## When a REST API is the better choice

- Your backend runs on **Linux, macOS or in containers** — which is most backends.
- You trade **other people's accounts**, or many accounts at once.
- You want results you can **retry safely** and **audit**: every order has a recorded state, and an order whose outcome is unclear is confirmed against the broker's records instead of guessed.

Many teams use both: the package, or another data source, for research; the API for placing and tracking trades in production.

## Next steps

- [Use the MT5 API on Linux and macOS](https://docs.fxapis.com/guides/linux-macos) — the workarounds people use for the package, and a table mapping each of its calls to the API.
- [Place MT5 orders from Python](https://docs.fxapis.com/guides/python) — a complete program with correct retries.
- [The MT5 API](https://fxapis.com/mt5-api) — everything the API covers.

## Questions

### Does the MetaTrader5 Python package work on Linux or macOS?

Not directly. The package's published files on PyPI are Windows builds, and it talks to a MetaTrader 5 terminal on the same machine. On Linux and macOS people run the terminal and a Windows Python under Wine, use a bridge, or rent a Windows VPS.

### Can I use Python with a REST API for MT5?

Yes. A REST API takes HTTPS requests, so any Python HTTP library works — requests, httpx or aiohttp — on any operating system, with no MetaTrader installed.

### Does fxapis provide historical price data?

No. fxapis covers accounts, orders, positions and trade history. It does not stream prices or serve bars and ticks, so you need a market data source if your strategy computes signals from them.

### Can I trade several MT5 accounts from one Python script with the official package?

A terminal is logged in to one account at a time, so trading several accounts at once with the package means running and coordinating several terminals. A hosted API connects each account separately and lets one request place a trade on many.
