Loyalty operations

Get the configuration for all platform interactions

Loyalty operations are responsible for communicating with multiple APIs.

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

📘

General call:

sdk.loyalty.someMethod(filtersObject).then((responseObject) => {
    // do something with responseObject
});

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

General operations

Get config

Method: getConfig()

This method returns all points configuration for all platform interactions.

📘

Example call:

sdk.loyalty.getConfig(filtersObject).then((responseObject) => {
    // do something with responseObject
});

Example result

{
   enabled: true,
   conditions: {
      list: [
         "FULL_PROFILE",
         "FAVOURITE_TEAM"
      ]
   },
   actions: {
      value: [
         {
            id: "LIKE",
            weight: 1,
            multiplier: 1,
            conditions: []
         },
         {
            id: "DISLIKE",
            weight: 1,
            multiplier: 1,
            conditions: []
         },
         {
            id: "CLICK_AD",
            weight: 7,
            multiplier: 1,
            conditions: []
         },
         {
            id: "COMMENT",
            weight: 5,
            multiplier: 1,
            conditions: []
         },
         {
            id: "CONTENT_CONSUMED",
            weight: 2,
            multiplier: 1,
            conditions: []
         },
         {
            id: "CONVERT",
            weight: 10,
            multiplier: 1,
            conditions: []
         },
         {
            id: "PAGE_VIEW",
            weight: 1,
            multiplier: 1,
            conditions: []
         },
         {
            id: "SHARE",
            weight: 4,
            multiplier: 1,
            conditions: []
         },
         {
            id: "PROFILE_UPDATE",
            weight: 1,
            multiplier: 1,
            conditions: []
         },
         {
            id: "MANAGE_INTERESTS",
            weight: 2,
            multiplier: 1,
            conditions: []
         },
         {
            id: "PREDICTION_MADE",
            weight: 2,
            multiplier: 1,
            conditions: []
         },
         {
            id: "GAME_PARTICIPATION",
            weight: 5,
            multiplier: 1,
            conditions: []
         }
      ]
   },
   rewards: {
      points: {
         general: [
            {
               id: "registration",
               points: 0
            },
            {
               id: "add_interest",
               points: 0
            },
            {
               id: "add_birthdate",
               points: 0
            },
            {
               id: "add_country",
               points: 0
            },
            {
               id: "add_gender",
               points: 0
            },
            {
               id: "add_avatar",
               points: 0
            }
         ],
         comments: [],
         predictor: [
            {
               id: "FT_1X2",
               points: 10,
               multiplier: 1,
               conditions: []
            },
            {
               id: "HT_1X2",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "HT_FT",
               points: 36,
               multiplier: 1,
               conditions: []
            },
            {
               id: "CORRECT_SCORE",
               points: 50,
               multiplier: 1,
               conditions: []
            },
            {
               id: "DOUBLE_CHANCE",
               points: 3,
               multiplier: 1,
               conditions: []
            },
            {
               id: "BOTH_TEAMS_SCORE",
               points: 6,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE",
               points: 9,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_TWICE",
               points: 23,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_HATTRICK",
               points: 45,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_FIRST_GOAL",
               points: 17,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_YELLOW_CARD",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_RED_CARD",
               points: 40,
               multiplier: 1,
               conditions: []
            },
            {
               id: "RED_CARD_MATCH",
               points: 25,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PENALTY_MATCH",
               points: 17,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_0_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_1_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_2_5",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_3_5",
               points: 7,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_4_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_5_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_6_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_6_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_7_5",
               points: 13,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_8_5",
               points: 15,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_9_5",
               points: 13,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_10_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_11_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_12_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_13_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "CORNERS_MATCH",
               points: 37,
               multiplier: 1,
               conditions: []
            }
         ],
         activity: [
            {
               id: "LIKE",
               points: 0,
               multiplier: 1,
               conditions: []
            },
            {
               id: "DISLIKE",
               points: 0,
               multiplier: 1,
               conditions: []
            },
            {
               id: "COMMENT",
               points: 0,
               multiplier: 1,
               conditions: []
            },
            {
               id: "SHARE",
               points: 0,
               multiplier: 1,
               conditions: []
            }
         ],
         topX: [
            {
               id: "FT_1X2",
               points: 10,
               multiplier: 1,
               conditions: []
            },
            {
               id: "CORRECT_SCORE",
               points: 50,
               multiplier: 1,
               conditions: []
            }
         ],
         matchQuiz: [
            {
               id: "FT_1X2",
               points: 10,
               multiplier: 1,
               conditions: []
            },
            {
               id: "HT_1X2",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "HT_FT",
               points: 36,
               multiplier: 1,
               conditions: []
            },
            {
               id: "CORRECT_SCORE",
               points: 50,
               multiplier: 1,
               conditions: []
            },
            {
               id: "DOUBLE_CHANCE",
               points: 3,
               multiplier: 1,
               conditions: []
            },
            {
               id: "BOTH_TEAMS_SCORE",
               points: 6,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE",
               points: 9,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_TWICE",
               points: 23,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_HATTRICK",
               points: 45,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_SCORE_FIRST_GOAL",
               points: 17,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_YELLOW_CARD",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PLAYER_RED_CARD",
               points: 40,
               multiplier: 1,
               conditions: []
            },
            {
               id: "RED_CARD_MATCH",
               points: 25,
               multiplier: 1,
               conditions: []
            },
            {
               id: "PENALTY_MATCH",
               points: 17,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_0_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_1_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_2_5",
               points: 8,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_3_5",
               points: 7,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_4_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_5_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_GOALS_6_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_6_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_7_5",
               points: 13,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_8_5",
               points: 15,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_9_5",
               points: 13,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_10_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_11_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_12_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "OVER_CORNERS_13_5",
               points: 1,
               multiplier: 1,
               conditions: []
            },
            {
               id: "CORNERS_MATCH",
               points: 37,
               multiplier: 1,
               conditions: []
            }
         ]
      },
      tiers: [
         {
            enabled: true,
            id: "diamond",
            points: 75000
         },
         {
            enabled: true,
            id: "platinum",
            points: 25000
         },
         {
            enabled: true,
            id: "gold",
            points: 10000
         },
         {
            enabled: true,
            id: "silver",
            points: 1500
         },
         {
            enabled: true,
            id: "bronze",
            points: 0
         }
      ],
      badges: {
         general: [],
         predictor: [
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: null,
                  predictionsMade: null,
                  correctPredictions: 10
               },
               id: "predictor_newbie",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: null,
                  predictionsMade: null,
                  correctPredictions: 100
               },
               id: "predictor_top",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: null,
                  predictionsMade: null,
                  correctPredictions: 1000
               },
               id: "predictor_scorer",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: null,
                  predictionsMade: null,
                  correctPredictions: 5000
               },
               id: "predictor_guru",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: null,
                  predictionsMade: null,
                  correctPredictions: 10000
               },
               id: "predictor_legend",
               enabled: true
            }
         ],
         topX: [
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 1,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "topx_newbie",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 10,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "topx_regular",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 50,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "topx_captain",
               enabled: true
            }
         ],
         matchQuiz: [
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 1,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "matchquiz_newbie",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 10,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "matchquiz_regular",
               enabled: true
            },
            {
               requirements: {
                  points: null,
                  entityId: null,
                  entityType: null,
                  gameParticipationCount: 50,
                  predictionsMade: null,
                  correctPredictions: null
               },
               id: "matchquiz_captain",
               enabled: true
            }
         ]
      }
   }
}

