Skip to main content
Unlike the initiator’s attempt, which is created automatically when the battle is initiated, the opponent’s attempt should be created by executing the createBattleAttempt mutation. The mutation has one required argument - battleId. Here is an example of the mutation execution:
mutation createBattleAttempt {
  createBattleAttempt(battleId: 1) {
    errors
    response {
      id
      cta {
        actionId
        title
        arguments {
          key
          value
        }
      }
    }
  }
}
After the mutation is successfully executed, a BattleAttempt object will be returned.

BattleAttempt object

The object represents a battle attempt data. Each opponent can have only one attempt, a battle cannot be restarted.
ArgumentTypeDescription
answersBattleQuestionAnswerOptional. The list of user’s answers for the battle questions. Answers will be returned only for the attempt created by the current API user; it’s impossible to check the other user’s answers.
battleStatusBattleStatusRequired. The battle attempt status. See the full list of available statuses below.
completedOnIntOptional. A timestamp when the attempt has been completed.
correctAnswersNumberIntRequired. The general number of correct answers provided by the user in the current battle attempt.
ctaCtaOptional. The list of available CTA for the battle attempt. See the list of available CTAs below.
idIDRequired. The battle attempt ID.
progressIntRequired. The attempt progress. Indicates the percentage of questions that have been answered so far.
scoreFloatRequired. The total number of points that the rival has earned earned for the battle.
timeSpentIntRequired. The time (in seconds) that the user spent answering the related battle questions.

BattleStatus options

The list of available BattleStatus options:
  1. COMPLETED - indicates that the battle has been completed by the current API user; also includes the battles that are not completed by the opponent yet.
  2. DRAW - indicates a tie, meaning that both opponents have earned the same score and spent the same amount of time;
  3. FINISHED - indicates that ths battle has been finished by both rivals.
  4. IN_PROGRESS - indicates that the battle have been started, but not completed by the user yet;
  5. PENDING - indicates that the battle has not been started by the user yet;
  6. LOST - indicates that the user has lost the battle;
  7. WAITING_OPPONENT - indicates that the battle is finished by the initiator, but not completed by the opponent yet.
  8. WON - indicates that the user has won the battle.

Battle attempt CTAs

The list of available CTAs can differ depending on the attempt status.
Action IDDescriptionCorresponding mutation/query
NEXT_BATTLE_QUESTIONAllows to get the next battle question. Available if the attempt is still in progress.getBattleNextQuestion
VIEW_BATTLE_RESULTSAllows to view the battle results. Available when the battle attempt is completed.getBattle