Saltar al contenido principal
GET
/
users
/
{id}
/
achievements
import { TrophyApiClient } from '@trophyso/node';

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

const response = await trophy.users.achievements("user-id");
[
  {
    "id": "d01dcbcb-d51e-4c12-b054-dc811dcdc625",
    "name": "Completed Onboarding",
    "trigger": "api",
    "key": "completed-onboarding",
    "achievedAt": "2021-01-01T00:00:00Z",
    "badgeUrl": "https://example.com/badge2.png",
    "completions": 100,
    "rarity": 50
  },
  {
    "id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
    "trigger": "metric",
    "key": "novice-writer",
    "metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc619",
    "metricValue": 500,
    "metricName": "words written",
    "name": "Novice Writer",
    "achievedAt": "2021-02-01T00:00:00Z",
    "badgeUrl": "https://example.com/badge1.png",
    "completions": 100,
    "rarity": 50
  },
  {
    "id": "d01dcbcb-d51e-4c12-b054-dc811dcdc624",
    "trigger": "streak",
    "key": "3-day-streak",
    "streakLength": 3,
    "name": "3-Day Streak",
    "achievedAt": "2021-03-01T00:00:00Z",
    "badgeUrl": "https://example.com/badge2.png",
    "completions": 100,
    "rarity": 50
  }
]
Límites de tasa

Autorizaciones

X-API-KEY
string
header
requerido

Parámetros de ruta

id
string
requerido

ID of the user.

Parámetros de consulta

includeIncomplete
enum<string>

When set to 'true', returns both completed and incomplete achievements for the user. When omitted or set to any other value, returns only completed achievements.

Opciones disponibles:
true

Respuesta

Successful operation

id
string
requerido

The unique ID of the achievement.

name
string
requerido

The name of this achievement.

trigger
enum<string>
requerido

The trigger of the achievement.

Opciones disponibles:
metric,
streak,
api,
achievement
description
string | null
requerido

The description of this achievement.

badgeUrl
string | null
requerido

The URL of the badge image for the achievement, if one has been uploaded.

completions
integer
requerido

The number of users who have completed this achievement.

rarity
number<double>
requerido

The percentage of all users who have completed this achievement.

achievedAt
string<date-time> | null
requerido

The date and time the achievement was completed, in ISO 8601 format. Null if the achievement has not been completed.

key
string

The key used to reference this achievement in the API (only applicable if trigger = 'api')

streakLength
integer

The length of the streak required to complete the achievement (only applicable if trigger = 'streak')

achievementIds
string[]

The IDs of the prerequisite achievements that must be completed to earn this achievement (only applicable if trigger = 'achievement')

metricId
string

The ID of the metric associated with this achievement (only applicable if trigger = 'metric')

metricValue
number<double>

The value of the metric required to complete the achievement (only applicable if trigger = 'metric')

metricName
string

The name of the metric associated with this achievement (only applicable if trigger = 'metric')

userAttributes
object[]

User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.

eventAttribute
object

Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.