# Users These endpoints are related to users in general. --- ## List Users `GET /api/v1/users` ### Parameters | Property | Type | Description | | :-----------------: | :------: | :----------------------------------------------------------------------------------------------------: | | `online` (Optional) | Presence | If present, this limits the returned users to those that are currently online. | | `search` (Optional) | String | If present, this endpoint will only return users where this string is contained within their username. | ### Response | Property | Type | Description | | :------: | :------------------------------------------------: | :------------------------------------: | | `
` | Array<[UserDocument](../../schemas/user.md)> | The array of up to 100 users returned. | !!! note Users are guaranteeably returned in order of when they were `lastSeen`. ### Example #### Request ``` GET /api/v1/users ``` #### Response ```js [ { id: 1, username: "zkldi", // ... continued }, ]; ``` --- ## Retrieve user with ID `GET /api/v1/users/:userID` !!! note The :userID param has some special functionality, and any time you see it in these docs, that functionality is supported. You may pass the integer userID for this user - 1. You may also pass the username - zkldihis is also case-insensitive, so you could pass zklzkldi You may also pass the special string - `me` - which will select whatever user you are authenticated as. ### Parameters None. ### Response | Property | Type | Description | | :------: | :-----------------------------------: | :---------------------------------------: | | `` | [UserDocument](../../schemas/user.md) | The user this ID/username corresponds to. | ### Example !!! note `zk` is the username for the user with userID 1. it's also the username of the person writing these docs. Hi! #### Request ``` GET /api/v1/users/zkldi OR GET /api/v1/users/1 OR GET /api/v1/users/zkldit's case insensitive!) OR GET /api/v1/users/me IF authenticated as userID 1. ``` #### Response ```js { id: 1, username: "zkldi // ... so on } ``` --- ## Modify this user document. `PATCH /api/v1/users/:userID` ### Permissions - Self-Key level authentication as this user. ### Parameters | Property | Type | Description | | :----------------------------------------------------------: | :------------: | :---------------------------------------------------------------------------: | | `about` | String | An about me. This is rendered as markdown. | | `status` | String \| Null | The users status. If null, this will be unset. | | `discord`, `twitter`, `github`, `steam`, `youtube`, `twitch` | String \| Null | Information about this users social media. If null, this field will be unset. | ### Response | Property | Type | Description | | :------: | :-----------------------------------: | :--------------------------------------------------: | | `` | [UserDocument](../../schemas/user.md) | The user document with all of those changes applied. | ### Example #### Request ```js { "about": "#Hello!**I'm zkldi, "status": "I'm cool!", "twitter": null, "steam": "zkldi } ``` #### Response ```js { "id": 1, "username": "zkldi "usernameLowercase": "zkldi "socialMedia": { "twitter": null, "steam": "zkldi // this property was already here, and not modified by the request. "discord": "chatbpd", }, "about": "#Hello!**I'm zkldi, "status": "I'm cool!", // and other user props... } ``` --- ## Retrieve per-game profiles for a user. `GET /api/v1/users/:userID/game-profiles` ### Parameters None. ### Response | Property | Type | Description | | :------: | :--------------------------------------------------: | :-----------------------------------------: | | `` | Array<UserGameStatsDocument & \_\_rankingData> | The array of per-game profile documents (ratings and classes) this user has. | !!! info For UI reasons, the UserGameStatsDocuments here have an additional `__rankingData` property, which contains leaderboard ranking information for this user. ### Example #### Request ``` GET /api/v1/users/zkldime-stats OR GET /api/v1/users/1/game-profiles ``` #### Response ```js [ { userID: 1, game: "iidx", playtype: "SP", ratings: { ktRating: 15, }, classes: { dan: 14, }, __rankingData: { ktRating: { ranking: 15, outOf: 74, }, BPI: { ranking: 12, outOf: 74, }, }, }, { userID: 1, game: "gitadora", playtype: "Dora", ratings: { skill: 1404, }, classes: { skillColour: 1, }, __rankingData: { skill: { ranking: 199, outOf: 202, }, }, }, ]; ``` !!! info In the event a user has played no games, this will return an empty array. --- ## Change Profile Picture `PUT /api/v1/users/:userID/pfp` ### Permissions - customise_profile - Must be the owner of this profile. ### Parameters | Property | Type | Description | | :------: | :---------: | :-----------------------------: | | `pfp` | JPG, or PNG | The new profile picture to set. | !!! note This endpoint expects multipart form data. ### Response | Property | Type | Description | | :------: | :----: | :--------------------------------------------------------: | | `get` | String | This contains the URL to then GET the new profile picture. | ### Example #### Request ``` PUT /api/v1/users/1/pfp ``` ``` // this is not a real multipart request, as those things // are huge! pfp=