What are Leaderboards? How to setup a leaderboard?

Refer our core leaderboards documentation.

Getting leaderboards associated with a program

You have the option to retrieve all leaderboards associated to a program by using the code samples below. This function will return an array of leaderboards.

API Definition: getLeaderboards

import { getLeaderboards } from "@livelike/javascript"

  programId: "<program id>"
}).then(leaderboards => console.log(leaderboards));

Getting leaderboard details

If you know a leaderboard id, you are able to get its details by using the code samples below. This can be useful if you would like to know the name of the leaderboard or the type of reward a user can earn.

API Definition: getLeaderboard

import { getLeaderboard } from "@livelike/javascript"

getLeaderboard({leaderboardId: "<leaderboard id>"})
	.then(leaderboard => console.log(leaderboard));

Getting leaderboard entries

A user that competes is considered a leaderboard entry. Use the code samples below to retrieve leaderboard entries for a specific leaderboard. Due to the nature of leaderboard entries growing to a very high number, this call is paginated with each page returning 20 leaderboard entries.

API Definition: getLeaderboardEntries

import { getLeaderboardEntries } from "@livelike/javascript"

  leaderboardId: "<leaderboard id>",
  profileIds: ["<profileId1>","<profileId2>"]
}).then(leaderboardEntries => console.log(leaderboardEntries));

Getting leaderboard entry for a given profile

Details about a leaderboard entry can be retrieved by providing a profile id and a leaderboard id. This can be useful if there is a leaderboard entry you are interested in keeping track of.

API Definition: getLeaderboardProfileRank

import { getLeaderboardProfileRank } from "@livelike/javascript"

  leaderboardId: "<leaderboard id>",
  profileId: "<profile id>"
}).then(profileRank => console.log(profileRank));

Getting a leaderboard entry for the current user profile

Retrieving details about the current user's profile can be done using the code samples below. This can be used to look up the current user's ranking in a specific leaderboard.

API Definition: getLeaderboardProfileRank

import { getLeaderboardProfileRank, userProfile } from "@livelike/javascript"

  leaderboardId: "<leaderboard id>",
  profileId: userProfile.id
}).then(profileRank => console.log(profileRank));

Get Leaderboards a given profile is ranked on

Integrators can fetch the leaderboards a given profile is ranked on.

API Definition: getProfileLeaderboards

import { getProfileLeaderboards } from "@livelike/javascript"

// leaderboard list for current profile
.then(leaderboards => console.log(leaderboards))
// leaderboard list for a given profileId
  profileId: "<profile-id>"
}).then(leaderboards => console.log(leaderboards))

Get Leaderboard views for a given profile

Integrators can fetch the leaderboard views for a given profile.

API Definition: getProfileLeaderboardViews

import { getProfileLeaderboardViews } from "@livelike/javascript"

// leaderboard views for current profile
.then(leaderboardviews => console.log(leaderboardviews))
// leaderboard views for a given profileId
  profileId: "<profile-id>"
}).then(leaderboardviews => console.log(leaderboardviews))