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

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

const response = await trophy.achievements.all();
[
  {
    "id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
    "trigger": "api",
    "name": "Finish onboarding",
    "description": "Complete the onboarding process.",
    "badgeUrl": "https://example.com/badge.png",
    "key": "finish-onboarding",
    "completions": 8,
    "rarity": 80
  },
  {
    "id": "5100fe51-6bce-6j44-b0hs-bddc4e123683",
    "trigger": "metric",
    "name": "500 words written",
    "description": "Write 500 words in the app.",
    "badgeUrl": "https://example.com/badge.png",
    "metricId": "5100fe51-6bce-6j44-b0hs-bddc4e123683",
    "metricName": "words written",
    "metricValue": 500,
    "completions": 6,
    "rarity": 60,
    "userAttributes": [
      {
        "key": "plan-type",
        "value": "premium"
      },
      {
        "key": "region",
        "value": "us-east"
      }
    ],
    "eventAttribute": {
      "key": "source",
      "value": "mobile-app"
    }
  },
  {
    "id": "5100fe51-6bce-6j44-b0hs-bddc4e123684",
    "trigger": "streak",
    "name": "10 days of exercise",
    "description": "Exercise at least once a day for 10 days in a row.",
    "badgeUrl": "https://example.com/badge.png",
    "streakLength": 10,
    "completions": 2,
    "rarity": 20,
    "userAttributes": [
      {
        "key": "plan-type",
        "value": "premium"
      }
    ]
  }
]
Límites de Tasa

Autorizaciones

X-API-KEY
string
header
requerido

Parámetros de consulta

userAttributes
string

Optional colon-delimited user attributes in the format attribute:value,attribute:value. Only achievements accessible to a user with the provided attributes will be returned.

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.

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.