# Quickstart

Source: https://docs.api2trade.com/docs/quickstart

> From an API key to live quotes in four steps.

Everything below uses one credential: your team's API key, which you can copy
from **Settings** in the [dashboard](https://app.api2trade.com/dashboard/general).

```bash
export API2TRADE_API_KEY="your-key"
```

## 1. Connect a trading account

Give the API your MetaTrader credentials and the server name exactly as your
broker writes it in the account details email.

```bash
curl -X POST \
  -H "X-API-Key: $API2TRADE_API_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "accountNumber": "1082118",
    "name": "Demo one",
    "type": "Metatrader 5",
    "accountPassword": "your-mt-password",
    "accountServerHost": "ICMarketsEU-Demo"
  }' \
  'https://api.api2trade.com/v2/accounts'
```

The response comes back immediately with `"terminalStatus": "provisioning"` and
the account's `id` — a UUID. Every call from here on uses it.

<Callout title="Prefer clicking?">
  The dashboard does the same thing: **Accounts → Add Account → API v2**. The
  [API Playground](https://app.api2trade.com/dashboard/playground) then lets you
  try every endpoint on this page without writing any code, and shows the
  matching `curl` for each one.
</Callout>

## 2. Wait for it to come up

A dedicated connection is set up for your account and logs in to your broker.
That takes a few minutes. Poll until it settles:

```bash
curl -s -H "X-API-Key: $API2TRADE_API_KEY" \
  'https://api.api2trade.com/v2/accounts/YOUR_ACCOUNT_ID' \
  | grep -o '"terminalStatus":"[^"]*"'
```

`ready` means it is logged in and serving. `error` means it will not come up on
its own, and `terminalLastError` says why — usually a wrong account number,
password or server name. See [Errors](/docs/api-v2/errors).

## 3. Call the account's own API

Each connected account gets its own base URL:

```
https://api.api2trade.com/v2/{account_id}/
```

```bash title="Is it actually trading-ready?"
curl -s -H "X-API-Key: $API2TRADE_API_KEY" \
  'https://api.api2trade.com/v2/YOUR_ACCOUNT_ID/status'
```

Check `broker.connected` and `account.loggedIn` before trusting any numbers —
a connection that never logged in still answers `200`, with zeros.

```bash title="A quote"
curl -s -H "X-API-Key: $API2TRADE_API_KEY" \
  'https://api.api2trade.com/v2/YOUR_ACCOUNT_ID/getQuote?symbol=EURUSD'
```

```bash title="Balance and equity"
curl -s -H "X-API-Key: $API2TRADE_API_KEY" \
  'https://api.api2trade.com/v2/YOUR_ACCOUNT_ID/AccountSummary'
```

The full list is under [Trading API](/docs/api-v2/trading-api/system).

## 4. Stream instead of polling

Quotes, positions and trade events are all available on one socket, which is
cheaper and faster than polling `getQuote` in a loop:

```
wss://api.api2trade.com/v2/{account_id}/ws?api_key=YOUR_API_KEY
```

```json
{ "action": "subscribe", "topic": "prices", "symbol": "EURUSD" }
```

See [WebSocket](/docs/api-v2/websocket) for every topic and the frame shapes.

## What next

<Cards>
  <Card title="Account API" href="/docs/api-v2/account-api/accounts" description="Connect, list and disconnect accounts." />

  <Card title="Trading API" href="/docs/api-v2/trading-api/system" description="Everything one connected account can do." />

  <Card title="WebSocket" href="/docs/api-v2/websocket" description="Live prices, bars, positions and trade events." />

  <Card title="Errors" href="/docs/api-v2/errors" description="What failures look like and which are worth retrying." />
</Cards>
