Wiki source code of Icon REST API
Last modified by Eleni Cojocariu on 2026/08/25 16:23
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Two REST resources report what the icons of an [[Icon Theme>>doc:documentation.xs.admin.icons.icon-themes.WebHome]] are made of, without rendering them. Both answer ##application/xml## and ##application/json##, and both take the ##name## query parameter once per icon asked for. | ||
| 2 | |||
| 3 | |=Resource|=Reports the icons of | ||
| 4 | |##GET /rest/wikis/{wiki}/iconThemes/icons?name={name}##|The theme the wiki uses, or the icon set built into the distribution when it has none. | ||
| 5 | |##GET /rest/wikis/{wiki}/iconThemes/{theme}/icons?name={name}##|The theme named in the path. | ||
| 6 | |||
| 7 | The answer holds one ##icon## per name the theme maps and one ##missingIcons## entry per name it does not, in the order they were asked for. An icon carries its ##name##, the ##iconSetName## it came from and the ##iconSetType##, then ##cssClass## on a font theme or ##url## on an image theme: | ||
| 8 | |||
| 9 | {{code language="bash"}} | ||
| 10 | # Three names, of which one is not in the theme. | ||
| 11 | curl -H 'Accept: application/json' \ | ||
| 12 | 'http://localhost:8080/xwiki/rest/wikis/xwiki/iconThemes/icons?name=add&name=home&name=unknown' | ||
| 13 | {{/code}} | ||
| 14 | |||
| 15 | {{code language="json"}} | ||
| 16 | {"icons":[ | ||
| 17 | {"name":"add","iconSetType":"FONT","iconSetName":"Font Awesome","cssClass":"fa fa-plus","url":null}, | ||
| 18 | {"name":"home","iconSetType":"FONT","iconSetName":"Font Awesome","cssClass":"fa fa-home","url":null}], | ||
| 19 | "missingIcons":["unknown"]} | ||
| 20 | {{/code}} | ||
| 21 | |||
| 22 | The same names against an image theme report a ##url## instead: | ||
| 23 | |||
| 24 | {{code language="bash"}} | ||
| 25 | curl -H 'Accept: application/json' \ | ||
| 26 | 'http://localhost:8080/xwiki/rest/wikis/xwiki/iconThemes/Silk/icons?name=home' | ||
| 27 | {{/code}} | ||
| 28 | |||
| 29 | {{code language="json"}} | ||
| 30 | {"icons":[{"name":"home","iconSetType":"IMAGE","iconSetName":"Silk","cssClass":null, | ||
| 31 | "url":"http://localhost:8080/xwiki/resources/icons/silk/house.png?cache-version=1785156334000"}], | ||
| 32 | "missingIcons":[]} | ||
| 33 | {{/code}} | ||
| 34 | |||
| 35 | == Status codes == | ||
| 36 | |||
| 37 | |=Code|=When | ||
| 38 | |200|The request was answered, whether or not every name asked for was found. | ||
| 39 | |404|The wiki does not exist, or the theme named in the path does not. | ||
| 40 | |500|The theme could not be read. |