Skip to main content
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> | null
required

The date the streak started.

periodStart
string<date> | null
required

The start date of the current streak period.

periodEnd
string<date> | null
required

The end date of the current streak period.

expires
string<date> | null
required

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

rank
integer | null
required

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

Example:

5

freezes
integer

The number of available streak freezes. Only present if the organization has enabled streak freezes.

maxFreezes
integer

The maximum number of streak freezes a user can have. Only present if the organization has enabled streak freezes.

freezeAutoEarnInterval
integer

The interval at which the user will earn streak freezes, in days. Only present if the organization has enabled streak freeze auto-earn.

freezeAutoEarnAmount
integer

The amount of streak freezes the user will earn per interval. Only present if the organization has enabled streak freeze auto-earn.

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.

I