Top X operations

Top X operations are responsible for communicating with the Prediction API in the context of a Top X game.
Games (a.k.a. Top X editions) are created by the staff members using their tokens in the Management Portal.
The following methods provide the functionality for end-users' interactions with the game.

Each method that works with statistical data also converts your IDs to the desired ID provider for easier and quicker development.

The general design of the namespace follows this pattern:

val response = sdk.topX().someMethod(...)
// do something with response object

Game related operations

The following methods are relating to the game instance.

Play the game

Method: play({})

Submits the user's predictions for a specific game.

Options object:

  • gameInstanceId: string. The game instance ID
  • fixtures: array of objects. Contains a list of fixtures and predictions for each of the games in the game instance. Each object should contain:
    • matchId: string. The ID of the match. It should exist in the game instance.
    • prediction: Object. The prediction for this match
      • value: String. Goals to be scored by each team separated by ":". Example: "2:3"
  • tiebreaker: Object. Optional. The first minute the user thinks a goal will be scored across all matches.
    • goldenGoal: Number. The number of the first goal prediction across all matches
val prediction = sdk.topX().play(List<PredictionFixture>, gameInstanceId, Tiebreaker)

Delete game participation

Method: delete(predictionId)

Deletes the user's participation (all game predictions) in a specific game.

val prediction = sdk.topX().delete('GSGUDDW5xVNSo7I0ujVbsNBoeMz2_g_ZLk')

Get games

Method: getGames(filters?, disableCache?)

Returns a list of Top X game instances, paginated.
If no value is passed to disableCache (undefined) it will be set to false.

Filters object:

  • limit: Int?. 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: GameStatus?
  • gameIds: List?
  • sortOrder: string. Options are: desc and asc. Games will be returned sorted by predictions cutoff. So for example when asc value is provided the games will be sorted by earliest predictions cutoff time. By default is desc (latest predictions cutoff time).
val response = sdk.topX().getGames(...)
val games = response.data

Get game by ID

Method: getGameById(gameId, disableCache?)

Returns a particular Match Quiz game instance.
If no value is passed to disableCache (undefined) it will be set to false.

val game = sdk.topX().getGameById('game-instance-id')

Get game predictions

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

Returns predictions for particular Top X game.
If no value is passed to disableCache (undefined) it will be set to false.

Filters object:

  • limit: number. The number of predictions to be returned.
  • startAfter: string. The ID after which the predictions should be listed. To be used in the context of infinite scroll/pagination.
val response = sdk.topX.getGamePredictions('game-instance-id', limit, startAfter)
val gamePredictions = response.data

Get game results

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

Returns the leaderboard for a specific game. Has pagination.
If no value is passed to disableCache (undefined) it will be set to false.

Filters object:

  • limit: Int?. The number of games to be returned.
  • startAfter: String?. The ID after which the results should be listed. To be used in the context of infinite scroll/pagination.
  • status: GameStatus?. Options include: "OPEN", "LIVE", "PENDING", "CANCELED", "CLOSED", "SETTLED"
val response = sdk.topX().getGameResults('game-instance-id')
val gameResults = response.data

Get current game results

Method: getCurrentGameResults(limit, startAfter, disableCache?)

Alias of getGameResults but returns the active game results. Has pagination.
If no value is passed to disableCache (undefined) it will be set to false.

val gameResult = sdk.topX().getCurrentGameResults(...)

User related operations

The following methods are relating to the user and their interaction with the game instances.

Get user's own game participations

Method: getMyGameEditions(filters, disableCache?)

Returns a list of Top X editions I have participated in.
If no value is passed to disableCache (undefined) it will be set to false.

Filters object:

  • limit: Int?. 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: GameStatus?. Options include: "OPEN", "LIVE", "PENDING", "CANCELED", "CLOSED", "SETTLED"
  • gameIds: List. An array of Game IDs
val response = sdk.topX().getMyGameEditions()
val gameEditions = response.data

Get user's own predictions for a game

Method: getMyGamePrediction(gameId)

Returns my own predictions for a specific Top X instance.

val predictions = sdk.topX().getMyGamePrediction('game-instance-id')

Get user's game prediction

Method: getUserGamePrediction(userId, gameId, disableCache?)

Returns user’s predictions for a specific Top X instance.
If no value is passed to disableCache (undefined) it will be set to false.

sdk.topX().getUserGamePrediction('user-id', 'game-instance-id')

Get user's game participations

Method: getUserGameEditions(userId, disableCache?)

Returns the edition the user has participated in.
If no value is passed to disableCache (undefined) it will be set to false.

val response = sdk.topX().getUserGameEditions('user-id')
val gameEditions = response.data