GET
/
users
/
{userId}
/
leaderboards
/
{key}
JavaScript
import { TrophyApiClient } from '@trophyso/node';

const trophy = new TrophyApiClient({
  apiKey: 'YOUR_API_KEY'
});

const response = await trophy.users.leaderboards("user-123", "weekly-words", {
  run: "2025-01-15"
});
{
  "id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
  "name": "Weekly Word Count Challenge",
  "key": "weekly-words",
  "rankBy": "metric",
  "metricKey": "words-written",
  "metricName": "Words Written",
  "pointsSystemKey": null,
  "pointsSystemName": null,
  "description": "Compete weekly to see who writes the most words",
  "start": "2025-01-01",
  "end": null,
  "maxParticipants": 100,
  "runUnit": "day",
  "runInterval": 7,
  "rank": 2,
  "value": 4500,
  "history": [
    {
      "time": "2025-01-15T10:30:00Z",
      "previousRank": null,
      "rank": 5,
      "previousValue": null,
      "value": 1000
    },
    {
      "time": "2025-01-15T14:15:00Z",
      "previousRank": 5,
      "rank": 3,
      "previousValue": 1000,
      "value": 3000
    },
    {
      "time": "2025-01-15T18:45:00Z",
      "previousRank": 3,
      "rank": 2,
      "previousValue": 3000,
      "value": 4500
    }
  ]
}

Authorizations

X-API-KEY
string
header
required

Path Parameters

userId
string
required

The user's ID in your database.

key
string
required

Unique key of the leaderboard as set when created.

Query Parameters

run
string<date>

Specific run date in YYYY-MM-DD format. If not provided, returns the current run.

Response

Successful operation

A user's data for a specific leaderboard including rank, value, and history. A leaderboard with its configuration details.

id
string
required

The unique ID of the leaderboard.

Example:

"5100fe51-6bce-6j44-b0hs-bddc4e123682"

name
string
required

The user-facing name of the leaderboard.

Example:

"Weekly Word Count Challenge"

key
string
required

The unique key used to reference the leaderboard in APIs.

Example:

"weekly-words"

rankBy
enum<string>
required

What the leaderboard ranks by.

Available options:
points,
streak,
metric
Example:

"metric"

start
string<date>
required

The start date of the leaderboard in YYYY-MM-DD format.

Example:

"2025-01-01"

maxParticipants
integer
required

The maximum number of participants in the leaderboard.

Example:

100

runInterval
integer
required

The interval between repetitions, relative to the start date and repetition type.

Example:

7

rank
integer | null
required

The user's current rank in this leaderboard. Null if the user is not on the leaderboard.

Example:

2

value
integer | null
required

The user's current value in this leaderboard. Null if the user is not on the leaderboard.

Example:

4500

history
LeaderboardEvent · object[]
required

An array of events showing the user's rank and value changes over time.

status
enum<string>

The status of the leaderboard.

Available options:
active,
scheduled,
finished
Example:

"active"

metricKey
string | null

The key of the metric to rank by, if rankBy is 'metric'.

Example:

"words-written"

metricName
string | null

The name of the metric to rank by, if rankBy is 'metric'.

Example:

"Words Written"

pointsSystemKey
string | null

The key of the points system to rank by, if rankBy is 'points'.

Example:

"xp-system"

pointsSystemName
string | null

The name of the points system to rank by, if rankBy is 'points'.

Example:

"Experience Points"

description
string | null

The user-facing description of the leaderboard.

Example:

"Compete weekly to see who writes the most words"

end
string<date> | null

The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.

Example:

"2025-12-31"

runUnit
enum<string> | null

The repetition type for recurring leaderboards, or null for one-time leaderboards.

Available options:
day,
month,
year
Example:

"day"