Event Game operations

Overview of custom event game feature

Event Game operations are responsible for communicating with Prediction API and specially with custom event game functionalities.

The namespace is of course called eventGame. All methods return promises. The general design of the namespace follows this pattern unless stated otherwise:

πŸ“˜

General call:

sdk.eventGame
  .someMethod()
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

The responses are comprised of different objects you can find here.

Game related operations

Get event games

Method: getGames(filters?, disableCache?)

Model:

The method returns list of event games.

No authentication required.

Filters object:

  • limit: number. The number of games to be returned.
  • startAfter: string. The ID after which the games should be listed. To be used in the context of infinite scroll/pagination.
  • status: string. Options include: "OPEN", "LIVE", "PENDING", "CANCELED", "CLOSED", "SETTLED"
  • sortOrder: string. Options are: desc and asc. Games will be returned sorted by created at.
  • gameIds: string[]. The IDs of event games.

The response from API is cached for 10 minutes. With disableCache argument you can avoid cached response.

πŸ“˜

Example call:

const filters = {
  status: GameStatusEnum.PENDING,
  sortOrder: "asc",
  limit: 10,
  startAfter: "gameId"
}
  
sdk.eventGame
  .getGames(filters)
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
  meta: {
    pagination: {
      itemsPerPage: 10,
      nextPageStartsAfter: null
    }
  },
  data: [
		{
      id: "event_match_123",
      title: "Manchester United vs Liverpool",
      description: "Predict the outcome of this Premier League clash",
      rules: "<p><h2>Rules of the game</h2><p>The rules of the game are...</p></p>",
      type: "EVENT",
      status: "OPEN",
      predictionCutoff: "2025-01-20T15:00:00Z",
      customFields: {
        competition: "Premier League",
        season: "2024/25",
        matchday: "23",
      },
      images: {
        main: null,
        cover: null,
        mobile: null,
      },
      related: [
        {
          entityId: "1",
          entityType: "classic_quiz",
          entityRelationship: "bonusPointsGame",
        },
      ],
      fixtures: [
        {
          id: "1",
          question: "Will Manchester United win?",
          status: "ACTIVE",
          voidReason: null,
          points: 2,
          validOutcomes: null,
          outcomeType: "BOOLEAN",
          outcome: null,
        },
      ],
      createdAt: "2024-01-15T10:00:00Z",
      updatedAt: "2025-01-20T17:15:00Z",
		}
   ]
}

Get event game by ID

Method: getGameById(gameId, disableCache?)

Model:

The method returns the Event Game information.

No authentication required.

The response from API is cached for 10 minutes. With disableCache argument you can avoid cached response.

πŸ“˜

Example call:

sdk.eventGame
  .getGameById("gameId")
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
      id: "event_match_123",
      title: "Manchester United vs Liverpool",
      description: "Predict the outcome of this Premier League clash",
      rules: "<p><h2>Rules of the game</h2><p>The rules of the game are...</p></p>",
      type: "EVENT",
      status: "OPEN",
      predictionCutoff: "2025-01-20T15:00:00Z",
      customFields: {
        competition: "Premier League",
        season: "2024/25",
        matchday: "23",
      },
      images: {
        main: null,
        cover: null,
        mobile: null,
      },
      related: [
        {
          entityId: "1",
          entityType: "classic_quiz",
          entityRelationship: "bonusPointsGame",
        },
      ],
      fixtures: [
        {
          id: "1",
          question: "Will Manchester United win?",
          status: "ACTIVE",
          voidReason: null,
          points: 2,
          validOutcomes: null,
          outcomeType: "BOOLEAN",
          outcome: null,
        },
      ],
      createdAt: "2024-01-15T10:00:00Z",
      updatedAt: "2025-01-20T17:15:00Z"
}

Get rankings for a event game

Method: getRankings(gameId, filters?, disableCache?)

Models:

The method returns leaderboard for specific game.

No authentication required.

The response from API is cached for 10 minutes. With disableCache argument you can avoid cached response.

πŸ“˜

Example call:

const filters = { limit: 10, startAfter: "id" };

sdk.eventGame
  .getRankings("gameId", filters)
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
  meta: {
    pagination: {
      itemsPerPage: 1,
      nextPageStartsAfter: null
    }
  },
  data: [
    {
      id: "profileId_g_gameId",
 			profileId: "profileId",
      profileModel: ProfileModel,
  		totalPoints: 100,
  		gamePoints: 80,
  		bonusPoints: 20,
      position: 1,
      status: "ACTIVE",
      gameId: "gameId",
      fixtures: [
          {
              id: "1",
              predictionType: "BOOLEAN",
              prediction: true,
              correct: null,
              points: 0,
          },
          {
            id: "2",
            predictionType: "NUMBER",
            prediction: 450,
            correct: null,
            points: 0,
          },
          {
            id: "3",
            predictionType: "ENUM",
            prediction: "Virat Kohli",
            correct: null,
            points: 0,
          },
          {
            id: "4",
            predictionType: "FREE_INPUT",
            prediction: "India 320, Australia 280",
            correct: null,
            points: 0,
          },
      ],
      tiebreaker: {
        statTotal: 1000,
      },
      createdAt: "2025-01-08T15:02:15Z",
      updatedAt: "2025-01-08T15:02:15Z"
    }
  ]
}

