diff --git a/api-reference/endpoints/streaks/get-streak-rankings.mdx b/api-reference/endpoints/streaks/get-streak-rankings.mdx new file mode 100644 index 0000000..94d0246 --- /dev/null +++ b/api-reference/endpoints/streaks/get-streak-rankings.mdx @@ -0,0 +1,3 @@ +--- +openapi: get /streaks/rankings +--- diff --git a/api-reference/openapi.yml b/api-reference/openapi.yml index a5b20ea..9cebc2d 100644 --- a/api-reference/openapi.yml +++ b/api-reference/openapi.yml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: Trophy - version: '1.0.4' + version: "1.0.4" paths: /achievements: get: @@ -20,14 +20,14 @@ paths: const response = await trophy.achievements.all(); responses: - '200': + "200": description: Successful operation content: application/json: schema: type: array items: - $ref: '#/components/schemas/AchievementWithStatsResponse' + $ref: "#/components/schemas/AchievementWithStatsResponse" examples: Successful operation: value: @@ -68,18 +68,18 @@ paths: userAttributes: - key: plan-type value: premium - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get all achievements and their completion stats security: - ApiKeyAuth: [] @@ -112,12 +112,12 @@ paths: type: string example: finish-onboarding responses: - '201': + "201": description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/AchievementCompletionResponse' + $ref: "#/components/schemas/AchievementCompletionResponse" examples: Successful operation: value: @@ -129,7 +129,7 @@ paths: description: Complete the onboarding process. badgeUrl: https://example.com/badge.png key: finish-onboarding - achievedAt: '2021-01-01T00:00:00Z' + achievedAt: "2021-01-01T00:00:00Z" points: points-system-key: id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 @@ -141,31 +141,31 @@ paths: awards: - id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 awarded: 10 - date: '2021-01-01T00:00:00Z' + date: "2021-01-01T00:00:00Z" total: 10 trigger: id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 type: achievement achievementName: Finish onboarding points: 10 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Achievement Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Achievement Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Mark an achievement as completed security: - ApiKeyAuth: [] @@ -177,7 +177,7 @@ paths: type: object properties: user: - $ref: '#/components/schemas/UpsertedUser' + $ref: "#/components/schemas/UpsertedUser" description: The user that completed the achievement. required: - user @@ -231,12 +231,12 @@ paths: type: string example: words-written responses: - '201': + "201": description: Created event content: application/json: schema: - $ref: '#/components/schemas/EventResponse' + $ref: "#/components/schemas/EventResponse" examples: Successful operation: value: @@ -251,14 +251,14 @@ paths: metricValue: 500 name: 500 words written description: Write 500 words in the app. - achievedAt: '2020-01-01T00:00:00Z' + achievedAt: "2020-01-01T00:00:00Z" currentStreak: length: 1 frequency: daily - started: '2025-04-02' - periodStart: '2025-03-31' - periodEnd: '2025-04-05' - expires: '2025-04-12' + started: "2025-04-02" + periodStart: "2025-03-31" + periodEnd: "2025-04-05" + expires: "2025-04-12" points: xp: id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 @@ -270,7 +270,7 @@ paths: awards: - id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 awarded: 10 - date: '2021-01-01T00:00:00Z' + date: "2021-01-01T00:00:00Z" total: 10 trigger: id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 @@ -278,24 +278,24 @@ paths: metricName: words written metricThreshold: 100 points: 10 - '400': - description: 'Bad Request' + "400": + description: "Bad Request" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '401': - description: 'Unauthorized' + $ref: "#/components/schemas/ErrorBody" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Send a metric change event security: - ApiKeyAuth: [] @@ -307,7 +307,7 @@ paths: type: object properties: user: - $ref: '#/components/schemas/UpsertedUser' + $ref: "#/components/schemas/UpsertedUser" description: The user that triggered the event. value: type: number @@ -333,7 +333,7 @@ paths: user: email: user@example.com tz: Europe/London - id: '18' + id: "18" attributes: department: engineering role: developer @@ -375,15 +375,15 @@ paths: application/json: schema: type: object - $ref: '#/components/schemas/UpsertedUser' + $ref: "#/components/schemas/UpsertedUser" description: The user object. responses: - '201': + "201": description: Identified user content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" examples: Successful operation: value: @@ -391,29 +391,29 @@ paths: email: user@example.com tz: Europe/London subscribedToEmails: true - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" attributes: department: engineering role: developer - '400': - description: 'Bad Request' + "400": + description: "Bad Request" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '401': - description: 'Unauthorized' + $ref: "#/components/schemas/ErrorBody" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" /users/{id}: get: description: Get a single user. @@ -442,12 +442,12 @@ paths: security: - ApiKeyAuth: [] responses: - '200': + "200": description: Found user content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" examples: Successful operation: value: @@ -455,29 +455,29 @@ paths: email: user@example.com tz: Europe/London subscribedToEmails: true - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" attributes: department: engineering role: developer - '400': - description: 'Bad Request' + "400": + description: "Bad Request" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '401': - description: 'Unauthorized' + $ref: "#/components/schemas/ErrorBody" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" put: description: Identify a user. operationId: users_identify @@ -516,7 +516,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UpdatedUser' + $ref: "#/components/schemas/UpdatedUser" description: The user object. example: email: user@example.com @@ -525,12 +525,12 @@ paths: department: engineering role: developer responses: - '200': + "200": description: Upserted user content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" examples: Successful operation: value: @@ -538,26 +538,26 @@ paths: email: user@example.com tz: Europe/London subscribedToEmails: true - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' - '400': - description: 'Bad Request' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" + "400": + description: "Bad Request" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '401': - description: 'Unauthorized' + $ref: "#/components/schemas/ErrorBody" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" patch: description: Update a user. operationId: users_update @@ -596,7 +596,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UpdatedUser' + $ref: "#/components/schemas/UpdatedUser" description: The user object. example: id: user-id @@ -606,12 +606,12 @@ paths: department: engineering role: developer responses: - '200': + "200": description: Updated user content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" examples: Successful operation: value: @@ -619,32 +619,32 @@ paths: email: user@example.com tz: Europe/London subscribedToEmails: true - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' - '400': - description: 'Bad Request' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" + "400": + description: "Bad Request" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'User Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "User Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '401': - description: 'Unauthorized' + $ref: "#/components/schemas/ErrorBody" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" /users/{id}/metrics: get: description: Get a single user's progress against all active metrics. @@ -670,14 +670,14 @@ paths: type: string example: userId responses: - '200': + "200": description: Successful operation content: application/json: schema: type: array items: - $ref: '#/components/schemas/MetricResponse' + $ref: "#/components/schemas/MetricResponse" examples: Successful operation: value: @@ -692,14 +692,14 @@ paths: name: Novice Writer metricId: d01dcbcb-d51e-4c12-b054-dc811dcdc623 metricValue: 500 - achievedAt: '2021-01-01T00:00:00Z' + achievedAt: "2021-01-01T00:00:00Z" badgeUrl: https://example.com/badge1.png - 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' + achievedAt: "2021-01-02T00:00:00Z" badgeUrl: https://example.com/badge2.png - id: 2090d038-aa04-4048-ab2e-e2b7bf2d3b9f trigger: metric @@ -707,24 +707,24 @@ paths: metricId: d01dcbcb-d51e-4c12-b054-dc811dcdc623 metricValue: 2000 achievedAt: null - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'User Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "User Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get all metrics for a user security: - ApiKeyAuth: [] @@ -760,12 +760,12 @@ paths: type: string example: key responses: - '200': + "200": description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/MetricResponse' + $ref: "#/components/schemas/MetricResponse" examples: Successful operation: value: @@ -780,13 +780,13 @@ paths: name: Novice Writer metricId: d01dcbcb-d51e-4c12-b054-dc811dcdc623 metricValue: 500 - achievedAt: '2021-01-01T00:00:00Z' + 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' + achievedAt: "2021-01-02T00:00:00Z" - id: 2090d038-aa04-4048-ab2e-e2b7bf2d3b9f trigger: metric name: Expert Writer @@ -794,24 +794,24 @@ paths: metricValue: 2000 achievedAt: null badgeUrl: https://example.com/badge.png - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a single metric for a user security: - ApiKeyAuth: [] @@ -868,7 +868,7 @@ paths: schema: type: string format: date - example: '2024-01-01' + example: "2024-01-01" - name: endDate in: query description: The end date for the data range in YYYY-MM-DD format. The endDate must be after the startDate, and the date range must not exceed 400 days. @@ -876,9 +876,9 @@ paths: schema: type: string format: date - example: '2024-01-31' + example: "2024-01-31" responses: - '200': + "200": description: Successful operation content: application/json: @@ -891,7 +891,7 @@ paths: type: string format: date description: The date of the data point. For weekly or monthly aggregations, this is the first date of the period. - example: '2024-01-01' + example: "2024-01-01" total: type: number format: double @@ -909,33 +909,33 @@ paths: examples: Successful operation: value: - - date: '2024-01-01' + - date: "2024-01-01" total: 100 change: 100 - - date: '2024-01-02' + - date: "2024-01-02" total: 300 change: 200 - - date: '2024-01-03' + - date: "2024-01-03" total: 600 change: 300 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a summary of metric events over time security: - ApiKeyAuth: [] @@ -982,17 +982,17 @@ paths: required: false schema: type: string - enum: ['true'] - example: 'true' + enum: ["true"] + example: "true" responses: - '200': + "200": description: Successful operation content: application/json: schema: type: array items: - $ref: '#/components/schemas/CompletedAchievementResponse' + $ref: "#/components/schemas/CompletedAchievementResponse" examples: Successful operation: value: @@ -1000,7 +1000,7 @@ paths: trigger: api key: completed-onboarding name: Completed Onboarding - achievedAt: '2021-01-01T00:00:00Z' + achievedAt: "2021-01-01T00:00:00Z" badgeUrl: https://example.com/badge2.png completions: 10 rarity: 90.13 @@ -1011,7 +1011,7 @@ paths: metricValue: 500 metricName: words written name: Novice Writer - achievedAt: '2021-02-01T00:00:00Z' + achievedAt: "2021-02-01T00:00:00Z" badgeUrl: https://example.com/badge1.png completions: 8 rarity: 22.98 @@ -1020,28 +1020,28 @@ paths: key: 3-day-streak streakLength: 3 name: 3-Day Streak - achievedAt: '2021-03-01T00:00:00Z' + achievedAt: "2021-03-01T00:00:00Z" badgeUrl: https://example.com/badge2.png completions: 12 rarity: 89.52 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a user's achievements security: - ApiKeyAuth: [] @@ -1080,62 +1080,62 @@ paths: The number of past streak periods to include in the streakHistory field of the response. responses: - '200': + "200": description: Successful operation content: application/json: schema: type: object - $ref: '#/components/schemas/StreakResponse' + $ref: "#/components/schemas/StreakResponse" examples: Successful operation: value: length: 1 frequency: weekly - started: '2025-04-02' - periodStart: '2025-03-31' - periodEnd: '2025-04-05' - expires: '2025-04-12' + started: "2025-04-02" + periodStart: "2025-03-31" + periodEnd: "2025-04-05" + expires: "2025-04-12" streakHistory: - - periodStart: '2025-03-30' - periodEnd: '2025-04-05' + - periodStart: "2025-03-30" + periodEnd: "2025-04-05" length: 1 - - periodStart: '2025-04-06' - periodEnd: '2025-04-12' + - periodStart: "2025-04-06" + periodEnd: "2025-04-12" length: 2 - - periodStart: '2025-04-13' - periodEnd: '2025-04-19' + - periodStart: "2025-04-13" + periodEnd: "2025-04-19" length: 3 - - periodStart: '2025-04-20' - periodEnd: '2025-04-26' + - periodStart: "2025-04-20" + periodEnd: "2025-04-26" length: 0 - - periodStart: '2025-04-27' - periodEnd: '2025-05-03' + - periodStart: "2025-04-27" + periodEnd: "2025-05-03" length: 1 - - periodStart: '2025-05-04' - periodEnd: '2025-05-10' + - periodStart: "2025-05-04" + periodEnd: "2025-05-10" length: 2 - - periodStart: '2025-05-11' - periodEnd: '2025-05-17' + - periodStart: "2025-05-11" + periodEnd: "2025-05-17" length: 3 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a user's streak status security: - ApiKeyAuth: [] @@ -1254,12 +1254,12 @@ paths: maximum: 100 description: The number of recent point awards to return. responses: - '200': + "200": description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/GetUserPointsResponse' + $ref: "#/components/schemas/GetUserPointsResponse" examples: Successful operation: value: @@ -1271,7 +1271,7 @@ paths: awards: - id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 awarded: 10 - date: '2021-01-01T00:00:00Z' + date: "2021-01-01T00:00:00Z" total: 100 trigger: id: 0040fe51-6bce-4b44-b0ad-bddc4e123534 @@ -1279,24 +1279,24 @@ paths: points: 10 metricName: words written metricThreshold: 1000 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a user's points data security: - ApiKeyAuth: [] @@ -1353,7 +1353,7 @@ paths: schema: type: string format: date - example: '2024-01-01' + example: "2024-01-01" - name: endDate in: query description: The end date for the data range in YYYY-MM-DD format. The endDate must be after the startDate, and the date range must not exceed 400 days. @@ -1361,9 +1361,9 @@ paths: schema: type: string format: date - example: '2024-01-31' + example: "2024-01-31" responses: - '200': + "200": description: Successful operation content: application/json: @@ -1376,7 +1376,7 @@ paths: type: string format: date description: The date of the data point. For weekly or monthly aggregations, this is the first date of the period. - example: '2024-01-01' + example: "2024-01-01" total: type: number format: double @@ -1394,33 +1394,33 @@ paths: examples: Successful operation: value: - - date: '2024-01-01' + - date: "2024-01-01" total: 100 change: 100 - - date: '2024-01-02' + - date: "2024-01-02" total: 300 change: 200 - - date: '2024-01-03' + - date: "2024-01-03" total: 600 change: 300 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a summary of points events over time security: - ApiKeyAuth: [] @@ -1458,12 +1458,12 @@ paths: type: string example: plan-type:premium,region:us-east responses: - '200': + "200": description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/PointsSummaryResponse' + $ref: "#/components/schemas/PointsSummaryResponse" examples: Successful operation: value: @@ -1500,24 +1500,24 @@ paths: - from: 901 to: 1000 users: 0 - '401': - description: 'Unauthorized' + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Not Found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Not Found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '422': - description: 'Unprocessible Entity' + $ref: "#/components/schemas/ErrorBody" + "422": + description: "Unprocessible Entity" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a breakdown of users by points security: - ApiKeyAuth: [] @@ -1546,12 +1546,12 @@ paths: type: string example: points-system-key responses: - '200': + "200": description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/PointsSystemResponse' + $ref: "#/components/schemas/PointsSystemResponse" examples: Successful operation: value: @@ -1575,15 +1575,15 @@ paths: eventAttribute: key: source value: mobile-app - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" - id: 0040fe51-6bce-4b44-b0ad-bddc4e123536 type: streak points: 10 status: active streakLengthThreshold: 7 - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" - id: 0040fe51-6bce-4b44-b0ad-bddc4e123535 type: achievement points: 50 @@ -1593,20 +1593,20 @@ paths: userAttributes: - key: plan-type value: premium - created: '2021-01-01T00:00:00Z' - updated: '2021-01-01T00:00:00Z' - '401': - description: 'Unauthorized' + created: "2021-01-01T00:00:00Z" + updated: "2021-01-01T00:00:00Z" + "401": + description: "Unauthorized" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' - '404': - description: 'Points system not found' + $ref: "#/components/schemas/ErrorBody" + "404": + description: "Points system not found" content: application/json: schema: - $ref: '#/components/schemas/ErrorBody' + $ref: "#/components/schemas/ErrorBody" summary: Get a points system with its triggers security: - ApiKeyAuth: [] @@ -1635,7 +1635,7 @@ components: type: integer description: The length of the user's current streak. frequency: - $ref: '#/components/schemas/StreakFrequency' + $ref: "#/components/schemas/StreakFrequency" description: The frequency of the streak. started: type: string @@ -1661,7 +1661,7 @@ components: type: object description: An object representing the user's streak after sending a metric event. allOf: - - $ref: '#/components/schemas/BaseStreakResponse' + - $ref: "#/components/schemas/BaseStreakResponse" - type: object properties: extended: @@ -1672,7 +1672,7 @@ components: type: object description: An object representing the user's streak. allOf: - - $ref: '#/components/schemas/BaseStreakResponse' + - $ref: "#/components/schemas/BaseStreakResponse" - type: object properties: streakHistory: @@ -1689,12 +1689,12 @@ components: type: string format: date description: The date this streak period started. - example: '2025-03-31' + example: "2025-03-31" periodEnd: type: string format: date description: The date this streak period ended. - example: '2025-04-05' + example: "2025-04-05" length: type: integer description: The length of the user's streak during this period. @@ -1713,7 +1713,7 @@ components: type: type: string description: The type of trigger - enum: ['metric', 'achievement', 'streak'] + enum: ["metric", "achievement", "streak"] points: type: number description: The points awarded by this trigger. @@ -1746,7 +1746,7 @@ components: type: number description: The user's total points after this award occurred. trigger: - $ref: '#/components/schemas/PointsTrigger' + $ref: "#/components/schemas/PointsTrigger" GetUserPointsResponse: title: GetUserPointsResponse type: object @@ -1770,7 +1770,7 @@ components: type: array description: Array of trigger awards that added points. items: - $ref: '#/components/schemas/PointsAward' + $ref: "#/components/schemas/PointsAward" required: - id - name @@ -1780,7 +1780,7 @@ components: title: MetricEventPointsResponse type: object allOf: - - $ref: '#/components/schemas/GetUserPointsResponse' + - $ref: "#/components/schemas/GetUserPointsResponse" - type: object properties: added: @@ -1799,7 +1799,7 @@ components: description: The name of this achievement. trigger: type: string - enum: ['metric', 'streak', 'api'] + enum: ["metric", "streak", "api"] description: The trigger of the achievement. description: type: string @@ -1827,7 +1827,7 @@ components: type: string description: The name of the metric associated with this achievement (only applicable if trigger = 'metric') currentStreak: - $ref: '#/components/schemas/MetricEventStreakResponse' + $ref: "#/components/schemas/MetricEventStreakResponse" description: >- The user's current streak for the metric, if the metric has streaks enabled. @@ -1839,7 +1839,7 @@ components: title: CompletedAchievementResponse type: object allOf: - - $ref: '#/components/schemas/AchievementResponse' + - $ref: "#/components/schemas/AchievementResponse" - type: object properties: achievedAt: @@ -1850,7 +1850,7 @@ components: title: AchievementWithStatsResponse type: object allOf: - - $ref: '#/components/schemas/AchievementResponse' + - $ref: "#/components/schemas/AchievementResponse" - type: object properties: completions: @@ -1909,7 +1909,7 @@ components: description: The name of the metric. example: Words written status: - $ref: '#/components/schemas/MetricStatus' + $ref: "#/components/schemas/MetricStatus" description: The status of the metric. current: type: number @@ -1919,7 +1919,7 @@ components: achievements: type: array items: - $ref: '#/components/schemas/CompletedAchievementResponse' + $ref: "#/components/schemas/CompletedAchievementResponse" description: >- A list of the metric's achievements and the user's progress towards each. @@ -1953,7 +1953,7 @@ components: items: type: string description: The device token. - example: ['token1', 'token2'] + example: ["token1", "token2"] subscribeToEmails: type: boolean default: true @@ -1972,7 +1972,7 @@ components: type: object description: An object with editable user fields. allOf: - - $ref: '#/components/schemas/UpdatedUser' + - $ref: "#/components/schemas/UpdatedUser" - type: object properties: id: @@ -1986,7 +1986,7 @@ components: type: object description: A user of your application. allOf: - - $ref: '#/components/schemas/UpsertedUser' + - $ref: "#/components/schemas/UpsertedUser" - type: object properties: control: @@ -1997,12 +1997,12 @@ components: type: string format: date-time description: The date and time the user was created, in ISO 8601 format. - example: '2021-01-01T00:00:00Z' + example: "2021-01-01T00:00:00Z" updated: type: string format: date-time description: The date and time the user was last updated, in ISO 8601 format. - example: '2021-01-01T00:00:00Z' + example: "2021-01-01T00:00:00Z" ErrorBody: title: ErrorBody type: object @@ -2020,11 +2020,11 @@ components: description: The unique ID of the completion. example: 0040fe51-6bce-4b44-b0ad-bddc4e123534 achievement: - $ref: '#/components/schemas/CompletedAchievementResponse' + $ref: "#/components/schemas/CompletedAchievementResponse" points: type: object additionalProperties: - $ref: '#/components/schemas/MetricEventPointsResponse' + $ref: "#/components/schemas/MetricEventPointsResponse" description: >- A map of points systems by key that were affected by this achievement completion. required: @@ -2050,17 +2050,17 @@ components: achievements: type: array items: - $ref: '#/components/schemas/CompletedAchievementResponse' + $ref: "#/components/schemas/CompletedAchievementResponse" description: Achievements completed as a result of this event. currentStreak: - $ref: '#/components/schemas/MetricEventStreakResponse' + $ref: "#/components/schemas/MetricEventStreakResponse" description: >- The user's current streak for the metric, if the metric has streaks enabled. points: type: object additionalProperties: - $ref: '#/components/schemas/MetricEventPointsResponse' + $ref: "#/components/schemas/MetricEventPointsResponse" description: >- A map of points systems by key that were affected by this event. required: @@ -2089,7 +2089,7 @@ components: to the greatest number of points a user has, rounded up to the nearest power of 10. items: - $ref: '#/components/schemas/PointsRange' + $ref: "#/components/schemas/PointsRange" PointsTriggerResponse: title: PointsTriggerResponse type: object @@ -2099,14 +2099,14 @@ components: description: The unique ID of the trigger. type: type: string - enum: ['metric', 'achievement', 'streak'] + enum: ["metric", "achievement", "streak"] description: The type of trigger. points: type: number description: The points awarded by this trigger. status: type: string - enum: ['active', 'archived'] + enum: ["active", "archived"] description: The status of the trigger. achievementId: type: string @@ -2186,7 +2186,7 @@ components: type: array description: Array of active triggers for this points system. items: - $ref: '#/components/schemas/PointsTriggerResponse' + $ref: "#/components/schemas/PointsTriggerResponse" required: - id - name diff --git a/docs.json b/docs.json index 03d549c..ae662e9 100644 --- a/docs.json +++ b/docs.json @@ -123,6 +123,10 @@ "api-reference/endpoints/achievements/all-achievements" ] }, + { + "group": "Streaks", + "pages": ["api-reference/endpoints/streaks/get-streak-rankings"] + }, { "group": "Metrics", "pages": [ diff --git a/platform/streaks.mdx b/platform/streaks.mdx index eed3b86..40f9d01 100644 --- a/platform/streaks.mdx +++ b/platform/streaks.mdx @@ -134,6 +134,12 @@ Use this data to display a user's streak history within your application. /> +### Streak Rankings + +You can also use the [streak rankings API](/api-reference/endpoints/streaks/get-streak-rankings) to get a list of up to the the top 100 users by streak length and display a streak leaderboard in your application. + +You can fetch rankings either for 'active' streaks (users on a streak at the time of request), or 'longest' (ranking each users longest ever streak). + ## Get Support Want to get in touch with the Trophy team? Reach out to us via [email](mailto:support@trophy.so). We're here to help!