Skip to content

feat(api): add V2 JSON:API relationship endpoints for comment resources#4818

Merged
wescopeland merged 5 commits intoRetroAchievements:masterfrom
wescopeland:v2-api-comments
May 5, 2026
Merged

feat(api): add V2 JSON:API relationship endpoints for comment resources#4818
wescopeland merged 5 commits intoRetroAchievements:masterfrom
wescopeland:v2-api-comments

Conversation

@wescopeland
Copy link
Copy Markdown
Member

This PR adds V2 API relationship endpoints for Comment resources, covering the V1 API_GetComments use cases for games, achievements, and user walls.

The resources are accessible through relationship routes:

  • GET /games/{game}/comments
  • GET /achievements/{achievement}/comments
  • GET /users/{user}/wall-comments

Things worth noting:

  1. Comments are accessed exclusively via relationship routes. There is no standalone comments index.
  2. Results are default sorted by submittedAt, matching V1's ascending default.
  3. Default attributes include author display data (authorDisplayName, authorAvatarUrl, authorId), isAutomated, and permalink, so clients can render useful comment lists without requiring ?include=author.
  4. The full author relationship can still be included via ?include=author.
  5. Deleted comments and comments from banned/deleted authors are excluded.
  6. Disabled or banned user walls return 404s for both related-resource and relationship-linkage routes.

How to test this PR

# Get paginated comments for a game (50 per page)
curl --request GET \
  --url http://localhost:64000/api/v2/games/1/comments \
  --header 'X-API-Key: {redacted}'

# Get paginated comments for an achievement
curl --request GET \
  --url http://localhost:64000/api/v2/achievements/9/comments \
  --header 'X-API-Key: {redacted}'

# Get paginated wall comments for a user
curl --request GET \
  --url http://localhost:64000/api/v2/users/Scott/wall-comments \
  --header 'X-API-Key: {redacted}'

# Get comments with full author resources included
curl --request GET \
  --url 'http://localhost:64000/api/v2/games/1/comments?include=author&fields[users]=displayName,avatarUrl' \
  --header 'X-API-Key: {redacted}'

# Sort by newest comments first
curl --request GET \
  --url 'http://localhost:64000/api/v2/games/1/comments?sort=-submittedAt' \
  --header 'X-API-Key: {redacted}'

# Use custom pagination
curl --request GET \
  --url 'http://localhost:64000/api/v2/users/Scott/wall-comments?page[number]=2&page[size]=25' \
  --header 'X-API-Key: {redacted}'

@wescopeland wescopeland requested a review from a team April 25, 2026 16:56
Comment thread app/Api/V2/Comments/CommentResource.php Outdated
@wescopeland wescopeland enabled auto-merge (squash) May 5, 2026 17:06
@wescopeland wescopeland merged commit 200befd into RetroAchievements:master May 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants