> 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/v1/live/live-ws.md).

# live ws

## View all live matches with WebSocket ID mapping 🟩

<mark style="color:blue;">`GET`</mark> `https://api.soccerfootball.info/v1/live/ws/`

This endpoint returns all currently live matches with the dual ID mapping system for the **MAIN\_REALTIME** WebSocket channel.\
Each ID field (match, team, championship) is an object containing two identifiers:\
\&#xNAN;**`ws_realtime`**: the ID used exclusively in the **MAIN\_REALTIME** channel messages\
\&#xNAN;**`rest_releated`**: the ID used in standard REST API endpoints and in all other WebSocket channels (MAIN, STATS, ODDS, STATS\_REALTIME, ODDS\_REALTIME)\
This mapping allows you to bridge between MAIN\_REALTIME events and the rest of the API.\
The parameter **`l`** must be a language code getted from languages/list endpoint.\
Format CSV is in MS excel compatible mode (double click open without import!)

{% hint style="warning" %}
**MAIN\_REALTIME only** — This endpoint is needed only if you subscribe to the **MAIN\_REALTIME** channel (MEGA plan 🟩). All other WebSocket channels already use REST IDs, so no mapping is required for them.
{% endhint %}

#### Query Parameters

| Name | Type   | Description                                             |
| ---- | ------ | ------------------------------------------------------- |
| t    | string | Your API Token **`DIRECT API ONLY`**                    |
| f    | string | Format response can be "json" or "csv" (default "json") |
| l    | string | Language code (default value is "en\_US")               |

#### Headers

| Name            | Type   | Description                                         |
| --------------- | ------ | --------------------------------------------------- |
| X-RapidAPI-Key  | string | Your API token **`RAPIDAPI ONLY`**                  |
| X-RapidAPI-Host | string | soccerfootballinfo.rapidapi.com **`RAPIDAPI ONLY`** |

{% tabs %}
{% tab title="200 Success response" %}
{% tabs %}
{% tab title="JSON" %}

```javascript
{
   "status":200,
   "errors":[],
   "pagination":[],
   "result":[
      {
         "id":{
            "ws_realtime":"a1b2c3d4e5f6a7b8", // WebSocket real-time match ID
            "rest_releated":"5ff7a0c8ceb4f157" // REST API match ID
         },
         "date":"2024-09-15 16:00:00",
         "timer":"45:00+02:10", // match timer, if in extra time: 90:00+01:00
         "est_e_time":"3", // estimated extra time, false if unknown
         "in_play":true, // if match is currently in play
         "championship":{
            "id":{
               "ws_realtime":"b2c3d4e5f6a7b8c9", // WebSocket championship ID
               "rest_releated":"5fda5fa8541c9de5" // REST API championship ID
            },
            "name":"Premier League",
            "country":"GB"
         },
         "teamA":{
            "id":{
               "ws_realtime":"c3d4e5f6a7b8c9d0", // WebSocket team ID
               "rest_releated":"5fda5fcd1aa9fae1" // REST API team ID
            },
            "name":"Manchester United",
            "score":{
               "f":"2", // final/current score
               "1h":"1", // first half score
               "2h":"1", // second half score
               "o":null, // overtime score
               "p":null // penalties score
            }
         },
         "teamB":{
            "id":{
               "ws_realtime":"d4e5f6a7b8c9d0e1",
               "rest_releated":"5fda5fcd1aa9fae2"
            },
            "name":"Liverpool",
            "score":{
               "f":"1",
               "1h":"0",
               "2h":"1",
               "o":null,
               "p":null
            }
         }
      },
      ...
   ]
}
```

{% endtab %}

{% tab title="CSV" %}

