> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trophy.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a user's achievements

> Get a user's achievements.



## OpenAPI

````yaml https://api.trophy.so/v1/openapi get /users/{id}/achievements
openapi: 3.1.0
info:
  title: Trophy
  version: 1.19.0
servers:
  - x-fern-server-name: Application API
    url: https://api.trophy.so/v1
    description: Application API
security: []
paths:
  /users/{id}/achievements:
    servers:
      - url: https://api.trophy.so/v1
        description: Application API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    get:
      tags:
        - Users
      summary: Get a user's achievements
      description: Get a user's achievements.
      operationId: users_achievements
      parameters:
        - name: id
          in: path
          description: ID of the user.
          required: true
          schema:
            type: string
          example: userId
        - name: includeIncomplete
          in: query
          description: >-
            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.
          required: false
          schema:
            type: string
            enum:
              - 'true'
          example: 'true'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserAchievementWithStatsResponse'
              examples:
                Successful operation:
                  value:
                    - 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
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '422':
          description: Unprocessible Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: javascript
          label: Get a user's completed achievements
          source: |
            import { TrophyApiClient } from '@trophyso/node';

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

            const response = await trophy.users.achievements("user-id");
        - lang: javascript
          label: Get a user's achievements (include incomplete)
          source: |
            import { TrophyApiClient } from '@trophyso/node';

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

            const response = await trophy.users.achievements("user-id", {
              includeIncomplete: true
            });
        - lang: python
          label: Get a user's completed achievements
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.users.achievements(id="user-id")
        - lang: python
          label: Get a user's achievements (include incomplete)
          source: >
            from trophy import TrophyApi


            client = TrophyApi(api_key='YOUR_API_KEY')


            response = client.users.achievements(id="user-id",
            include_incomplete="true")
        - lang: go
          source: |
            import (
              "context"

              api "github.com/trophyso/trophy-go"
              trophyclient "github.com/trophyso/trophy-go/client"
              "github.com/trophyso/trophy-go/option"
            )

            client := trophyclient.NewClient(
              option.WithApiKey("YOUR_API_KEY"),
            )

            response, err := client.Users.Achievements(
              context.TODO(),
              "user-id",
              &api.UsersAchievementsRequest{},
            )
components:
  parameters:
    TenantId:
      name: Tenant-ID
      in: header
      description: >-
        The tenant identifier for multi-tenant organisations. Required when the
        organisation has multi-tenancy enabled. The value should be your
        internal ID for the tenant. Ignored for single-tenant organisations.
      required: false
      schema:
        type: string
      example: customer_12345
  schemas:
    UserAchievementWithStatsResponse:
      title: UserAchievementWithStatsResponse
      type: object
      allOf:
        - $ref: '#/components/schemas/AchievementWithStatsResponse'
        - type: object
          properties:
            achievedAt:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                The date and time the achievement was completed, in ISO 8601
                format. Null if the achievement has not been completed.
          required:
            - achievedAt
    ErrorBody:
      title: ErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    AchievementWithStatsResponse:
      title: AchievementWithStatsResponse
      type: object
      allOf:
        - $ref: '#/components/schemas/AchievementResponse'
        - type: object
          properties:
            completions:
              type: integer
              description: The number of users who have completed this achievement.
            rarity:
              type: number
              format: double
              description: The percentage of all users who have completed this achievement.
          required:
            - completions
            - rarity
    AchievementResponse:
      title: AchievementResponse
      type: object
      properties:
        id:
          type: string
          description: The unique ID of the achievement.
        name:
          type: string
          description: The name of this achievement.
        trigger:
          type: string
          enum:
            - metric
            - streak
            - api
            - achievement
          description: The trigger of the achievement.
        description:
          type:
            - string
            - 'null'
          description: The description of this achievement.
        badgeUrl:
          type:
            - string
            - 'null'
          description: >-
            The URL of the badge image for the achievement, if one has been
            uploaded.
        key:
          type: string
          description: >-
            The key used to reference this achievement in the API (only
            applicable if trigger = 'api')
        streakLength:
          type: integer
          description: >-
            The length of the streak required to complete the achievement (only
            applicable if trigger = 'streak')
        achievementIds:
          type: array
          items:
            type: string
          description: >-
            The IDs of the prerequisite achievements that must be completed to
            earn this achievement (only applicable if trigger = 'achievement')
        metricId:
          type: string
          description: >-
            The ID of the metric associated with this achievement (only
            applicable if trigger = 'metric')
        metricValue:
          type: number
          format: double
          description: >-
            The value of the metric required to complete the achievement (only
            applicable if trigger = 'metric')
        metricName:
          type: string
          description: >-
            The name of the metric associated with this achievement (only
            applicable if trigger = 'metric')
        userAttributes:
          type: array
          description: >-
            User attribute filters that must be met for this achievement to be
            completed.
          items:
            type: object
            properties:
              key:
                type: string
                description: The key of the user attribute.
                example: plan-type
              value:
                type: string
                description: The value of the user attribute.
                example: premium
            required:
              - key
              - value
        eventAttribute:
          type: object
          description: >-
            Deprecated. Event attribute filter that must be met for this
            achievement to be completed. Only present if the achievement has an
            event filter configured.
          deprecated: true
          properties:
            key:
              type: string
              description: The key of the event attribute.
              example: source
            value:
              type: string
              description: The value of the event attribute.
              example: mobile-app
          required:
            - key
            - value
        eventAttributes:
          type: array
          description: >-
            Event attribute filters that must be met for this achievement to be
            completed. Omitted for non-metric achievements.
          items:
            type: object
            properties:
              key:
                type: string
                description: The key of the event attribute.
                example: source
              value:
                type: string
                description: The value of the event attribute.
                example: mobile-app
            required:
              - key
              - value
      required:
        - id
        - name
        - trigger
        - description
        - badgeUrl
        - userAttributes
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````