Skip to main content
Use query getBattles to retrieve the list of all battles related to the user. In a response it returns a list of Battle objects that fit the applied filters. Results will be returned with the pagination and possibility to change the order and sorting key (default sorting is by the battle creation date, ascending). The following arguments can be used in the query:
ArgumentTypeDescriptionDefault
afterCursorReturns results that come after the specified cursor. Should be used together with first parameter. Cannot be used if before is set.
beforeCursorReturns results that come before the specified cursor. Should be used together with last parameter. Cannot be used if after is set.
firstIntReturns up to the first N elements from the list. Required if after parameter is set. Cannot be used together with last.
lastIntReturns up to the first N elements from the list. Required if before parameter is set. Cannot be used together with first.
reverseBooleanAllows to reverse the order of the underlying list (default order is ascending).false
sortKeyBattleSortKeyAllows to change the results sorting. Available options: CREATED (default), FINISHEDCREATED
statusBattleStatusProvides the possibility to filter by the battle status. Leave empty to get all available battles.
userContextIdIDThe user context ID to get the list of battles for. If omitted, the results will be retrieved for the current API user context.
Only user contexts associated with the ADMINISTRATOR scope can access the list of other users’ battles.
Here is an example of the query execution:
query getBattles {
  getBattles(first: 10, status: "WON") {
    edges {
      node {
        domain {
          name
        }
        initiatorAttempt {
          score
          timeSpent
        }
        opponentAttempt {
          score
          timeSpent
        }
      }
    }
    totalItems
  }
}

Pagination

Learn how to efficiently navigate through large sets of items using cursor-based pagination.