```
id_ws_realtime;id_rest_releated;date;timer;est_e_time;in_play;championship_id_ws_realtime;championship_id_rest_releated;championship_name;championship_country;teamA_id_ws_realtime;teamA_id_rest_releated;teamA_name;teamA_score_f;teamA_score_1h;teamA_score_2h;teamA_score_o;teamA_score_p;teamB_id_ws_realtime;teamB_id_rest_releated;teamB_name;teamB_score_f;teamB_score_1h;teamB_score_2h;teamB_score_o;teamB_score_p
a1b2c3d4e5f6a7b8;5ff7a0c8ceb4f157;"2024-09-15 16:00:00";45:00+02:10;3;yes;b2c3d4e5f6a7b8c9;5fda5fa8541c9de5;"Premier League";GB;c3d4e5f6a7b8c9d0;5fda5fcd1aa9fae1;"Manchester United";2;1;1;;;d4e5f6a7b8c9d0e1;5fda5fcd1aa9fae2;"Liverpool";1;0;1;;
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

{% file src="/files/XJTQH8tCM5ZJYoj0jBag" %}

## Example of code for direct API

{% tabs %}
{% tab title="PHP" %}

```php
$url = 'https://api.soccerfootball.info/v1/live/ws/';

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_PROXY => null,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_CUSTOMREQUEST => "GET"
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if (!$err) {
  $result = json_decode($response);
  print_r($result);
} else {
    echo "cURL Error:" . $err;
}
```

{% endtab %}

{% tab title="Javascript" %}

```python
fetch("https://api.soccerfootball.info/v1/live/ws/", {
    "method": "GET"
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.error(err);
});
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const request = require('request');

const options = {
  method: 'GET',
  url: 'https://api.soccerfootball.info/v1/live/ws/'
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});
```

{% endtab %}

{% tab title="Phyton" %}

```python
import requests

url = "https://api.soccerfootball.info/v1/live/ws/"

response = requests.get(url).json()

print(response)
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
    --url 'https://api.soccerfootball.info/v1/live/ws/'
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://api.soccerfootball.info/v1/live/ws/"

    req, _ := http.NewRequest("GET", url, nil)

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
```

{% endtab %}
{% endtabs %}

## Example of code for RapidAPI

{% tabs %}
{% tab title="PHP" %}

```php
$url = 'https://soccer-football-info.p.rapidapi.com/live/ws/';

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_PROXY => null,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "X-RapidAPI-Host: soccer-football-info.p.rapidapi.com",
        "X-RapidAPI-Key: TOKEN"
    ],
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if (!$err) {
  $result = json_decode($response);
  print_r($result);
} else {
    echo "cURL Error:" . $err;
}
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch("https://soccer-football-info.p.rapidapi.com/live/ws/", {
    "method": "GET",
    "headers": {
        "X-RapidAPI-Key": "TOKEN",
        "X-RapidAPI-Host": "soccer-football-info.p.rapidapi.com"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.error(err);
});
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const request = require('request');

const options = {
  method: 'GET',
  url: "https://soccer-football-info.p.rapidapi.com/live/ws/",
  headers: {
   "X-RapidAPI-Key": "TOKEN",
     "X-RapidAPI-Host": "soccer-football-info.p.rapidapi.com"
   useQueryString: true
  }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});
```

{% endtab %}

{% tab title="Phyton" %}

```python
import requests

url = "https://soccer-football-info.p.rapidapi.com/live/ws/"

headers = {
    "X-RapidAPI-Key": "TOKEN",
      "X-RapidAPI-Host": "soccer-football-info.p.rapidapi.com"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
    --url https://soccer-football-info.p.rapidapi.com/live/ws/ \
    --header 'X-RapidAPI-Host: soccer-football-info.p.rapidapi.com' \
    --header 'X-RapidAPI-Key: TOKEN'
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://soccer-football-info.p.rapidapi.com/live/ws/"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("X-RapidAPI-Key", "TOKEN")
    req.Header.Add("X-RapidAPI-Host", "soccer-football-info.p.rapidapi.com")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
```

{% endtab %}
{% endtabs %}

More example of code on [rapidAPI](https://rapidapi.com/soccerfootball-info-soccerfootball-info-default/api/soccer-football-info)
