import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.wrapped("user-123", {
year: 2024
});{
"user": {
"id": "user-123",
"email": "[email protected]",
"name": "John Doe",
"tz": "America/New_York",
"subscribeToEmails": true,
"created": "2024-01-15T10:30:00Z",
"updated": "2024-06-20T14:45:00Z",
"control": false,
"attributes": {
"plan-type": "premium",
"region": "us-east"
}
},
"activity": {
"daysActive": 156,
"weeksActive": 42,
"monthsActive": 11,
"mostActiveDay": {
"date": "2024-03-15",
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 2500,
"percentChange": 20,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 500,
"percentChange": 11.1
}
},
"achievements": [
{
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"name": "500 Words Written",
"trigger": "metric",
"description": "Write 500 words in a single day",
"badgeUrl": "https://example.com/badge.png",
"key": "500-words",
"metricId": "metric-123",
"metricValue": 500,
"metricName": "Words Written",
"achievedAt": "2024-03-15T14:30:00Z",
"completions": 150,
"rarity": 15
}
],
"leaderboards": {
"weekly-words": {
"id": "leaderboard-123",
"name": "Weekly Word Count",
"key": "weekly-words",
"rankBy": "metric",
"metricKey": "words-written",
"metricName": "Words Written",
"description": "Weekly writing competition",
"start": "2024-03-11",
"end": "2024-03-17",
"maxParticipants": 100,
"runUnit": "day",
"runInterval": 7,
"rank": 3,
"value": 2500
}
}
},
"mostActiveWeek": {
"start": "2024-03-11",
"end": "2024-03-17",
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 8500,
"percentChange": 130,
"percentileThisPeriod": 95,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 1200,
"percentChange": 31.5,
"percentileThisPeriod": 88
}
},
"achievements": [],
"leaderboards": {}
},
"mostActiveMonth": {
"month": 2,
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 12000,
"percentChange": 400,
"percentileThisPeriod": 92,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 2000,
"percentChange": 66.6,
"percentileThisPeriod": 85
}
},
"achievements": [],
"leaderboards": {}
},
"entireYear": {
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 150000,
"changeThisPeriod": 150000,
"percentChange": 100,
"percentileThisPeriod": 78,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 25000,
"changeThisPeriod": 25000,
"percentChange": 100,
"percentileThisPeriod": 82
}
},
"achievements": [
{
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"name": "500 Words Written",
"trigger": "metric",
"description": "Write 500 words in a single day",
"badgeUrl": "https://example.com/badge.png",
"key": "500-words",
"metricId": "metric-123",
"metricValue": 500,
"metricName": "Words Written",
"achievedAt": "2024-03-15T14:30:00Z",
"completions": 150,
"rarity": 15
}
],
"leaderboards": {},
"longestStreak": {
"length": 45,
"frequency": "daily",
"periodStart": "2024-02-01",
"periodEnd": "2024-03-17",
"started": "2024-02-01"
}
}
}
}Get a user’s year-in-review wrapped data.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.wrapped("user-123", {
year: 2024
});{
"user": {
"id": "user-123",
"email": "[email protected]",
"name": "John Doe",
"tz": "America/New_York",
"subscribeToEmails": true,
"created": "2024-01-15T10:30:00Z",
"updated": "2024-06-20T14:45:00Z",
"control": false,
"attributes": {
"plan-type": "premium",
"region": "us-east"
}
},
"activity": {
"daysActive": 156,
"weeksActive": 42,
"monthsActive": 11,
"mostActiveDay": {
"date": "2024-03-15",
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 2500,
"percentChange": 20,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 500,
"percentChange": 11.1
}
},
"achievements": [
{
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"name": "500 Words Written",
"trigger": "metric",
"description": "Write 500 words in a single day",
"badgeUrl": "https://example.com/badge.png",
"key": "500-words",
"metricId": "metric-123",
"metricValue": 500,
"metricName": "Words Written",
"achievedAt": "2024-03-15T14:30:00Z",
"completions": 150,
"rarity": 15
}
],
"leaderboards": {
"weekly-words": {
"id": "leaderboard-123",
"name": "Weekly Word Count",
"key": "weekly-words",
"rankBy": "metric",
"metricKey": "words-written",
"metricName": "Words Written",
"description": "Weekly writing competition",
"start": "2024-03-11",
"end": "2024-03-17",
"maxParticipants": 100,
"runUnit": "day",
"runInterval": 7,
"rank": 3,
"value": 2500
}
}
},
"mostActiveWeek": {
"start": "2024-03-11",
"end": "2024-03-17",
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 8500,
"percentChange": 130,
"percentileThisPeriod": 95,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 1200,
"percentChange": 31.5,
"percentileThisPeriod": 88
}
},
"achievements": [],
"leaderboards": {}
},
"mostActiveMonth": {
"month": 2,
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 15000,
"changeThisPeriod": 12000,
"percentChange": 400,
"percentileThisPeriod": 92,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 5000,
"changeThisPeriod": 2000,
"percentChange": 66.6,
"percentileThisPeriod": 85
}
},
"achievements": [],
"leaderboards": {}
},
"entireYear": {
"metrics": {
"words-written": {
"name": "Words Written",
"units": "words",
"currentTotal": 150000,
"changeThisPeriod": 150000,
"percentChange": 100,
"percentileThisPeriod": 78,
"byAttribute": {}
}
},
"points": {
"xp-system": {
"name": "Experience Points",
"description": "Points earned through activity",
"currentTotal": 25000,
"changeThisPeriod": 25000,
"percentChange": 100,
"percentileThisPeriod": 82
}
},
"achievements": [
{
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"name": "500 Words Written",
"trigger": "metric",
"description": "Write 500 words in a single day",
"badgeUrl": "https://example.com/badge.png",
"key": "500-words",
"metricId": "metric-123",
"metricValue": 500,
"metricName": "Words Written",
"achievedAt": "2024-03-15T14:30:00Z",
"completions": 150,
"rarity": 15
}
],
"leaderboards": {},
"longestStreak": {
"length": 45,
"frequency": "daily",
"periodStart": "2024-02-01",
"periodEnd": "2024-03-17",
"started": "2024-02-01"
}
}
}
}The user's ID in your database.
The year to get wrapped data for. Defaults to the current year. Must be an integer between 1 and the current year.
x >= 1Successful operation
A user's year-in-review wrapped data including activity summaries, metrics, points, achievements, streaks, and leaderboard rankings.
The user's profile information.
Show child attributes
The ID of the user in your database. Must be a string.
"user-id"
The user's email address.
The name of the user.
"John Doe"
The user's timezone.
"Europe/London"
The user's device tokens.
The device token.
["token1", "token2"]Whether the user is opted into receiving Trophy-powered emails.
true
Whether the user is in the control group, meaning they do not receive emails or other communications from Trophy.
false
The date and time the user was created, in ISO 8601 format.
"2021-01-01T00:00:00Z"
The date and time the user was last updated, in ISO 8601 format.
"2021-01-01T00:00:00Z"
The user's activity data for the wrapped year.
Show child attributes
The number of days the user was active during the year.
156
The number of weeks the user was active during the year.
42
The number of months the user was active during the year.
11
Data about the user's most active day. Activity data for a specific period (day, week, month, or year).
Show child attributes
The user's metrics during this period, keyed by metric key.
Show child attributes
A user's metric data for a wrapped period.
Show child attributes
The name of the metric.
"Words Written"
The user's current total for the metric.
15000
The change in the metric value during the period.
2500
The percentage change in the metric value during the period.
20
Metric data broken down by attribute key and value.
Show child attributes
Show child attributes
Show child attributes
The name of the metric.
The units of the metric.
The current total for this attribute value.
The change during the period for this attribute value.
The percentage change for this attribute value.
The user's percentile rank for this attribute value during the period.
The units of the metric.
"words"
The user's percentile rank for this metric during the period. Only included for weekly, monthly, and yearly aggregation periods.
85
The user's points during this period, keyed by points system key.
Show child attributes
A user's points data for a wrapped period.
Show child attributes
The name of the points system.
"Experience Points"
The user's current total points.
5000
The change in points during the period.
500
The percentage change in points during the period.
11.1
The description of the points system.
"Points earned through activity"
The user's percentile rank for this points system during the period. Only included for weekly, monthly, and yearly aggregation periods.
88
Achievements completed during this period.
Show child attributes
The unique ID of the achievement.
The name of this achievement.
The trigger of the achievement.
metric, streak, api The description of this achievement.
The URL of the badge image for the achievement, if one has been uploaded.
The key used to reference this achievement in the API (only applicable if trigger = 'api')
The number of users who have completed this achievement.
The percentage of all users who have completed this achievement.
The date and time the achievement was completed, in ISO 8601 format. Null if the achievement has not been completed.
The length of the streak required to complete the achievement (only applicable if trigger = 'streak')
The ID of the metric associated with this achievement (only applicable if trigger = 'metric')
The value of the metric required to complete the achievement (only applicable if trigger = 'metric')
The name of the metric associated with this achievement (only applicable if trigger = 'metric')
User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.
Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.
The user's best leaderboard rankings during this period, keyed by leaderboard key.
Show child attributes
A user's data for a specific leaderboard including rank, value, and history. A leaderboard with its configuration details.
Show child attributes
The unique ID of the leaderboard.
"5100fe51-6bce-6j44-b0hs-bddc4e123682"
The user-facing name of the leaderboard.
"Weekly Word Count Challenge"
The unique key used to reference the leaderboard in APIs.
"weekly-words"
What the leaderboard ranks by.
points, streak, metric "metric"
The key of the attribute to break down this leaderboard by.
"country"
The user-facing description of the leaderboard.
"Compete weekly to see who writes the most words"
The start date of the leaderboard in YYYY-MM-DD format.
"2025-01-01"
The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
"2025-12-31"
The maximum number of participants in the leaderboard.
100
The repetition type for recurring leaderboards, or null for one-time leaderboards.
day, month, year, "day"
The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.
7
The user's current rank in this leaderboard. Null if the user is not on the leaderboard.
2
The user's current value in this leaderboard. Null if the user is not on the leaderboard.
4500
The key of the metric to rank by, if rankBy is 'metric'.
"words-written"
The name of the metric to rank by, if rankBy is 'metric'.
"Words Written"
The key of the points system to rank by, if rankBy is 'points'.
"xp-system"
The name of the points system to rank by, if rankBy is 'points'.
"Experience Points"
The date of the most active day in YYYY-MM-DD format.
"2024-03-15"
Data about the user's most active week. Activity data for a specific period (day, week, month, or year).
Show child attributes
The user's metrics during this period, keyed by metric key.
Show child attributes
A user's metric data for a wrapped period.
Show child attributes
The name of the metric.
"Words Written"
The user's current total for the metric.
15000
The change in the metric value during the period.
2500
The percentage change in the metric value during the period.
20
Metric data broken down by attribute key and value.
Show child attributes
Show child attributes
Show child attributes
The name of the metric.
The units of the metric.
The current total for this attribute value.
The change during the period for this attribute value.
The percentage change for this attribute value.
The user's percentile rank for this attribute value during the period.
The units of the metric.
"words"
The user's percentile rank for this metric during the period. Only included for weekly, monthly, and yearly aggregation periods.
85
The user's points during this period, keyed by points system key.
Show child attributes
A user's points data for a wrapped period.
Show child attributes
The name of the points system.
"Experience Points"
The user's current total points.
5000
The change in points during the period.
500
The percentage change in points during the period.
11.1
The description of the points system.
"Points earned through activity"
The user's percentile rank for this points system during the period. Only included for weekly, monthly, and yearly aggregation periods.
88
Achievements completed during this period.
Show child attributes
The unique ID of the achievement.
The name of this achievement.
The trigger of the achievement.
metric, streak, api The description of this achievement.
The URL of the badge image for the achievement, if one has been uploaded.
The key used to reference this achievement in the API (only applicable if trigger = 'api')
The number of users who have completed this achievement.
The percentage of all users who have completed this achievement.
The date and time the achievement was completed, in ISO 8601 format. Null if the achievement has not been completed.
The length of the streak required to complete the achievement (only applicable if trigger = 'streak')
The ID of the metric associated with this achievement (only applicable if trigger = 'metric')
The value of the metric required to complete the achievement (only applicable if trigger = 'metric')
The name of the metric associated with this achievement (only applicable if trigger = 'metric')
User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.
Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.
The user's best leaderboard rankings during this period, keyed by leaderboard key.
Show child attributes
A user's data for a specific leaderboard including rank, value, and history. A leaderboard with its configuration details.
Show child attributes
The unique ID of the leaderboard.
"5100fe51-6bce-6j44-b0hs-bddc4e123682"
The user-facing name of the leaderboard.
"Weekly Word Count Challenge"
The unique key used to reference the leaderboard in APIs.
"weekly-words"
What the leaderboard ranks by.
points, streak, metric "metric"
The key of the attribute to break down this leaderboard by.
"country"
The user-facing description of the leaderboard.
"Compete weekly to see who writes the most words"
The start date of the leaderboard in YYYY-MM-DD format.
"2025-01-01"
The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
"2025-12-31"
The maximum number of participants in the leaderboard.
100
The repetition type for recurring leaderboards, or null for one-time leaderboards.
day, month, year, "day"
The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.
7
The user's current rank in this leaderboard. Null if the user is not on the leaderboard.
2
The user's current value in this leaderboard. Null if the user is not on the leaderboard.
4500
The key of the metric to rank by, if rankBy is 'metric'.
"words-written"
The name of the metric to rank by, if rankBy is 'metric'.
"Words Written"
The key of the points system to rank by, if rankBy is 'points'.
"xp-system"
The name of the points system to rank by, if rankBy is 'points'.
"Experience Points"
The start date of the most active week in YYYY-MM-DD format.
"2024-03-11"
The end date of the most active week in YYYY-MM-DD format.
"2024-03-17"
Data about the user's most active month. Activity data for a specific period (day, week, month, or year).
Show child attributes
The user's metrics during this period, keyed by metric key.
Show child attributes
A user's metric data for a wrapped period.
Show child attributes
The name of the metric.
"Words Written"
The user's current total for the metric.
15000
The change in the metric value during the period.
2500
The percentage change in the metric value during the period.
20
Metric data broken down by attribute key and value.
Show child attributes
Show child attributes
Show child attributes
The name of the metric.
The units of the metric.
The current total for this attribute value.
The change during the period for this attribute value.
The percentage change for this attribute value.
The user's percentile rank for this attribute value during the period.
The units of the metric.
"words"
The user's percentile rank for this metric during the period. Only included for weekly, monthly, and yearly aggregation periods.
85
The user's points during this period, keyed by points system key.
Show child attributes
A user's points data for a wrapped period.
Show child attributes
The name of the points system.
"Experience Points"
The user's current total points.
5000
The change in points during the period.
500
The percentage change in points during the period.
11.1
The description of the points system.
"Points earned through activity"
The user's percentile rank for this points system during the period. Only included for weekly, monthly, and yearly aggregation periods.
88
Achievements completed during this period.
Show child attributes
The unique ID of the achievement.
The name of this achievement.
The trigger of the achievement.
metric, streak, api The description of this achievement.
The URL of the badge image for the achievement, if one has been uploaded.
The key used to reference this achievement in the API (only applicable if trigger = 'api')
The number of users who have completed this achievement.
The percentage of all users who have completed this achievement.
The date and time the achievement was completed, in ISO 8601 format. Null if the achievement has not been completed.
The length of the streak required to complete the achievement (only applicable if trigger = 'streak')
The ID of the metric associated with this achievement (only applicable if trigger = 'metric')
The value of the metric required to complete the achievement (only applicable if trigger = 'metric')
The name of the metric associated with this achievement (only applicable if trigger = 'metric')
User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.
Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.
The user's best leaderboard rankings during this period, keyed by leaderboard key.
Show child attributes
A user's data for a specific leaderboard including rank, value, and history. A leaderboard with its configuration details.
Show child attributes
The unique ID of the leaderboard.
"5100fe51-6bce-6j44-b0hs-bddc4e123682"
The user-facing name of the leaderboard.
"Weekly Word Count Challenge"
The unique key used to reference the leaderboard in APIs.
"weekly-words"
What the leaderboard ranks by.
points, streak, metric "metric"
The key of the attribute to break down this leaderboard by.
"country"
The user-facing description of the leaderboard.
"Compete weekly to see who writes the most words"
The start date of the leaderboard in YYYY-MM-DD format.
"2025-01-01"
The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
"2025-12-31"
The maximum number of participants in the leaderboard.
100
The repetition type for recurring leaderboards, or null for one-time leaderboards.
day, month, year, "day"
The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.
7
The user's current rank in this leaderboard. Null if the user is not on the leaderboard.
2
The user's current value in this leaderboard. Null if the user is not on the leaderboard.
4500
The key of the metric to rank by, if rankBy is 'metric'.
"words-written"
The name of the metric to rank by, if rankBy is 'metric'.
"Words Written"
The key of the points system to rank by, if rankBy is 'points'.
"xp-system"
The name of the points system to rank by, if rankBy is 'points'.
"Experience Points"
The month number (0-11, where 0 is January).
0 <= x <= 112
Data about the user's activity for the entire year. Activity data for a specific period (day, week, month, or year).
Show child attributes
The user's metrics during this period, keyed by metric key.
Show child attributes
A user's metric data for a wrapped period.
Show child attributes
The name of the metric.
"Words Written"
The user's current total for the metric.
15000
The change in the metric value during the period.
2500
The percentage change in the metric value during the period.
20
Metric data broken down by attribute key and value.
Show child attributes
Show child attributes
Show child attributes
The name of the metric.
The units of the metric.
The current total for this attribute value.
The change during the period for this attribute value.
The percentage change for this attribute value.
The user's percentile rank for this attribute value during the period.
The units of the metric.
"words"
The user's percentile rank for this metric during the period. Only included for weekly, monthly, and yearly aggregation periods.
85
The user's points during this period, keyed by points system key.
Show child attributes
A user's points data for a wrapped period.
Show child attributes
The name of the points system.
"Experience Points"
The user's current total points.
5000
The change in points during the period.
500
The percentage change in points during the period.
11.1
The description of the points system.
"Points earned through activity"
The user's percentile rank for this points system during the period. Only included for weekly, monthly, and yearly aggregation periods.
88
Achievements completed during this period.
Show child attributes
The unique ID of the achievement.
The name of this achievement.
The trigger of the achievement.
metric, streak, api The description of this achievement.
The URL of the badge image for the achievement, if one has been uploaded.
The key used to reference this achievement in the API (only applicable if trigger = 'api')
The number of users who have completed this achievement.
The percentage of all users who have completed this achievement.
The date and time the achievement was completed, in ISO 8601 format. Null if the achievement has not been completed.
The length of the streak required to complete the achievement (only applicable if trigger = 'streak')
The ID of the metric associated with this achievement (only applicable if trigger = 'metric')
The value of the metric required to complete the achievement (only applicable if trigger = 'metric')
The name of the metric associated with this achievement (only applicable if trigger = 'metric')
User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.
Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.
The user's best leaderboard rankings during this period, keyed by leaderboard key.
Show child attributes
A user's data for a specific leaderboard including rank, value, and history. A leaderboard with its configuration details.
Show child attributes
The unique ID of the leaderboard.
"5100fe51-6bce-6j44-b0hs-bddc4e123682"
The user-facing name of the leaderboard.
"Weekly Word Count Challenge"
The unique key used to reference the leaderboard in APIs.
"weekly-words"
What the leaderboard ranks by.
points, streak, metric "metric"
The key of the attribute to break down this leaderboard by.
"country"
The user-facing description of the leaderboard.
"Compete weekly to see who writes the most words"
The start date of the leaderboard in YYYY-MM-DD format.
"2025-01-01"
The end date of the leaderboard in YYYY-MM-DD format, or null if it runs forever.
"2025-12-31"
The maximum number of participants in the leaderboard.
100
The repetition type for recurring leaderboards, or null for one-time leaderboards.
day, month, year, "day"
The interval between repetitions, relative to the start date and repetition type. Null for one-time leaderboards.
7
The user's current rank in this leaderboard. Null if the user is not on the leaderboard.
2
The user's current value in this leaderboard. Null if the user is not on the leaderboard.
4500
The key of the metric to rank by, if rankBy is 'metric'.
"words-written"
The name of the metric to rank by, if rankBy is 'metric'.
"Words Written"
The key of the points system to rank by, if rankBy is 'points'.
"xp-system"
The name of the points system to rank by, if rankBy is 'points'.
"Experience Points"
The user's longest streak during the year.
Show child attributes
The length of the streak.
45
The frequency of the streak.
daily, weekly, monthly The start date of the streak period.
"2024-02-01"
The end date of the streak period.
"2024-03-17"
The date the streak started.
"2024-02-01"
Was this page helpful?