Add V2 player endpoint with clean JSON response structure#113
Add V2 player endpoint with clean JSON response structure#113
Conversation
Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
ebd075e to
10c5017
Compare
Amund211
left a comment
There was a problem hiding this comment.
@copilot The branch has been rebased. Fix the route definitions in main.go to use the new helper, and fix any code quality check errors.
Prefer v2 as a suffix. E.g rename the file to player_v2.go, Rename to MakeGetPlayerV2Handler, rename to PlayerToPlayerResponseDataV2, rename to PlayerResponseV2
To start with, don't include specific gamemode stats. Only include overall. Keep it as a separate field, so specific gamemodes are easy to add later.
Verify that all code quality checks pass after the changes have been implemented
… stats only, fix route definitions Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
Fixed all requested changes in commit 32d3ae9: ✅ Route definitions: Updated to use
✅ Simplified response: Removed specific gamemode stats (solo, doubles, threes, fours), keeping only ✅ Code quality: All tests passing, build successful, no linting errors The response now only includes the overall stats field while maintaining clean extensibility for adding specific gamemodes later. |
This PR introduces a new V2 player data endpoint that provides a cleaner, more structured JSON response format compared to the existing Hypixel API-compatible endpoint.
New Endpoint
GET
/v2/player/{uuid}- Retrieve player data with modern REST API designThe new endpoint uses path parameters instead of query parameters and returns a response structure that closely mirrors the internal domain models with proper JSON field naming.
Response Format
The V2 endpoint returns a consistent response structure with simplified stats focused on overall gameplay:
{ "success": true, "player": { "queriedAt": "2024-01-01T12:00:00Z", "uuid": "01234567-89ab-cdef-0123-456789abcdef", "displayname": "PlayerName", "lastLogin": "2024-01-01T11:00:00Z", "lastLogout": "2024-01-01T11:30:00Z", "missingBedwarsStats": false, "experience": 1000, "overall": { "winstreak": 10, "gamesPlayed": 100, "wins": 80, "losses": 20, "bedsBroken": 150, "bedsLost": 30, "finalKills": 200, "finalDeaths": 25, "kills": 500, "deaths": 100 } } }Error responses follow the same pattern:
{ "success": false, "player": null, "cause": "Invalid UUID" }Implementation Details
GetAndPersistPlayerWithCachefunction as the V1 endpointBackward Compatibility
This change is fully backward compatible. The existing
/v1/playerdataendpoint remains unchanged and continues to return Hypixel API-compatible responses for existing clients like Prism overlay.Files Added
internal/ports/player_v2.go- Main handler implementationinternal/ports/player_v2_converters.go- Response structure and conversion logicinternal/ports/player_v2_test.go- Handler testsinternal/ports/player_v2_converters_test.go- Converter testsThe endpoint is now available for testing:
curl 'localhost:8123/v2/player/01234567-89ab-cdef-0123-456789abcdef'Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.