> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get battle statistics

The number of battles with the needed status can be retrieved by calling [`getBattles`](/OpignoEnterpriseAPI/Battle/GetBattles) query.
However, if you need to get the aggregated battles statistics for a specific user context,
`getUserBattlesStatistics` query can be executed. The returned data includes the key-value pairs
that represent the number of battles by status for the given user context.

The query has one **optional** argument `userContextUuid`. If it is omitted, the battles will be retrieved for the current API user context.

<Note>
  Only users associated with the `ADMINISTRATOR` scope can view the other user's battle statistics.
</Note>

Query execution example:

<CodeGroup>
  ```filename GraphQL Battle statistics query theme={null}
  query getUserBattlesStatistics {
    getUserBattlesStatistics {
      key
      value
    }
  }
  ```

  ```File Battle statistics query result [expandable] theme={null}
  {
    "data": {
      "getUserBattlesStatistics": {
        [
          {
            "key": "TOTAL_BATTLES_NUMBER",
            "value": 5
          },
          {
            "key": "PENDING_BATTLES_NUMBER",
            "value": 1
          },
          {
            "key": "WON_BATTLES_NUMBER",
            "value": 2
          },
          {
            "key": "LOST_BATTLES_NUMBER",
            "value": 1
          },
          {
            "key": "DRAW_BATTLES_NUMBER",
            "value": 1
          },
        ]
      }
    }
  }
  ```
</CodeGroup>

The list of the returned keys is always the same:

1. `TOTAL_BATTLES_NUMBER` - represents the battles taken by the current user; also includes the pending battles.
2. `PENDING_BATTLES_NUMBER` - represents the battles where the user has been selected as an opponent but did not start them yet.
3. `WON_BATTLES_NUMBER` - represents the battles that the user has won.
4. `LOST_BATTLES_NUMBER` - represents the battles that the user has lost.
5. `DRAW_BATTLES_NUMBER` - represents the battles finished as a tie (both rivals earned the same number of points and spent the same amount of time).