Get available badges

Method: getClientBadges()

Methods returns all available badges for client.

📘

Example call:

sdk.loyalty.getClientBadges().then((responseObject) => {
    // do something with responseObject
});

Example result

{
   general: [],
   predictor: [
      "predictor_newbie",
      "predictor_top",
      "predictor_guru"
   ],
   topX: [
      "topx_regular"
   ],
   matchQuiz: [
      "matchquiz_regular"
   ]
}

Templates and leaderboards operations

Get all templates

Method: getTemplates(disableCache?)

Methods retuns list of all created templates for specific client.

The response from API is cached for 1 hour. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

sdk.loyalty.getTemplates(true).then((responseObject) => {
   // Handle response
});

Example result

{
   meta: {
      totalItems: 3
   },
   data: [
      {
        id: "competition:premier-league",
        name: "Premier League (England)'s Leaderboard",
        description: "Some description",
        type: "PRIMARY",
        fromDate: "2022-07-01",
        toDate: "2023-06-30",
        markets: null,
        teamIds: null,
        matchIds: null,
        gameIds: null,
        gameTypes: null,
        competitionIds: [
           "3"
        ],
        rules: "Rules for participating in template.",
        flags: ["This", "is", "string", "array"],
        images: {
          main: "some-photo-url",
          cover: "some-photo-url",
          mobile: "some-photo-url"
        },
        excludedProfileIds: null,
        related: [
          {
            entityId: "team:leicester-city",
            entityType: "TEMPLATE"
          }
        ],
        createdAt: "2023-03-01T10:10:50Z",
        updatedAt: "2023-03-01T10:10:50Z"
      },
      {
        id: "market:ft-1x2",
        name: "Championship (England)'s Leaderboard",
        description: "Some description",
        type: "PRIMARY",
        fromDate: "2022-07-01",
        toDate: "2023-06-30",
        markets: [
           "FT_1X2"
        ],
        teamIds: null,
        matchIds: null,
        gameIds: null,
        gameTypes: null,
        competitionIds: null,
        rules: "Rules for participating in template.",
        flags: ["This", "is", "string", "array"],
        images: {
          main: "some-photo-url",
          cover: "some-photo-url",
          mobile: "some-photo-url"
        },
        excludedProfileIds: ["some-profile-id"],
        related: null,
        createdAt: "2023-03-01T10:10:50Z",
        updatedAt: "2023-03-01T10:10:50Z"
      },
      {
        id: "team:leicester-city",
        name: "Leicester City's Leaderboard",
        type: "PRIMARY",
        fromDate: "2022-07-01",
        toDate: "2023-06-30",
        markets: null,
        teamIds: [
           "81"
        ],
        matchIds: null,
        gameIds: null,
        gameTypes: null,
        competitionIds: null,
        rules: 'Rules for participating in template.',
        flags: ['This', 'is', 'string', 'array'],
        images: {
          main: "some-photo-url",
          cover: "some-photo-url",
          mobile: "some-photo-url"
        },
        excludedProfileIds: ["profile-id-1", "profile-id-2"],
        related: [
          {
            entityId: "competition:premier-league",
            entityType: "TEMPLATE"
          }
        ],
        createdAt: "2023-03-01T10:10:50Z",
        updatedAt: "2023-03-01T10:10:50Z"
      }
   ]
}

