GET
/
users
/
{id}
/
streak
JavaScript
import { TrophyApiClient } from '@trophyso/node';

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

const response = await trophy.users.streak("user-id", {
  historyPeriods: 14
});
{
  "length": 1,
  "frequency": "weekly",
  "started": "2025-04-02",
  "periodStart": "2025-03-31",
  "periodEnd": "2025-04-05",
  "expires": "2025-04-12",
  "rank": 5,
  "streakHistory": [
    {
      "periodStart": "2025-03-30",
      "periodEnd": "2025-04-05",
      "length": 1
    },
    {
      "periodStart": "2025-04-06",
      "periodEnd": "2025-04-12",
      "length": 2
    },
    {
      "periodStart": "2025-04-13",
      "periodEnd": "2025-04-19",
      "length": 3
    },
    {
      "periodStart": "2025-04-20",
      "periodEnd": "2025-04-26",
      "length": 0
    },
    {
      "periodStart": "2025-04-27",
      "periodEnd": "2025-05-03",
      "length": 1
    },
    {
      "periodStart": "2025-05-04",
      "periodEnd": "2025-05-10",
      "length": 2
    },
    {
      "periodStart": "2025-05-11",
      "periodEnd": "2025-05-17",
      "length": 3
    }
  ]
}

Authorizations

X-API-KEY
string
header
required

Path Parameters

id
string
required

ID of the user.

Query Parameters

historyPeriods
integer
default:7

The number of past streak periods to include in the streakHistory field of the response.

Response

Successful operation

An object representing the user's streak.

length
integer
required

The length of the user's current streak.

frequency
enum<string>
required

The frequency of the streak.

Available options:
daily,
weekly,
monthly,
yearly
started
string<date>

The date the streak started.

periodStart
string<date>

The start date of the current streak period.

periodEnd
string<date>

The end date of the current streak period.

expires
string<date>

The date the streak will expire if the user does not increment a metric.

streakHistory
object[]

A list of the user's past streak periods up through the current period. Each period includes the start and end dates and the length of the streak.

rank
integer

The user's rank across all users. Null if the user has no active streak.

Example:

5