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

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

const response = await trophy.users.singleMetric("user-id", "words-written");
{
  "id": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
  "key": "words-written",
  "name": "Words written",
  "status": "active",
  "current": 1500,
  "achievements": [
    {
      "id": "abe3120f-5ca9-4344-92c8-5b891643a04b",
      "trigger": "metric",
      "name": "Novice Writer",
      "metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
      "metricValue": 500,
      "achievedAt": "2021-01-01T00:00:00Z"
    },
    {
      "id": "8a07f2d0-9c72-4de1-bf92-9530ae82b4b6",
      "trigger": "metric",
      "name": "Intermediate Writer",
      "metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
      "metricValue": 1000,
      "achievedAt": "2021-01-02T00:00:00Z"
    },
    {
      "id": "2090d038-aa04-4048-ab2e-e2b7bf2d3b9f",
      "trigger": "metric",
      "name": "Expert Writer",
      "metricId": "d01dcbcb-d51e-4c12-b054-dc811dcdc623",
      "metricValue": 2000,
      "achievedAt": null,
      "badgeUrl": "https://example.com/badge.png"
    }
  ]
}
Límites de tasa

Autorizaciones

X-API-KEY
string
header
requerido

Parámetros de ruta

id
string
requerido

ID of the user.

key
string
requerido

Unique key of the metric.

Respuesta

Successful operation

id
string
requerido

The unique ID of the metric.

Ejemplo:

"d01dcbcb-d51e-4c12-b054-dc811dcdc623"

key
string
requerido

The unique key of the metric.

Ejemplo:

"words-written"

name
string
requerido

The name of the metric.

Ejemplo:

"Words written"

status
enum<string>
requerido

The status of the metric.

Opciones disponibles:
archived,
active
current
number<double>
requerido

The user's current total for the metric.

Ejemplo:

1500

achievements
UserAchievementResponse · object[]
requerido

A list of the metric's achievements and the user's progress towards each.