> 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/teams/versus.md).

# versus

## Versus results between two teams ⬜ 🟨 🟦 🟩

<mark style="color:blue;">`GET`</mark> `https://api.soccerfootball.info/v1/teams/versus/?x=IDX&y=IDY`

This endpoint returns with all matches between two teams and its results \
You can define two teams, one with **`x`** and another with **`y`** \
With parameter **`w`** you can define the time lapse "all" (from 2017 01 01), "1y" last year, "6m" last 6 months. \
The parameter **`l`** must be a language code getted from languages/list endpoint.\
Some elements such as championship and team names can be translated.\
Format response can be "json" or "csv" (Default "json")

#### Query Parameters

| Name | Type   | Description                                                    |
| ---- | ------ | -------------------------------------------------------------- |
| t    | string | Your API Token **`DIRECT API ONLY`**                           |
| f    | string | Format response can be "json" or "csv" (default "csv")         |
| x    | string | ID of X TEAM                                                   |
| y    | string | ID of Y TEAM                                                   |
| w    | string | When get time can be "all", "1y", "6m" (default value is "6m") |
| 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":[
      {
         "lapse":"all",
         "teamX":{
            "id":"5fda6034be4e9d6b",
            "name":"Inter"
         },
         "teamY":{
            "id":"5fda5fcad92584cd",
            "name":"Milan"
         },
         "results":{
            "teamX":5, // times of X wins
            "teamY":2, // times of Y wins
            "draw":2 // times of matces go draw
         },
         "macthes":[
            {
               "id":"5fb96897c83c9629",
               "date":"2020-10-17 16:00:00",
               "championship":{
                  "id":"5fda5fab11fbd288",
                  "name":"Italia - Serie A",
                  "s_name":"Serie A 20/21"
               },
               "teamA":{
                  "id":"5fda6034be4e9d6b",
                  "name":"Inter",
                  "score":"1"
               },
               "teamB":{
                  "id":"5fda5fcad92584cd",
                  "name":"Milan",
                  "score":"2"
               }
            },
            ...
         ]
      }
   ]
}
```

{% endtab %}

{% tab title="CSV" %}

```
time_all;match_id;date_match;champipship;championship_id;season_name;teamA_name;teamA_id;teamA_score;teamB_name;teamB_id;teamB_score
;600772c53a14d889;"2021-01-26 19:45:00";"Italia - Coppa Italia";5fda5fa8d5514fc8;;Inter;5fda6034be4e9d6b;2;Milan;5fda5fcad92584cd;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/teams/versus/?t=TOKEN&x=IDX&y=IDY';

$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/teams/versus/?t=TOKEN&x=IDX&y=IDY", {
    "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/teams/versus/?t=TOKEN&x=IDX&y=IDY'
};

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/teams/versus/?t=TOKEN&x=IDX&y=IDY"

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

print(response)
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
    --url 'https://api.soccerfootball.info/v1/teams/versus/?t=TOKEN&x=IDX&y=IDY'
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

func main() {

    url := "https://api.soccerfootball.info/v1/teams/versus/?t=TOKEN&x=IDX&y=IDY"

    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/teams/versus/?x=IDX&y=IDY';

$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/teams/versus/?x=IDX&y=IDY", {
    "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/teams/versus/?x=IDX&y=IDY",
  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/teams/versus/?x=IDX&y=IDY"

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/v1/teams/versus/?x=IDX&y=IDY \
    --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/teams/versus/?x=IDX&y=IDY"

    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-)
