API:Options
![]() |
This page is part of the MediaWiki API documentation. |
Language: | English • 日本語 |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
MediaWiki version: | 1.20 |
Contents
Token[edit | edit source]
To change options, an options token is required. Options tokens can be obtained via action=tokens with type=options (MW 1.20+), or by using the following method:
Obtaining an options token
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <tokens optionstoken="58b54e0bab4a1d3fd3f7653af38e75cb+\" /> </api> |
Changing options[edit | edit source]
Options can be changed using action=options.
While this API is primarily intended for changing options which are registered by MediaWiki core or extensions and available on Special:Preferences, since Gerrit #I5f9ba5 you can also use it to set arbitrary user options that can be used by user-scripts or external editors.
These arbitrary options have three limits imposed on them:
- the key must start with the prefix
userjs-
- the length of the key must not be more than 255 bytes
- the key must consist only of ASCII letters, numbers, hyphens and underscores (a-z, A-Z, 0-9, _, -)
There are currently no hard limits on the length or contents of the value, nor is there a limit on the number of user options you can set at once. You can even store a complex tree of data within a user option by encoding it as a JSON string.
Parameters[edit | edit source]
token
: The token obtained in the previous request. Take care to urlencode the trailing+\
as%2B%5C
.reset
: Resets all preferences to the site defaults.change
: Pipe-separated list of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters.
- Note: Providing only names of options without equal sign (e.g.
hideminor|skin
) results in resetting them. In the case of an arbitraryuserjs-
name/value pair, the resetting results in the removal of the name/value pair; in other words - deletion.
optionname
: A name of a option which should have an optionvalue set.optionvalue
: A value of the option specified by the optionname, can contain pipe characters.
The change parameter cannot be used to set a value which contains a pipe character "|", as it is used by the API to separate options. If you need to set such a value (for example, a user signature) use an optionname & optionvalue pair.
Available Options[edit | edit source]
The following is an example list obtained with /w/api.php?action=query&format=json&meta=userinfo&uiprop=options for a Wikipedia (MW 1.24) account.
Note that most of the options listed here and defined by various MediaWiki extensions, like Echo, VisualEditor, WikiLove, Gadgets or EducationProgram, among others.
ccmeonemails
: 0cols
: 80date
: "mdy"diffonly
: 0disablemail
: 0editfont
: "default"editondblclick
: 0editsectiononrightclick
: 0enotifminoredits
: 0enotifrevealaddr
: 0enotifusertalkpages
: 1enotifwatchlistpages
: 0extendwatchlist
: "1"fancysig
: "1"forceeditsummary
: "1"gender
: "male"hideminor
: 0hidepatrolled
: 0imagesize
: 2math
: 0minordefault
: 0newpageshidepatrolled
: 0nickname
: user signaturenorollbackdiff
: 0numberheadings
: 0previewonfirst
: 0previewontop
: 1rcdays
: "14"rclimit
: "100"rows
: 25showhiddencats
: falseshownumberswatching
: 1showtoolbar
: 1skin
: "vector"stubthreshold
: 0thumbsize
: "3"underline
: 2uselivepreview
: 0usenewrc
: 0watchcreations
: 1watchdefault
: "1"watchdeletion
: 0watchlistdays
: "2"watchlisthideanons
: 0watchlisthidebots
: 0watchlisthideliu
: 0watchlisthideminor
: 0watchlisthideown
: 0watchlisthidepatrolled
: 0watchmoves
: "1"wllimit
: "300"useeditwarning
: 1prefershttps
: 1flaggedrevssimpleui
: 1flaggedrevsstable
: 0flaggedrevseditdiffs
: trueflaggedrevsviewdiffs
: falseusebetatoolbar
: 1usebetatoolbar-cgd
: 1multimediaviewer-enable
: truevisualeditor-enable
: 0visualeditor-betatempdisable
: 0visualeditor-enable-experimental
: 0visualeditor-enable-language
: 0visualeditor-hidebetawelcome
: 0wikilove-enabled
: 1mathJax
: falseecho-subscriptions-web-page-review
: trueecho-subscriptions-email-page-review
: falseep_showtoplink
: falseep_bulkdelorgs
: falseep_bulkdelcourses
: trueep_showdyk
: trueecho-subscriptions-web-education-program
: trueecho-subscriptions-email-education-program
: falseecho-notify-show-link
: trueecho-show-alert
: trueecho-email-frequency
: 0echo-email-format
: "html"echo-subscriptions-email-system
: trueecho-subscriptions-web-system
: trueecho-subscriptions-email-user-rights
: trueecho-subscriptions-web-user-rights
: trueecho-subscriptions-email-other
: falseecho-subscriptions-web-other
: trueecho-subscriptions-email-edit-user-talk
: 1echo-subscriptions-web-edit-user-talk
: trueecho-subscriptions-email-reverted
: falseecho-subscriptions-web-reverted
: trueecho-subscriptions-email-article-linked
: falseecho-subscriptions-web-article-linked
: falseecho-subscriptions-email-mention
: falseecho-subscriptions-web-mention
: trueecho-subscriptions-web-edit-thank
: trueecho-subscriptions-email-edit-thank
: falseecho-subscriptions-web-flow-discussion
: trueecho-subscriptions-email-flow-discussion
: falsegettingstarted-task-toolbar-show-intro
: trueuls-preferences
: ""language
: "en"variant-gan
: "gan"variant-iu
: "iu"variant-kk
: "kk"variant-ku
: "ku"variant-shi
: "shi"variant-sr
: "sr"variant-tg
: "tg"variant-uz
: "uz"variant-zh
: "zh"searchNs0
: truesearchNs1
: falsesearchNs2
: "1"searchNs3
: falsesearchNs4
: "1"searchNs5
: falsesearchNs6
: "1"searchNs7
: falsesearchNs8
: "1"searchNs9
: falsesearchNs10
: "1"searchNs11
: falsesearchNs12
: "1"searchNs13
: falsesearchNs14
: "1"searchNs15
: falsesearchNs100
: falsesearchNs101
: falsesearchNs108
: falsesearchNs109
: falsesearchNs118
: falsesearchNs119
: falsesearchNs446
: falsesearchNs447
: falsesearchNs710
: falsesearchNs711
: falsesearchNs828
: falsesearchNs829
: falsegadget-teahouse
: ""gadget-ReferenceTooltips
: 1gadget-DRN-wizard
: 1gadget-charinsert
: 1gadget-refToolbar
: 1gadget-mySandbox
: 1betafeatures-vector-compact-personal-bar
: "0"cirrussearch-default
: "0"pagetriage-lastuse
: timestamppopups
: "0"timecorrection
: "ZoneInfo|60|Europe/London"uls-compact-links
: "0"usecodeeditor
: "1"userjs-arbitraryKeyName
: arbitrary valuewatchlisttoken
: token
Example[edit | edit source]
Note: In this example, all parameters are passed in a GET request for the sake of simplicity. However, action=options requires POST requests; GET requests will cause an error. Changing a single option
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api options="success" /> |
Resetting all options and changing a single option
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api options="success" /> |
Changing three options
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api options="success" /> |
Possible errors[edit | edit source]
In addition to the usual stuff:
Code | Info |
---|---|
notloggedin | Anonymous users cannot change preferences |
nochanges | No changes were requested |
See also[edit | edit source]
- API:Meta#userinfo / ui for reading existing options.