Saltar al contenido principal
GET
/
users
/
{id}
/
wrapped
JavaScript
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": "user@example.com",
    "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"
      }
    }
  }
}
Límites de velocidad

Autorizaciones

X-API-KEY
string
header
requerido

Parámetros de ruta

id
string
requerido

The user's ID in your database.

Parámetros de consulta

year
integer

The year to get wrapped data for. Defaults to the current year. Must be an integer between 1 and the current year.

Rango requerido: x >= 1

Respuesta

Successful operation

A user's year-in-review wrapped data including activity summaries, metrics, points, achievements, streaks, and leaderboard rankings.

user
User · object
requerido

The user's profile information.

activity
WrappedActivity · object
requerido

The user's activity data for the wrapped year.