import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.allMetrics("user-id");[
{
"id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"key": "words-written",
"name": "Words written",
"status": "active",
"current": 4500,
"achievements": [
{
"id": "abe3120f-5ca9-4344-92c8-5b891643a04b",
"trigger": "metric",
"name": "Novice Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 500,
"achievedAt": "2021-01-01T00:00:00Z",
"badgeUrl": "https://example.com/badge1.png"
},
{
"id": "8a07f2d0-9c72-4de1-bf92-9530ae82b4b6",
"trigger": "metric",
"name": "Intermediate Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 1000,
"achievedAt": "2021-01-02T00:00:00Z",
"badgeUrl": "https://example.com/badge2.png"
},
{
"id": "2090d038-aa04-4048-ab2e-e2b7bf2d3b9f",
"trigger": "metric",
"name": "Expert Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 2000,
"achievedAt": null,
"badgeUrl": "null"
}
]
}
]Get a single user’s progress against all active metrics.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.allMetrics("user-id");[
{
"id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"key": "words-written",
"name": "Words written",
"status": "active",
"current": 4500,
"achievements": [
{
"id": "abe3120f-5ca9-4344-92c8-5b891643a04b",
"trigger": "metric",
"name": "Novice Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 500,
"achievedAt": "2021-01-01T00:00:00Z",
"badgeUrl": "https://example.com/badge1.png"
},
{
"id": "8a07f2d0-9c72-4de1-bf92-9530ae82b4b6",
"trigger": "metric",
"name": "Intermediate Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 1000,
"achievedAt": "2021-01-02T00:00:00Z",
"badgeUrl": "https://example.com/badge2.png"
},
{
"id": "2090d038-aa04-4048-ab2e-e2b7bf2d3b9f",
"trigger": "metric",
"name": "Expert Writer",
"description": "null",
"metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
"metricValue": 2000,
"achievedAt": null,
"badgeUrl": "null"
}
]
}
]ID of the user
Successful operation
The unique ID of the metric.
"d01dcbcb-d51e-4c12-b054-dc811dcdc623"
The unique key of the metric.
"words-written"
The name of the metric.
"Words written"
The status of the metric.
archived, active The user's current total for the metric.
1500
A list of the metric's achievements and the user's progress towards each.
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.
Was this page helpful?