Get single template

Method: getTemplateById(templateId, disableCache?)

Methods returns specified template.

The response from API is cached for 10 minutes. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

sdk.loyalty.getTemplateById("competition:premier-league", true)
.then((responseObject) => {
   // Handle response
})
.catch((error) => {
  // Throws error message 
)};

Example result

{
  id: "competition:premier-league",
  name: "Premier League (England)'s Leaderboard",
  description: "Best league in the world",
  type: "PRIMARY",
  fromDate: "2022-07-01",
  toDate: "2023-06-30",
  markets: null,
  teamIds: null,
  matchIds: null,
  gameIds: null,
  gameTypes: null,
  competitionIds: [
    "3"
  ],
  rules: 'Rules for participating in template.',
  flags: ['This', 'is', 'string', 'array'],
  excludedProfileIds: ["profile-id-1", "profile-id-2"],
  related: [
    {
      entityId: "team:leicester-city",
      entityType: "TEMPLATE"
    }
  ],
  createdAt: "2023-03-01T10:10:50Z",
  updatedAt: "2023-03-01T10:10:50Z"
}

Get template winners

Method: getTemplateWinners(templateId)

Method returns winners for the specific template.

📘

Example call:

sdk.loyalty.getTemplateWinners("templateId").then((responseObject) => {
   // Returns winners for the specific template
});

Example response:

{
   contestId: "2neVcxhVwZw3eCy7Xt5LiV",
   contestType: "TEMPLATE",
   contestModel: TemplateModel,
   description: "description",
   userList: [
      {
         position: "big winner",
         profileId: "profileId",
         profileModel: ProfileModel,
         note: "The winner",
         tags: [
            "big_prizezzzzz",
            "champion"
         ]
      }
   ]
}

Get leaderboard for a template

Method: getLeaderboard(templateId, filters?, disableCache?)

Returns a leaderboard for specific template. Supports pagination.

Available options for filters:

  • limit:number. How many leaderboards will be returned in list.
  • page: number. The number of the page.

The response from API is cached for 1 hour. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

const filters = {
   limit: 2,
   page: 2
}
sdk.loyalty.getLeaderboard("competition:premier-league", filters).then((responseObject) => {
   // Handle response
});

Example response:

{
   meta: {
      rankType: "PRIMARY",
      fromDate: "2022-07-01",
      toDate: "2023-06-30",
      pagination: {
         currentPage: 2,
         itemsPerPage: 2,
         totalItems: 10,
         numberOfPages: 5
      }
   },
   data: [
      {
         position: 1,
         profileId: "GSGUDDW5xVNSo7I0ujVbsNBoeMz2",
         profileModel: ProfileModel,
         points: 30,
         predictionsMade: 3
      },
      {
         position: 2,
         profileId: "Y44CxUzkpHdypYxcVVlwIQiLNtD2",
         profileModel: ProfileModel,
         points: 20,
         predictionsMade: 2
      }
   ]
}

Get leaderboard for a game

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

Returns a leaderboard for specific game. Supports pagination.

Available options for filters:

  • limit:number. How many leaderboards will be returned in list.
  • page: number. The number of the page.

The response from API is cached for 1 hour. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

