Wiki source code of REST API endpoints for user information
Last modified by Pierre Jeanjean on 2026/03/23 17:04
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{toc/}} | ||
| 2 | |||
| 3 | = Requirements = | ||
| 4 | |||
| 5 | * Obtain public user information of a given user, such as display name, email address and avatar, | ||
| 6 | * Access user preferences if visible (//i.e.//, logged-in user access their own preferences, or are an administrator), | ||
| 7 | * Quick access to user information and preferences for the currently logged-in user. | ||
| 8 | |||
| 9 | = Definition = | ||
| 10 | |||
| 11 | == Model == | ||
| 12 | |||
| 13 | {{code language="xml"}} | ||
| 14 | <complexType name="UserSummary"> | ||
| 15 | <complexContent> | ||
| 16 | <extension base="xwiki:LinkCollection"> | ||
| 17 | <sequence> | ||
| 18 | <element name="id" type="string"></element> | ||
| 19 | <element name="firstName" type="string"></element> | ||
| 20 | <element name="lastName" type="string"></element> | ||
| 21 | <element name="avatarUrl" type="string"></element> | ||
| 22 | <element name="global" type="boolean"></element> | ||
| 23 | <element name="xwikiRelativeUrl" type="string"></element> | ||
| 24 | <element name="xwikiAbsoluteUrl" type="string"></element> | ||
| 25 | </sequence> | ||
| 26 | </extension> | ||
| 27 | </complexContent> | ||
| 28 | </complexType> | ||
| 29 | |||
| 30 | <complexType name="UserPreferences"> | ||
| 31 | <sequence> | ||
| 32 | <element name="displayHiddenDocuments" type="boolean"></element> | ||
| 33 | <element name="underlineLinks" type="string"></element> | ||
| 34 | <element name="timezone" type="string"></element> | ||
| 35 | <element name="editor" type="string"></element> | ||
| 36 | <element name="advanced" type="boolean"></element> | ||
| 37 | </sequence> | ||
| 38 | </complexType> | ||
| 39 | |||
| 40 | <complexType name="User"> | ||
| 41 | <complexContent> | ||
| 42 | <extension base="xwiki:UserSummary"> | ||
| 43 | <sequence> | ||
| 44 | <element name="displayName" type="string"></element> | ||
| 45 | <element name="company" type="string"></element> | ||
| 46 | <element name="about" type="string"></element> | ||
| 47 | <element name="email" type="string"></element> | ||
| 48 | <element name="phone" type="string"></element> | ||
| 49 | <element name="address" type="string"></element> | ||
| 50 | <element name="blog" type="string"></element> | ||
| 51 | <element name="blogFeed" type="string"></element> | ||
| 52 | <element name="preferences" type="xwiki:UserPreferences" minOccurs="0"></element> | ||
| 53 | </sequence> | ||
| 54 | </extension> | ||
| 55 | </complexContent> | ||
| 56 | </complexType> | ||
| 57 | |||
| 58 | <element name="users"> | ||
| 59 | <complexType> | ||
| 60 | <sequence> | ||
| 61 | <element name="userSummary" type="xwiki:UserSummary" minOccurs="0" maxOccurs="unbounded"></element> | ||
| 62 | </sequence> | ||
| 63 | </complexType> | ||
| 64 | </element> | ||
| 65 | |||
| 66 | <element name="user" type="xwiki:User"></element> | ||
| 67 | {{/code}} | ||
| 68 | |||
| 69 | == Endpoints == | ||
| 70 | |||
| 71 | All the endpoints go through a specific wiki, which is necessary to authenticate the user in a wiki before performing the request. | ||
| 72 | |||
| 73 | === /wikis/{wikiName}/user[?preferences~={true,false}] === | ||
| 74 | |||
| 75 | * **HTTP Method:** GET | ||
| 76 | ** **Media types:** | ||
| 77 | *** application/xml (User element) | ||
| 78 | ** **Query parameters:** | ||
| 79 | *** ##preferences##: also return the preferences. Disabled by default. | ||
| 80 | ** **Description:** The user performing the request | ||
| 81 | ** **Status codes:** | ||
| 82 | *** 200: If the request was successful. | ||
| 83 | *** 401: If the user is not authorized on {wikiName}. | ||
| 84 | |||
| 85 | === /wikis/{wikiName}/users/{userId}[?preferences~={true,false}] === | ||
| 86 | |||
| 87 | * **HTTP Method:** GET | ||
| 88 | ** **Media types:** | ||
| 89 | *** application/xml (User element) | ||
| 90 | ** **Query parameters:** | ||
| 91 | *** ##preferences##: also return the preferences. Disabled by default and might require specific rights. | ||
| 92 | ** **Description:** The user that corresponds to {userId} when resolved from {wikiName}. The format of {userId} is intentionally left unspecified and depends on the available resolvers on the instance. For example, with a user stored as a document ##XWiki.someUser## on the default wiki, {userId} could be either ##someUser## or one of the more technical syntaxes listed in the [[User API documentation>>doc:extensions:Extension.User Module.API.WebHome||anchor="HBridge"]]. | ||
| 93 | ** **Status codes:** | ||
| 94 | *** 200: If the request was successful. | ||
| 95 | *** 401: If the user is not authorized on {wikiName} or does not have access to the requested user's profile. | ||
| 96 | *** 404: If the requested user could not be found. |