> ## 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 all achievements and their completion stats

> Get all achievements and their completion stats.



## OpenAPI

````yaml https://api.trophy.so/v1/openapi get /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:
  /achievements:
    servers:
      - url: https://api.trophy.so/v1
        description: Application API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    get:
      tags:
        - Achievements
      summary: Get all achievements and their completion stats
      description: Get all achievements and their completion stats.
      operationId: achievements_all
      parameters:
        - name: userAttributes
          in: query
          description: >-
            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.
          required: false
          schema:
            type: string
          example: plan-type:premium,region:us-east
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AchievementWithStatsResponse'
              examples:
                Successful operation:
                  value:
                    - 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
                      eventAttributes:
                        - key: source
                          value: mobile-app
                        - key: plan
                          value: premium
                    - 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
        '401':
          description: Unauthorized
          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
          source: |
            import { TrophyApiClient } from '@trophyso/node';

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

            const response = await trophy.achievements.all();
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.achievements.all()
        - 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.Achievements.All(context.TODO(),
            &api.AchievementsAllRequest{})
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:
    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
    ErrorBody:
      title: ErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    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

````