const filters = {
   limit: 2,
   page: 2
}
sdk.loyalty.getLeaderboardForGame("3xtM4jU7jaXe82KnxrTKaJ", filters).then((responseObject) => {
   // Handle response
});

Example result

{
   meta: {
      rankType: "GAME",
      fromDate: null,
      toDate: null,
      pagination: {
         currentPage: 2,
         itemsPerPage: 2,
         totalItems: 10,
         numberOfPages: 5
      }
   },
   data: [
      {
         position: 1,
         profileId: "GSGUDDW5xVNSo7I0ujVbsNBoeMz2",
         profileModel: ProfileModel,
         points: 30,
         predictionsMade: 3
      },
      {
         position: 2,
         profileId: "Y44CxUzkpHdypYxcVVlwIQiLNtD2",
         profileModel: ProfileModel,
         points: 20,
         predictionsMade: 2
      }
   ]
}

User rankings

Get user own rankings

Method: getOwnRankings(filters?, disableCache?)

Methods returns user's own rankings.

Filters options:

  • limit: number. How mani rankings will be returned from API. By default it will return 10 items per page.
  • page: number. Which page to be returned. By default is first page.
  • sortOder: SortOrder. Union type 'asc' | 'desc'. By default the order is desc (comes from descending).
  • type: RankingsType. Union type 'game' | 'template'. By default the response will contaion both types.
  • leaderboardIds: string[]. List of strings. The response will contain only provided game or template ids.

The response from API is cached for 1 hour. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

const filters = {
   limit: 2,
   page: 2,
   sortOrder: 'asc',
   type: 'game'
};

const disableCache = true;

sdk.loyalty.getOwnRankings(filters, disableCache).then((responseObject) => {
   // Handle response
});

Example result

{
    meta: {
        pagination: {
            currentPage: 2,
            itemsPerPage: 2,
            totalItems: 12,
            numberOfPages: 2
        }
    },
    data: [
        {
            id: "1Tvag5OuxUnOgqRr4MGWAQ",
            rankType: "GAME",
            position: 1,
            points: 60
        },
        {
            id: "2qzP5Ahc6uKiuNL2OU5or",
            rankType: "GAME",
            position: 2,
            points: 40
        }
    ]
}

Get user rankings

Method: getUserRankings(userId, filters?, disableCache?)

Methods returns user's rankings.

Filters options:

  • limit: number. How mani rankings will be returned from API. By default it will return 10 items per page.
  • page: number. Which page to be returned. By default is first page.
  • sortOder: SortOrder. Union type 'asc' | 'desc'. By default the order is desc (comes from descending).
  • type: RankingsType. Union type 'game' | 'template'. By default the response will contaion both types.
  • leaderboardIds: string[]. List of strings. The response will contain only provided game or template ids.

The response from API is cached for 1 hour. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

const filters = {
   limit: 2,
   page: 2,
   sortOrder: 'asc',
   type: 'game'
};

const disableCache = true;

sdk.loyalty.getOwnRankings("user-id", filters, disableCache).then((responseObject) => {
   // Handle response
});
{
    meta: {
        pagination: {
            currentPage: 2,
            itemsPerPage: 2,
            totalItems: 12,
            numberOfPages: 2
        }
    },
    data: [
        {
            id: "1Tvag5OuxUnOgqRr4MGWAQ",
            rankType: "GAME",
            position: 1,
            points: 60
        },
        {
            id: "2qzP5Ahc6uKiuNL2OU5or",
            rankType: "GAME",
            position: 2,
            points: 40
        }
    ]
}

Get highest success rate

Method: getHighestSuccessRate(market?, disableCache?)

Method returns first 100 users with highest success rate who have placed at least 100 predictions.

Optional argument market is type string and when provided, JS SDK will return first 100 users with highest success rate for provided market.

The response from API is cached for 8 hours. With disableCache argument you can avoid cached response.
If no value is provided it will be set to false by default.

📘

Example call:

sdk.loyalty.getHighestSuccessRate().then((responseObject) => {
   // Returns 100 users who have placed at least 100 predictions across all markets
});

sdk.loyalty.getHighestSuccessRate("CORRECT_SCORE").then((responseObject) => {
   // Returns 100 users who have placed at least 100 predictions for CORRECT_SCORE market
});
[
   {
      position: 1,
      points: 1412,
      predictionsMade: 325,
      profileId: "BRLWNsotfsRdmA0EHq0GzkjeRRD2",
      profileModel: ProfileModel,
      successRatePercent: 46
   },
   {
      position: 2,
      points: 1002,
      predictionsMade: 218,
      profileId: "GSGUDDW5xVNSo7I0ujVbsNBoeMz2",
      profileModel: ProfileModel,
      successRatePercent: 33
   }
]