> For the complete documentation index, see [llms.txt](https://info.soccerfootball.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://info.soccerfootball.info/websocket/channels/main-realtime.md).

# MAIN REALTIME

## MAIN\_REALTIME Channel

The MAIN\_REALTIME channel delivers the same key match events as the MAIN channel, but with the lowest possible latency available in the market. This is the fastest channel for receiving soccer match events in real-time, designed for applications where milliseconds matter, such as live betting platforms, in-play trading systems, and real-time score trackers.

### Availability

| Plan  | Available |
| ----- | --------- |
| BASIC | No        |
| PRO   | No        |
| ULTRA | No        |
| MEGA  | Yes       |

{% hint style="warning" %}
**RapidAPI clients connecting from Asia: MAIN\_REALTIME is not available on the Asian node**

The `MAIN_REALTIME` channel is currently served **only** from the European node (`wss://ws-eu.soccerfootball.info`).

If you are a **RapidAPI** customer connecting from **Asia**, the `/v1/ws/new` response will route you to the Asian node and the `server` URL will point to `wss://ws-as.soccerfootball.info`. On that node the `MAIN_REALTIME` channel will \* *not*\* be available.

If you need `MAIN_REALTIME` in this situation, please email **<info@soccerfootball.info>**. We will set up a parallel, working token for you so you can connect to the European node and use the channel without issues.
{% endhint %}

### Events

| Event               | Description         |
| ------------------- | ------------------- |
| match\_start        | Match has started   |
| goal                | A goal was scored   |
| halftime            | First half ended    |
| second\_half\_start | Second half started |
| match\_end          | Match has ended     |

***

### match\_start

Fired when a match kicks off.

#### Message

```json
{
  "type": "match_start",
  "channel": "MAIN_REALTIME",
  "matchId": "12345",
  "leagueId": "67890",
  "ts": 1705312800000,
  "data": {
    "teamA": {
      "id": "1001",
      "name": "Manchester United"
    },
    "teamB": {
      "id": "1002",
      "name": "Liverpool"
    },
    "championship": {
      "id": "67890",
      "name": "Premier League",
      "country": "England",
      "seasonName": "2023/2024"
    },
    "startDate": "2024-01-15T15:00:00Z"
  }
}
```

#### Data Fields

| Field                     | Type   | Description                 |
| ------------------------- | ------ | --------------------------- |
| `teamA`                   | object | Home team information       |
| `teamA.id`                | string | Team public ID              |
| `teamA.name`              | string | Team name                   |
| `teamB`                   | object | Away team information       |
| `teamB.id`                | string | Team public ID              |
| `teamB.name`              | string | Team name                   |
| `championship`            | object | Championship information    |
| `championship.id`         | string | Championship public ID      |
| `championship.name`       | string | Championship name           |
| `championship.country`    | string | Country                     |
| `championship.seasonName` | string | Season name                 |
| `startDate`               | string | Match start time (ISO 8601) |

***

### goal

Fired when a goal is scored.

#### Message

```json
{
  "type": "goal",
  "channel": "MAIN_REALTIME",
  "matchId": "12345",
  "leagueId": "67890",
  "ts": 1705314600000,
  "data": {
    "score": "1;0",
    "timer": "23",
    "team": "A"
  }
}
```

#### Data Fields

| Field   | Type   | Description                                |
| ------- | ------ | ------------------------------------------ |
| `score` | string | Current score in format "teamA;teamB"      |
| `timer` | string | Match minute when goal was scored          |
| `team`  | string | Team that scored: "A" (home) or "B" (away) |

#### Score Format

The score is formatted as `"X;Y"` where:

* `X` = Goals scored by Team A (home)
* `Y` = Goals scored by Team B (away)

Example: `"2;1"` means Team A is winning 2-1.

***

### halftime

Fired when the first half ends.

#### Message

```json
{
  "type": "halftime",
  "channel": "MAIN_REALTIME",
  "matchId": "12345",
  "leagueId": "67890",
  "ts": 1705315500000,
  "data": {
    "score": "1;1"
  }
}
```

#### Data Fields

| Field   | Type   | Description                               |
| ------- | ------ | ----------------------------------------- |
| `score` | string | Score at halftime in format "teamA;teamB" |

***

### second\_half\_start

Fired when the second half kicks off.

#### Message

```json
{
  "type": "second_half_start",
  "channel": "MAIN_REALTIME",
  "matchId": "12345",
  "leagueId": "67890",
  "ts": 1705316400000,
  "data": {
    "score": "1;1"
  }
}
```

#### Data Fields

| Field   | Type   | Description                        |
| ------- | ------ | ---------------------------------- |
| `score` | string | Current score at second half start |

***

### match\_end

Fired when the match ends (full time, or after extra time/penalties if applicable).

#### Message

```json
{
  "type": "match_end",
  "channel": "MAIN_REALTIME",
  "matchId": "12345",
  "leagueId": "67890",
  "ts": 1705318800000,
  "data": {
    "finalScore": "2;1",
    "score1h": "1;1"
  }
}
```

#### Data Fields

| Field        | Type   | Description                              |
| ------------ | ------ | ---------------------------------------- |
| `finalScore` | string | Final score in format "teamA;teamB"      |
| `score1h`    | string | First half score in format "teamA;teamB" |

***

### MAIN vs MAIN\_REALTIME Comparison

| Feature           | MAIN                   | MAIN\_REALTIME                        |
| ----------------- | ---------------------- | ------------------------------------- |
| Events            | Same 5 event types     | Same 5 event types                    |
| Latency           | Standard               | Ultra-low (fastest available)         |
| Plan availability | PRO, ULTRA, MEGA       | MEGA only                             |
| Best for          | General match tracking | Live betting, trading, real-time apps |

***

### Subscription Examples

#### Subscribe to all MAIN\_REALTIME events

```json
{"action": "subscribe", "channel": "MAIN_REALTIME", "scope": "all"}
```

#### Subscribe to a specific match

```json
{"action": "subscribe", "channel": "MAIN_REALTIME", "scope": "match", "id": "b01d28ac92221034"}
```

#### Subscribe to a league

```json
{"action": "subscribe", "channel": "MAIN_REALTIME", "scope": "league", "id": "f2b16fa54cb525d"}
```

***

### Example: Tracking a Match

```javascript
ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);

  if (msg.channel !== 'MAIN_REALTIME') return;

  switch (msg.type) {
    case 'match_start':
      console.log(`Match started: ${msg.data.teamA.name} vs ${msg.data.teamB.name}`);
      break;

    case 'goal':
      const [homeGoals, awayGoals] = msg.data.score.split(';');
      const scorer = msg.data.team === 'A' ? 'Home' : 'Away';
      console.log(`GOAL! ${scorer} team scores at ${msg.data.timer}'`);
      console.log(`Score: ${homeGoals} - ${awayGoals}`);
      break;

    case 'halftime':
      console.log(`Halftime: ${msg.data.score.replace(';', ' - ')}`);
      break;

    case 'second_half_start':
      console.log('Second half started');
      break;

    case 'match_end':
      console.log(`Full time: ${msg.data.finalScore.replace(';', ' - ')}`);
      console.log(`First half was: ${msg.data.score1h.replace(';', ' - ')}`);
      break;
  }
};
```