User related operations

Make prediction for a Event Game

Method: makePrediction(gameId, prediction)

Models:

The method creates user prediction for the game.

Authentication required.

πŸ“˜

Example call:

 const prediction = {
  fixtures: [
    {
      id: "1",
      predictionType: EventGameOutcomeTypeEnum.BOOLEAN,
      prediction: true,
    },
    {
      id: "2",
      predictionType: EventGameOutcomeTypeEnum.NUMBER,
      prediction: 450,
    },
    {
      id: "3",
      predictionType: EventGameOutcomeTypeEnum.ENUM,
      prediction: "Virat Kohli",
    },
    {
      id: "4",
      predictionType: EventGameOutcomeTypeEnum.FREE_INPUT,
      prediction: "India 320, Australia 280",
    },
  ],
  tiebreaker: {
    statTotal: 1000,
  },
 };
sdk.eventGame
  .makePrediction("gameId", prediction)
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
  id: "profileId_g_gameId",
  profileId: "profileId",
  profileModel: null,
  totalPoints: null,
  gamePoints: null,
  bonusPoints: null,
  position: null,
  status: "ACTIVE",
  gameId: "gameId",
  fixtures: [
      {
          id: "1",
          predictionType: "BOOLEAN",
          prediction: true,
          correct: null,
          points: 0,
      },
      {
        id: "2",
        predictionType: "NUMBER",
        prediction: 450,
        correct: null,
        points: 0,
      },
      {
        id: "3",
        predictionType: "ENUM",
        prediction: "Virat Kohli",
        correct: null,
        points: 0,
      },
      {
        id: "4",
        predictionType: "FREE_INPUT",
        prediction: "India 320, Australia 280",
        correct: null,
        points: 0,
      },
    ],
  tiebreaker: {
    statTotal: 1000,
  },
  createdAt: "2025-01-08T15:02:15Z",
  updatedAt: "2025-01-08T15:02:15Z"
}

Update prediction for a Event Game

Method: updatePrediction(gameId, predictionId, prediction)

Models:

The method updates user prediction for the game.

Authentication required.

πŸ“˜

Example call:

const prediction = ["1", "3", "4", "2"];
sdk.eventGame
  .updatePrediction("gameId", "profileId_g_gameId", prediction)
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
  id: "profileId_g_gameId",
  profileId: "profileId",
  profileModel: null,
  totalPoints: null,
  gamePoints: null,
  bonusPoints: null,
  position: null,
  status: "ACTIVE",
  gameId: "gameId",
  fixtures: [
      {
        id: "1",
        predictionType: "BOOLEAN",
        prediction: true,
        correct: null,
        points: 0,
      },
      {
        id: "2",
        predictionType: "NUMBER",
        prediction: 450,
        correct: null,
        points: 0,
      },
      {
        id: "3",
        predictionType: "ENUM",
        prediction: "Virat Kohli",
        correct: null,
        points: 0,
      },
      {
        id: "4",
        predictionType: "FREE_INPUT",
        prediction: "India 320, Australia 280",
        correct: null,
        points: 0,
      },
    ],
  tiebreaker: {
    statTotal: 1000,
  },
  createdAt: "2025-01-08T15:02:15Z",
  updatedAt: "2025-01-08T15:02:15Z"
}

Get event game predictions for user

Method: getGamePredictionsForUser(gameId, profileId, disableCache?)

Models:

The method returns all predictions for specific game for specific user.

No authentication required.

πŸ“˜

Example call:

sdk.eventGame
  .getGamePredictionsForUser("gameId", "profileId")
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
  meta: {
    pagination: {
      itemsPerPage: 1,
      nextPageStartsAfter: "profileId_g_gameId"
    }
  },
  data: [
    {
      id: "profileId_g_gameId",
      profileId: "profileId",
      totalPoints: null,
      gamePoints: null,
      bonusPoints: null,
      position: null,
      status: "ACTIVE",
      gameId: "gameId",
      fixtures: [
        {
          id: "1",
          predictionType: "BOOLEAN",
          prediction: true,
          correct: null,
          points: 0,
        },
        {
          id: "2",
          predictionType: "NUMBER",
          prediction: 450,
          correct: null,
          points: 0,
        },
        {
          id: "3",
          predictionType: "ENUM",
          prediction: "Virat Kohli",
          correct: null,
          points: 0,
        },
        {
          id: "4",
          predictionType: "FREE_INPUT",
          prediction: "India 320, Australia 280",
          correct: null,
          points: 0,
        },
    	],
      tiebreaker: {
        statTotal: 1000,
      },
      createdAt: "2025-01-08T15:02:15Z",
      updatedAt: "2025-01-08T15:02:15Z"
    }
  ]
}