# Search counters to a defense team

Section: PVP statistics

```
POST https://ba.joexyz.online/api/v1/pvp/stats/search?limit=20&cursor=
```

Finds attack teams that were used against a defense team, with their
    win/loss records. Leave a slot's `studentId` out to match anyone there.

    `matchMode` is `primary` (exact slots, default) or `similar`. This is a
    read-only search: POST is used only because the input is structured.

Results are paginated: follow `pagination.nextCursor` while `pagination.hasMore` is `true`.

**Parameters**

- `limit`: Page size, 1–100. Defaults to 50.
- `cursor`: The `pagination.nextCursor` of the previous page.

## Authentication

None

## Query parameters

| Name | Value |
| --- | --- |
| `limit` | `20` |
| `cursor` |  |

## Headers

| Name | Value |
| --- | --- |
| `Content-Type` | `application/json` |

## Body

Content type: `application/json`

```json
{
  "season": 11,
  "defenseTeam": [
    {
      "studentId": "hoshino"
    },
    {
      "studentId": "iori"
    },
    {},
    {},
    {
      "studentId": "himari"
    },
    {}
  ],
  "excludedStudentIds": [],
  "matchMode": "primary"
}
```

## Example responses

### 200 OK

```json
{
  "data": [
    {
      "attackTeam": [
        {
          "studentId": "hoshino",
          "level": 90,
          "starLevel": 5
        },
        {
          "studentId": "aru"
        },
        {
          "studentId": "iori"
        },
        {
          "studentId": "neru"
        },
        {
          "studentId": "himari"
        },
        {
          "studentId": "ako"
        }
      ],
      "defenseTeam": [
        {
          "studentId": "hoshino",
          "level": 90,
          "starLevel": 5
        },
        {
          "studentId": "aru"
        },
        {
          "studentId": "iori"
        },
        {
          "studentId": "neru"
        },
        {
          "studentId": "himari"
        },
        {
          "studentId": "ako"
        }
      ],
      "matchupId": "…",
      "wins": 14,
      "losses": 2,
      "total": 16,
      "…": "more fields"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "…"
  }
}
```

### 429 Too Many Requests

```http
Retry-After: 41
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1793620860
```

```json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Too many requests. Try again in 41 seconds."
  }
}
```

## Examples

### cURL

```bash
curl -X POST 'https://ba.joexyz.online/api/v1/pvp/stats/search?limit=20&cursor=' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "season": 11,
  "defenseTeam": [
    {
      "studentId": "hoshino"
    },
    {
      "studentId": "iori"
    },
    {},
    {},
    {
      "studentId": "himari"
    },
    {}
  ],
  "excludedStudentIds": [],
  "matchMode": "primary"
}'
```

### JavaScript

```javascript
const response = await fetch("https://ba.joexyz.online/api/v1/pvp/stats/search?limit=20&cursor=", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "season": 11,
    "defenseTeam": [
      {
        "studentId": "hoshino"
      },
      {
        "studentId": "iori"
      },
      {},
      {},
      {
        "studentId": "himari"
      },
      {}
    ],
    "excludedStudentIds": [],
    "matchMode": "primary"
  }),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://ba.joexyz.online/api/v1/pvp/stats/search?limit=20&cursor="
payload = {
    "season": 11,
    "defenseTeam": [
        {
            "studentId": "hoshino",
        },
        {
            "studentId": "iori",
        },
        {},
        {},
        {
            "studentId": "himari",
        },
        {},
    ],
    "excludedStudentIds": [],
    "matchMode": "primary",
}

response = requests.post(url, json=payload)
print(response.json())
```

### Go

```go
package main

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

func main() {
	body := strings.NewReader(`{
  "season": 11,
  "defenseTeam": [
    {
      "studentId": "hoshino"
    },
    {
      "studentId": "iori"
    },
    {},
    {},
    {
      "studentId": "himari"
    },
    {}
  ],
  "excludedStudentIds": [],
  "matchMode": "primary"
}`)

	req, err := http.NewRequest("POST", "https://ba.joexyz.online/api/v1/pvp/stats/search?limit=20&cursor=", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
```
