API:Query - Lists
From MediaWiki.org
| This page is part of the MediaWiki API documentation. |
Lists differ from properties in two aspects - instead of appending data to the elements in the pages element, each list has its own separated branch in the query element. Also, list output is limited by number of items, and may be continued using the query-continue element. Unless indicated otherwise, modules listed on this page can be used as generators.
[edit] Limits
All list queries return a limited number of results. This limit is 10 by default, and can be set as high as 500 for regular users, or 5000 for users with the apihighlimits right (typically bots and sysops). Some modules impose stricter limits under certain conditions. If you're not sure which limit applies to you and just want as many results as possible, set the limit to max. In that case, a <limits> element will be returned, specifying the limits used.
Errors
If you set the limit to a value higher than the maximum, an error will be thrown, which looks like:
- code: aplimit
- info: aplimit may not be over 500 (set to 1000) for users
(ap can be replaced with any other module prefix)
Example Getting the maximum amount of revisions with content and backlinks for en:Winnipeg, Manitoba
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="6842860" ns="0" title="Winnipeg, Manitoba"> <revisions> <rev>#REDIRECT [[Winnipeg]] {{R from Canadian settlement name}}</rev> <rev>#REDIRECT [[Winnipeg]]</rev> </revisions> </page> </pages> <backlinks> <bl pageid="924" ns="0" title="A. A. Milne" /> <bl pageid="5959" ns="0" title="Canadian Pacific Railway" /> <!-- ... --> <bl pageid="708754" ns="2" title="User:ChrisErbach" /> <bl pageid="802133" ns="2" title="User:Earl Andrew/54nl) 80X" /> </backlinks> </query> <limits revisions="50" backlinks="500" /> <query-continue> <backlinks blcontinue="0|Winnipeg,_Manitoba|994168" /> </query-continue> </api>
[edit] allpages / ap
Returns a list of pages in a given namespace, ordered by page title.
Parameters
apfrom: Start listing at this title. The title need not existapprefix: Only list titles that start with this valueapnamespace: The namespace to enumerate. You can only enumerate one namespace at a time. By default, the main namespace will be enumeratedapfilterredir: How to filter redirectsall: List all pages regardless of their redirect flag (default)redirects: Only list redirectsnonredirects: Don't list redirects
apfilterlanglinks: How to filter based on whether a page has language linksall: List all pages regardless of whether they have language links (default)withlanglinks: Only list pages with language linkswithoutlanglinks: Only list pages without language links
apminsize: Only list pages that are at least this many bytes in sizeapmaxsize: Only list pages that are at most this many bytes in sizeapprtype: Only list pages that have been protected from this type of actionedit: Only list edit-protected pagesmove: Only list move-protected pages- Other wikis may allow for more kinds of protection and will therefore provide more options here
apprlevel: Only list pages that have been protected at this level. Cannot be used withoutapprtypeautoconfirmed: Only autoconfirmed users can edit/move/whateversysop: Only sysops can edit/move/whatever- Empty: Everyone can edit/move/whatever
- Other wikis may allow protection on more levels and will therefore provide more options here
aplimit: Maximum amount of pages to list (10 by default)apdir: In which direction to listascending: List from A to Z (default)descending: List from Z to A
Example Show a list of first 5 pages starting from "Kre"
<api> <query-continue> <allpages apfrom="Kreatel" /> </query-continue> <query> <allpages> <p pageid="1756320" ns="0" title="Kre'fey" /> <p pageid="3361042" ns="0" title="Kreab" /> <p pageid="288613" ns="0" title="Kreacher" /> <p pageid="812540" ns="0" title="Kreamer, PA" /> <p pageid="133750" ns="0" title="Kreamer, Pennsylvania" /> </allpages> </query> </api>
Possible errors
- code: apparams
- info: Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator
- code: apparams
- info: prlevel may not be used without prtype
[edit] alllinks / al
Returns a list of (unique) links to pages in a given namespace starting ordered by link title.
Parameters
alcontinue: Used to continue a previous requestalfrom: Start listing at this title. The title need not existalprefix: Only list links to titles that begin with this valuealnamespace: The namespace to enumerate. You can only enumerate one namespace at a time. By default, the main namespace will be enumeratedalunique: If set, multiple links to the same title will be listed only once. Cannot be used in generator mode or withalprop=idsallimit: Maximum amount of links to list (10 by default)alprop: Which properties to returnids: Page IDs of the linking pages. Cannot be used together withaluniquetitle: Link titles (default)
Example List all links to talk pages whose name starts with Talk:API
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <alllinks alcontinue="APILAS|5484123" /> </query-continue> <query> <alllinks> <l fromid="3633229" ns="1" title="Talk:API" /> <l fromid="14912955" ns="1" title="Talk:API-Calculus" /> <l fromid="15131143" ns="1" title="Talk:API5" /> <l fromid="15165243" ns="1" title="Talk:API5" /> <l fromid="8327984" ns="1" title="Talk:APIIC Tower" /> <l fromid="14109257" ns="1" title="Talk:APIIC Tower" /> <l fromid="14177354" ns="1" title="Talk:APIIC Tower" /> <l fromid="14180196" ns="1" title="Talk:APIIC Tower" /> <l fromid="6760965" ns="1" title="Talk:APIIT" /> <l fromid="12229053" ns="1" title="Talk:APILAS" /> </alllinks> </query> </api>
Possible errors
- code: alparams
- info: alllinks cannot be used as a generator in unique links mode
- code: alparams
- info: alllinks cannot return corresponding page ids in unique links mode
- This happens when you use
aluniqueandalprop=idstogether
- This happens when you use
- info: alllinks cannot return corresponding page ids in unique links mode
- code: alparams
- info: alcontinue and alfrom cannot be used together
[edit] allcategories / ac
Get a list of all categories. This differs from list=allpages&alnamespace=14 in that empty categories aren't listed, and categories without description pages are.
Parameters
acfrom: Start listing at this category title. The category need not existacprefix: Only list category titles starting with this valueaclimit: Maximum amount of categories to list (10 by default)acdir: In which direction to listascending: List from A to Z (default)descending: List from Z to A
Example List the first 10 categories whose name starts with "List of"
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <allcategories acfrom="List of Baptist sub-denominations" /> </query-continue> <query> <allcategories> <c>List of "M" series military vehicles</c> <c>List of Alternative Rock Groups</c> <c>List of Alumni of Philippine Science High School</c> <c>List of American artists</c> <c>List of Anglicans and Episcopalians</c> <c>List of Arizona Reptiles</c> <c>List of Artists by record label</c> <c>List of Australian Anglicans</c> <c>List of Bahá'ís</c> <c>List of Balliol College people</c> </allcategories> </query> </api>
Possible errors
None
[edit] allusers / au
Get a list of registered users, ordered by username. This module cannot be used as a generator.
Parameters
aufrom: Start listing at this username. The user name need not existauprefix: Only list usernames starting with this valueaugroup: Only list users in this groupbotsysopbureaucrat- Any other group that is defined on the wiki. This is different for every wiki; see the API help or action=paraminfo for a list of possible values
auprop: Which properties to returneditcount: The number of edits the user has madegroups: A list of all groups the user is inregistration: The date and time of the user's registration
aulimit: Number of users to list (10 by default)
Example Show a list of first 5 sysops
<api> <query-continue> <allusers aufrom="A Train" /> </query-continue> <query> <allusers> <u name="(aeropagitica)" /> <u name="-- April" /> <u name="17Drew" /> <u name="23skidoo" /> <u name="A Man In Black" /> </allusers> </query> </api>
Possible errors
None
[edit] allimages / ai
Returns a list of all images, ordered by image title.
Parameters
aifrom: Start listing at this title. The title need not existaiprefix: Only list titles that start with this valueaiminsize: Only list images that are at least this many bytes in sizeaimaxsize: Only list images that are at most this many bytes in sizeailimit: Maximum amount of images to list (10 by default)aidir: In which direction to listascending: List from A to Z (default)descending: List from Z to A
aisha1: Only list images with this SHA-1 hash. These hashes are supposed to be unique, so you can use this to track duplicates. If you run into two different images with the same hash, you should start playing the lotteryaisha1base36: Same asaisha1, but in base 36aiprop: Which properties to gettimestamp: The time and date the most recent version of the image was uploaded (default)user: The name of the user who uploaded the most recent versioncomment: The edit comment for the latest uploadurl: The URL to the most recent version of the image (default)size: The image's size in bytesdimensions: The image's width and height in pixelsmime: The image's MIME typesha1: The image's SHA-1 hashmetadata: Image metadata, if available
Example Show a list of first 5 images whose name starts with "Albert"
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <allimages aifrom="Albert-einstein-biography-pictures.jpg" /> </query-continue> <query> <allimages> <img name="Albert's_Real_Jamaican_Foods.JPG" width="1024" height="768" mime="image/jpeg" /> <img name="Albert-Cashier.jpg" width="150" height="220" mime="image/jpeg" /> <img name="Albert-Park-Brisbane-1.jpg" width="936" height="695" mime="image/jpeg" /> <img name="Albert-Park-Brisbane-2.jpg" width="830" height="525" mime="image/jpeg" /> <img name="Albert-Park-railway-station.jpg" width="640" height="480" mime="image/jpeg" /> </allimages> </query> </api>
[edit] backlinks / bl
Lists pages that link to a given page, similar to Special:Whatlinkshere. Ordered by linking page title.
Parameters
bltitle: List pages linking to this title. The title need not existblnamespace: Only list pages in these namespacesblfilterredir: How to filter redirectsall: List all pages regardless of their redirect flag (default)redirects: Only list redirectsnonredirects: Don't list redirects
bllimit: Maximum amount of pages to list (10 by default). Maximum limit is halved ifblredirectis setblredirect: If set, pages linking tobltitlethrough a redirect will also be listed. See below for more detailed informationblcontinue: Used to continue a previous request
Example
Find all pages that redirect to en:Main Page.
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <backlinks blcontinue="0|Main_Page|668228" /> </query-continue> <query> <backlinks> <bl pageid="217224" ns="0" title="Mainpage" /> <bl pageid="217225" ns="0" title="Main page" /> <bl pageid="234094" ns="0" title="Main Path" /> <bl pageid="485188" ns="4" title="Wikipedia:Main page" /> <bl pageid="485697" ns="0" title="Main Page/" /> </backlinks> </query> </api>
Links through redirects
When the blredirect parameter is set, this module behaves slightly differently. bllimit applies to both levels separately: if e.g. bllimit=10, at most 10 first-level pages (pages that link to bltitle) and 10 second-level pages (pages that link to bltitle through a redirect) will be listed. Continuing queries also works differently, as displayed in the following example.
Get a list of pages linking to Application programming interface
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <backlinks blcontinue="0|Application_programming_interface|1191|42661" /> </query-continue> <query> <backlinks> <bl pageid="1191" ns="0" title="API" redirect=""> <redirlinks> <bl pageid="2807" ns="0" title="Active Directory" /> <bl pageid="4355" ns="0" title="BBC Micro" /> <bl pageid="8146" ns="0" title="DOS" /> <bl pageid="9101" ns="0" title="Device driver" /> <bl pageid="15215" ns="0" title="Internet Explorer" /> <bl pageid="29090" ns="0" title="Software testing" /> <bl pageid="30237" ns="0" title="Tcl" /> <bl pageid="32612" ns="0" title="Virtual reality" /> <bl pageid="34203" ns="0" title="XFS" /> <bl pageid="37545" ns="0" title="Palm OS" /> </redirlinks> </bl> <bl pageid="2141" ns="0" title="Atari ST" /> <bl pageid="2323" ns="0" title="Amdahl's law" /> <bl pageid="2581" ns="0" title="Apache HTTP Server" /> <bl pageid="2753" ns="0" title="AutoCAD" /> <bl pageid="3105" ns="0" title="AmigaOS" /> <bl pageid="3130" ns="0" title="Advanced Power Management" /> <bl pageid="4440" ns="0" title="Berkeley Software Distribution" /> <bl pageid="4473" ns="0" title="BIOS" /> <bl pageid="4706" ns="0" title="Berkeley DB" /> </backlinks> </query> </api>
When continuing this request, we see that there are more pages linking to API, and that the other first-level pages are listed again. To progress beyond Berkeley DB, we have to query-continue again and again until we've had all links to API (or increase bllimit, of course). Continuing the previous request
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <backlinks blcontinue="0|Application_programming_interface|1191|56891" /> </query-continue> <query> <backlinks> <bl pageid="1191" ns="0" title="API" redirect=""> <redirlinks> <bl pageid="42661" ns="0" title="Myth (computer game series)" /> <bl pageid="42750" ns="0" title="Enterprise JavaBean" /> <bl pageid="45308" ns="0" title="XPath" /> <bl pageid="46628" ns="0" title="Automated teller machine" /> <bl pageid="51172" ns="0" title="DNIX" /> <bl pageid="51746" ns="0" title="Cisco Systems" /> <bl pageid="53076" ns="0" title="Darwin (operating system)" /> <bl pageid="53252" ns="0" title="Liberty BASIC" /> <bl pageid="55519" ns="0" title="NeWS" /> <bl pageid="55888" ns="0" title="Trusted system" /> </redirlinks> </bl> <bl pageid="2141" ns="0" title="Atari ST" /> <bl pageid="2323" ns="0" title="Amdahl's law" /> <bl pageid="2581" ns="0" title="Apache HTTP Server" /> <bl pageid="2753" ns="0" title="AutoCAD" /> <bl pageid="3105" ns="0" title="AmigaOS" /> <bl pageid="3130" ns="0" title="Advanced Power Management" /> <bl pageid="4440" ns="0" title="Berkeley Software Distribution" /> <bl pageid="4473" ns="0" title="BIOS" /> <bl pageid="4706" ns="0" title="Berkeley DB" /> </backlinks> </query> </api>
Possible errors
- code: blbad_title_count
- info: The backlinks query requires one title to start
- This happens when you use
titlesinstead ofbltitle(this usage is deprecated) and specify multiple titles
- This happens when you use
- info: The backlinks query requires one title to start
- code: bl_badcontinue
- info: Invalid continue param. You should pass the original value returned by the previous query
[edit] blocks / bk
List all blocks, à la Special:Ipblocklist. This module cannot be used as a generator.
Parameters
bkstart: The timestamp to start listing frombkend: The timestamp to end listing atbkdir: Direction to list in.older: List newest blocks first (default). Note: bkstart has to be later than bkend.newer: List oldest blocks first. Note: bkstart has to be before bkend.
bkids: Only list blocks with these IDsbkusers: Only list blocks of these usersbkip: List all blocks, including range blocks, that apply to this IP address. You can also specify a CIDR range here, in which case only blocks applying to the entire range will be listed. Cannot be used together withbkusers. CIDR ranges broader than /16 are not allowed, as range blocks cannot cross /16 boundariesbklimit: Maximum number of blocks to list (10 by default)bkprop: A pipe-separated list of properties to get. The default value is id|user|by|timestamp|expiry|reason|flagsid: The ID of the block (default)user: The IP address or username that was blocked (default)by: The user who applied the block (default)timestamp: When the block was applied (default)expiry: When the block will expire (default)reason: The reason for the block (default)range: If an IP range was blocked, the first and last IP the block applies toflags: Flags that apply to the block (default)automatic: Automatically blocked because of an autoblock (see also action=block)anononly: Only anonymous edits are blockednocreate: Account creation is disabledautoblock: Automatic blocking is enabled for this blocknoemail: Sending e-mail through the wiki is disabled for the blocked userhidden: This block is hidden from Special:Ipblocklist. Only users with oversight permissions can see these blocks.
Example Listing the 3 most recent blocks
<?xml version="1.0" encoding="utf-8"?> <api> <query> <blocks> <block id="4" user="123.123.0.0/16" userid="0" by="Catrope" byuserid="1" timestamp="2007-11-23T11:44:41Z" expiry="infinity" reason="Bad proxies; these folks will just have to register" rangestart="123.123.0.0" rangeend="123.123.255.255" anononly="" /> <block id="2" user="25.50.100.200" userid="0" by="Catrope" byuserid="1" timestamp="2007-11-23T11:37:28Z" expiry="infinity" reason="Intimidating behaviour/harassment" rangestart="25.50.100.200" rangeend="25.50.100.200" anononly="" nocreate="" /> <block id="1" user="Vandal01" userid="3" by="Catrope" byuserid="1" timestamp="2007-11-23T11:36:40Z" expiry="2007-12-23T11:36:40Z" reason="Spamming links to external sites" rangestart="0.0.0.0" rangeend="0.0.0.0" nocreate="" autoblock="" noemail="" /> </blocks> </query> </api>
Possible errors
None.
[edit] categorymembers / cm
List of pages that belong to a given category, ordered by page sort title.
Parameters
cmtitle: The category to enumeratecmnamespace: Only list pages in these namespacescmstart: Start listing at this timestamp. Can only be used withcmsort=timestampcmend: End listing at this timestamp. Can only be used withcmsort=timestampcmstartsortkey: Start listing at this sortkey. Can only be used withcmsort=sortkeycmendsortkey: End listing at this sortkey. Can only be used withcmsort=sortkeycmsort: Property to sort bysortkey: The article's sort key (default)timestamp: The time the article was added to the category
cmdir: Direction to sort inasc: From A to Z or from 2002 to 2009. Note: cmstart has to be before cmenddesc: From Z to A or from 2009 to 2002 Note: cmstart has to be later than cmend
cmlimit: Maximum amount of pages to list (10 by default)cmprop: Which properties to getids: page ID (default)title: page title (default)sortkey: sort keytimestamp: time and date the article was added to the category
cmcontinue: Used to continue a previous request
Example Get the 10 articles most recently added to Category:Physics
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <categorymembers cmcontinue="Magnetic levitation|" /> </query-continue> <query> <categorymembers> <cm pageid="1653925" ns="100" title="Portal:Physics" /> <cm pageid="22939" ns="0" title="Physics" /> <cm pageid="3445246" ns="0" title="Glossary of classical physics" /> <cm pageid="25856" ns="0" title="Radiation" /> <cm pageid="16212316" ns="14" title="Category:Gravitation" /> <cm pageid="24489" ns="0" title="List of basic physics topics" /> <cm pageid="4412382" ns="0" title="Friability" /> <cm pageid="1111581" ns="0" title="Reaction (physics)" /> <cm pageid="16178400" ns="0" title="Normal (optics)" /> <cm pageid="14476384" ns="0" title="Mass versus weight" /> </categorymembers> </query> </api>
Possible errors
- code: cmnotitle
- info: The cmtitle parameter is required
- code: cminvalidcategory
- info: The category name you entered is not valid
- code: cmbadcontinue
- info: Invalid continue param. You should pass the original value returned by the previous query
[edit] embeddedin / ei
List pages that include a certain page.
Parameters
eititle: List pages including this title. The title need not existeinamespace: Only list pages in these namespaceseifilterredir: How to filter redirectsall: List all pages regardless of their redirect flag (default)redirects: Only list redirectsnonredirects: Don't list redirects
eilimit: Maximum amount of pages to list (10 by default)eicontinue: Used to continue a previous request
Example
Find all pages that embed en:template:Stub.
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <embeddedin eicontinue="10|Stub|16324457" /> </query-continue> <query> <embeddedin> <ei pageid="7997510" ns="0" title="Maike Evers" /> <ei pageid="10357370" ns="0" title="ConnectU" /> <ei pageid="11347592" ns="0" title="Oliver B. Greene" /> <ei pageid="11886644" ns="0" title="Godfrey Burley Group" /> <ei pageid="14882500" ns="0" title="Contra principia negantem disputari non potest" /> </embeddedin> </query> </api>
Possible errors
- code: eibad_title_count
- info: The embeddedin query requires one title to start
- This happens when you use
titlesinstead ofeititle(this usage is deprecated) and specify multiple titles
- This happens when you use
- info: The embeddedin query requires one title to start
- code: ei_badcontinue
- info: Invalid continue param. You should pass the original value returned by the previous query
[edit] exturlusage / eu
Get a list of pages that link to a certain URL, à la Special:Linksearch
Parameters
euquery: The URL to search for, without the protocol.*can be used as a wildcard. If you omiteuquery(not just leave it empty), all external links will be listed, andeuprotocolwill be ignoredeuprotocol: Protocol of the URL- The options for this parameter vary per wiki. By default, the options are
http(default),https,ftp,irc,gopher,telnet,nntp,worldwind,mailto,news
- The options for this parameter vary per wiki. By default, the options are
eunamespace: Only list links from pages in these namespaceseulimit: Maximum amount of pages to list (10 by default)euprop: Which properties to getids: Page ID of the linking pagetitle: Title of the linking pageurl: URL being linked to
euoffset: Used for continuing a previous request
Example Get a list of pages linking to slashdot.org
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <exturlusage euoffset="11" /> </query-continue> <query> <exturlusage> <eu pageid="533948" ns="2" title="User:Peter Ellis" url="http://slashdot.org" /> <eu pageid="3274" ns="2" title="User:Alexdb" url="http://slashdot.org/" /> <eu pageid="36471" ns="2" title="User:Joao" url="http://slashdot.org/" /> <eu pageid="246276" ns="2" title="User:Pablo Mayrgundter" url="http://slashdot.org/" /> <eu pageid="352958" ns="2" title="User:Yckoh" url="http://slashdot.org" /> <eu pageid="417592" ns="2" title="User:Geekboy" url="http://slashdot.org" /> <eu pageid="439013" ns="4" title="Wikipedia:Village pump/January 2004 archive 5" url="http://slashdot.org" /> <eu pageid="512464" ns="2" title="User:Vaceituno" url="http://slashdot.org" /> <eu pageid="527793" ns="4" title="Wikipedia:New user log/archive1" url="http://slashdot.org" /> <eu pageid="592017" ns="5" title="Wikipedia talk:Announcements/Archive 1" url="http://slashdot.org/" /> </exturlusage> </query> </api>
[edit] imageusage / iu
List of pages that include a given image. Ordered by page title.
Parameters
iutitle: List pages using this image. The image need not existiunamespace: Only list pages in these namespacesiufilterredir: How to filter redirectsall: List all pages regardless of their redirect flag (default)redirects: Only list redirectsnonredirects: Don't list redirects
iulimit: Maximum amount of pages to list (10 by default)iuredirect: If set, pages linking toiutitlethrough a redirect will also be listed. See the documentation for list=backlinks for more detailed informationiucontinue: Used to continue a previous request
Example Find all pages that use Image:Albert Einstein Head.jpg
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <imageusage iucontinue="6|Albert_Einstein_Head.jpg|45864" /> </query-continue> <query> <imageusage> <iu pageid="736" ns="0" title="Albert Einstein" /> <iu pageid="2201" ns="0" title="Aage Niels Bohr" /> <iu pageid="12432" ns="0" title="Genius" /> <iu pageid="14400" ns="0" title="History of science" /> <iu pageid="34523" ns="0" title="Zhu Shijie" /> </imageusage> </query> </api>
Possible errors
- code: iubad_title_count
- info: The imageusage query requires one title to start
- This happens when you use
titlesinstead ofiutitle(this usage is deprecated) and specify multiple titles
- This happens when you use
- info: The imageusage query requires one title to start
- code: iu_badcontinue
- info: Invalid continue param. You should pass the original value returned by the previous query
- code: iubad_image_title
- info: The title for imageusage query must be an image
[edit] logevents / le
Get a list of all logged events, à la Special:Log. This module cannot be used as a generator.
Parameters
leprop: Which properties to getids: Page ID of the page in question and log ID (default)title: Title of the page in question (default)type: Type of log entry (default)user: User responsible for the log entry (default)timestamp: Time and date the log entry was created (default)comment: Log comment (default)details: Extra information (not present for all log types) (default)
letype: Only list log entries of this typeblockprotectrightsdeleteuploadmoveimportpatrolmergenewusers- Extensions may add other log types
leuser: Only list log entries made by this userletitle: Only list log entries related to this titlelestart: The timestamp to start listing fromleend: The timestamp to end listing atledir: Direction to list inolder: List newest log entries first (default). Note:lestarthas to be later thanleend.newer: List oldest log entries first. Note:lestarthas to be beforeleend.
lelimit: Maximum amount of log entries to list (10 by default)
Example List the 3 most recent page moves
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <logevents lestart="2008-03-25T21:26:37Z" /> </query-continue> <query> <logevents> <item logid="0" pageid="16577509" ns="1" title="Talk:Parisii (France)" type="move" action="move" user="QuartierLatin1968" timestamp="2008-03-25T21:31:39Z" comment="It is wrong to use such an anachronistic name."> <move new_ns="1" new_title="Talk:Parisii (Gaul)" /> </item> <item logid="0" pageid="16577508" ns="0" title="Parisii (France)" type="move" action="move" user="QuartierLatin1968" timestamp="2008-03-25T21:31:38Z" comment="It is wrong to use such an anachronistic name."> <move new_ns="0" new_title="Parisii (Gaul)" /> </item> <item logid="0" pageid="16577421" ns="10" title="Template:User Brunei work group" type="move" action="move" user="Black Falcon" timestamp="2008-03-25T21:28:02Z" comment="Has become a full WikiProject"> <move new_ns="10" new_title="Template:User WikiProject Brunei" /> </item> </logevents> </query> </api>
Possible errors
- code: leparam_user
- info: User name username not found
- code: leparam_title
- info: Bad title value 'title'
- This happens when you set
letitleto an invalid title
- This happens when you set
- info: Bad title value 'title'
[edit] recentchanges / rc
Get all recent changes to the wiki, à la Special:Recentchanges. This module cannot be used as a generator.
Parameters
rcstart: The timestamp to start listing fromrcend: The timestamp to end listing atrcdir: Direction to list inolder: List newest changes first (default). Note:rcstarthas to be later thanrcend.newer: List oldest changes first. Note:rcstarthas to be beforercend.
rclimit: Maximum amount of changes to list (10 by default)rcnamespace: Only list changes in these namespacesrctitles: Only list changes to these titlesrcuser: Only list changes made by this userrcexcludeuser: Do not list changes made by this userrctype: Only list certain types of changesedit: Regular page editsnew: Page creationslog: Log entries
rcshow: Only list items that meet these criteria. Conflicting options (such asminorand!minor) cannot be used togetherminor: Only list minor edits!minor: Don't list minor editsbot: Only list bot edits!bot: Don't list bot editsanon: Only list edits by anonymous users!anon: Only list edits by registered usersredirect: Only list edits to pages that are currently redirects!redirect: Only list edits to pages that currently aren't redirectspatrolled: Only list edits flagged as patrolled. Only available to users with thepatrolright!patrolled: Only list edits not flagged as patrolled. Only available to users with thepatrolright
rcprop: Which properties to getuser: The user who made the changecomment: The edit/log commenttimestamp: The time and date of the change (default)title: The title the change was made to (default)ids: The page ID, revision ID, previous revision ID and RCID (used for patrolling) (default)sizes: The page size before and after the changeredirect: Whether the changed page is currently a redirectpatrolled: Whether the change is patrolled. Only available to users with thepatrolrightloginfo: If the change was a log event, add thelogid,logtypeandlogactionfields and the log parametersflags:new: A new page was createdminor: The change was a minor editbot: The change was a bot edit
Example Get the 3 most recent changes with sizes and flags
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <recentchanges rcstart="2008-03-25T22:03:47Z" /> </query-continue> <query> <recentchanges> <rc type="log" ns="-1" title="Special:Log/protect" rcid="205182563" pageid="0" revid="0" old_revid="0" user="Yamla" oldlen="0" newlen="0" /> <rc type="new" ns="0" title="Clasico de Avellaneda" rcid="205182562" pageid="16578364" revid="200906507" old_revid="0" user="Eubot" bot="" new="" oldlen="0" newlen="66" /> <rc type="edit" ns="3" title="User talk:Diligent Terrier" rcid="205182561" pageid="12353452" revid="200906506" old_revid="200863749" user="Basketball110" oldlen="202363" newlen="202761" /> </recentchanges> </query> </api>
Possible warnings
- Action 'action' is not allowed for the current user
- Thrown when a token is requested that the current user isn't allowed to use
Possible errors
- code: rcshow
- info: Incorrect parameter - mutually exclusive values may not be supplied
- code: rcpermissiondenied
- info: You need the patrol right to request the patrolled flag
[edit] search / sr
Search for a string in all articles à la Special:Search
Parameters
srsearch: The string to search forsrwhat: Where to search intitle: Search in page titles (default) (falls back to text if search engine doesn't support title searches, as on Wikipedia)text: Search in page text
srnamespace: Only search in these namespaces. By default, only the main namespace is searchedsrredirects: Also list redirectssrlimit: Maximum amount of pages to list (10 by default)sroffset: Used to continue a previous request
Example Show a list of 10 pages that contain the word 'wikipedia'
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <search sroffset="10" /> </query-continue> <query> <search> <p ns="0" title="Wikipedia" /> <p ns="0" title="French Wikipedia" /> <p ns="0" title="German Wikipedia" /> <p ns="0" title="Criticism of Wikipedia" /> <p ns="0" title="2004" /> <p ns="0" title="2005" /> <p ns="0" title="Japanese Wikipedia" /> <p ns="0" title="Spanish Wikipedia" /> <p ns="0" title="History of Wikipedia" /> <p ns="0" title="2007" /> </search> </query> </api>
Possible errors
- code: srparam-search
- info: empty search string is not allowed
- code: srsearch-title-disabled
- info: title search is disabled
- code: srsearch-text-disabled
- info: text search is disabled
[edit] usercontribs / uc
Gets a list of contributions made by a given user, ordered by modification time. This module cannot be used as a generator.
Parameters
ucuser: User to retrieve contributions forucuserprefix: List contributions of all users whose name starts with this string. Overridesucuser- This is useful for getting contributions of IP ranges.
- Note that contributions will be sorted by user first, then by timestamp, when using this option
ucstart: The timestamp to start listing fromucend: The timestamp to end listing atuccontinue: When more results are available, use this to continueucdir: Direction to list inolder: List newest contributions first (default). Note:ucstarthas to be later thanucend.- If using
ucuserprefix, users will be listed in descending order (Z to A)
- If using
newer: List oldest contributions first. Note:ucstarthas to be beforeucend.- If using
ucuserprefix, users will be listed in ascending order (A to Z)
- If using
uclimit: Maximum amount of contributions to list (10 by default)ucnamespace: Only list contributions in these namespacesucshow: Only list contributions that meet these criteria. Conflicting options (such asminorand!minor) cannot be used togetherminor: Only list minor edits!minor: Don't list minor editspatrolled: Only list patrolled edits. Only available to users with thepatrolright!patrolled: Only list non-patrolled edits. Only available to users with thepatrolright- If
patrolledor!patrolledis used, revisions older than $wgRCMaxAge will not be shown.
- If
ucprop: Which properties to getids: Page ID and revision IDtitle: Title of the page that was changedtimestamp: Time and date of the contributioncomment: Edit/log commentpatrolled: Whether the change is patrolled. Only available to users with thepatrolrightflags:new: A new page was createdminor: The change was a minor editbot: The change was a bot edittop: This is the latest version of the article
Example Get the first three contributions by en:User:Catrope
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <usercontribs ucstart="2007-06-11T09:23:57Z" /> </query-continue> <query> <usercontribs> <item user="Catrope" pageid="11650099" revid="136629050" ns="3" title="User talk:Catrope" timestamp="2007-06-07T16:45:30Z" minor="" comment="Creation; directing to BW" /> <item user="Catrope" pageid="11650100" revid="136629120" ns="2" title="User:Catrope" timestamp="2007-06-07T16:45:49Z" new="" minor="" comment="Creation; directing to BW" /> <item user="Catrope" pageid="3383874" revid="136629407" ns="3" title="User talk:Ruud Koot" timestamp="2007-06-07T16:47:09Z" comment="Nested collapsible tables fix" /> </usercontribs> </query> </api>
Possible errors
- code: ucparam_user
- info: User name username is not valid
- code: ucparam_user
- info: User parameter may not be empty
- code: ucshow
- info: Incorrect parameter - mutually exclusive values may not be supplied
- code: permissiondenied
- info: You need the patrol right to request the patrolled flag
[edit] watchlist / wl
Get a list of pages on the current user's watchlist that were changed within the given time period. Ordered by time of the last change of the watched page.
Parameters
wlstart: The timestamp to start listing fromwlend: The timestamp to end listing atwldir: Direction to list inolder: List most recently changed pages first (default). Note:wlstarthas to be later thanwlend.newer: List least recently changed pages first. Note:wlstarthas to be beforewlend.
wllimit: Maximum amount of pages to list (10 by default)wlnamespace: Only list pages in these namespaceswluser: Only list changes made by this userwlexcludeuser: Do not list changes made by this userwlallrev: Include multiple revisions to the same page. This parameter cannot be used in generator modewlshow: Only list revisions that meet these criteria. Conflicting options (such asminorand!minor) cannot be used togetherminor: Only list minor edits!minor: Don't list minor editsbot: Only list bot edits!bot: Don't list bot editsanon: Only list edits by anonymous users!anon: Only list edits by registered users
wlprop: Which properties to getuser: The user who made the changecomment: The edit/log commenttimestamp: The time and date of the changetitle: The title the change was made to (default)ids: The page ID, revision ID, previous revision ID and RCID (used for patrolling) (default)sizes: The page size before and after the changepatrol: Whether the change is patrolled. Only available to users with thepatrolrightflags: (default)new: A new page was createdminor: The change was a minor editbot: The change was a bot editanon: The change was made by a user who wasn't logged in
Example Get the current user's watchlist
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <watchlist wlstart="2008-03-04T16:01:48Z" /> </query-continue> <query> <watchlist> <item pageid="16396" revid="176417" ns="0" title="API:Query - Lists" /> <item pageid="25300" revid="176413" ns="1" title="Talk:Summer of Code 2008" /> <item pageid="24947" revid="176089" ns="0" title="Summer of Code 2008" /> <item pageid="16377" revid="174495" ns="0" title="API:Query" /> <item pageid="16393" revid="174239" ns="0" title="API:Query - Meta" minor="" /> <item pageid="16375" revid="174222" ns="0" title="API:Login" /> <item pageid="16391" revid="174216" ns="0" title="API:Data formats" minor="" /> <item pageid="14588" revid="174214" ns="0" title="API" /> <item pageid="18710" revid="173571" ns="1" title="Talk:API:Edit - Create&Edit pages" /> <item pageid="20025" revid="173412" ns="1" title="Talk:API:Query" /> </watchlist> </query> </api>
Possible errors
- code: wlnotloggedin
- info: You must be logged-in to have a watchlist
- code: wlpatrol
- info: patrol property is not available
- code: wlshow
- info: Incorrect parameter - mutually exclusive values may not be supplied
[edit] deletedrevs / dr
- NOTE: This module's behavior was changed significantly in MediaWiki 1.15. Some of the features described here are not available in MediaWiki 1.14 and earlier.
List deleted revisions. You need the deletedhistory right to use this module. This module cannot be used as a generator. This module can be used in one of three modes:
- List deleted revisions for the given titles (through
titlesor a generator), sorted by timestamp - List deleted contributions for a certain user, sorted by timestamp (
druserset, no titles given) - List all deleted revisions in a certain namespace (
drusernot set, no titles given)
Some parameters are restricted to certain modes only, and are marked accordingly. For instance, a parameter marked (1,2) only applies to modes 1 and 2 and is ignored in mode 3.
Parameters
drlimit: Maximum number of revisions to list (10 by default)druser: Only list revisions by this userdrexcludeuser: Don't list revisions by this userdrstart: The timestamp to start listing from (optional). If not specified, all revisions before drend will be listed. (1,2)drend: The timestamp to end listing at (optional). If not specified, all revisions later than drstart will be listed. (1,2)drdir: Direction to list in. (1,2)older: List newest revisions first (default). Note: drstart has to be later than drend.newer: List oldest revisions first. Note: drstart has to be before drend.
drnamespace: List all deleted revisions in this namespace (3)drunique: List only one revision for each page (3)drfrom: Start listing at this title (3)drcontinue: When more results are available, use this to continue (3)drprop: Which properties to getrevid: Revision IDuser: User who made the edit (default)comment: Edit comment (default)minor: Whether the edit was minorlen: Revision sizecontent: Revision content. You need theundeleteright to use this optiontoken: Undelete token
Sample request Listing the 8 most recent deleted revisions dated September 4, 2007 (mode 3).
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <deletedrevs drstart="20070904142729" /> </query-continue> <query> <deletedrevs> <page title="Main Page" ns="0" token="e4c475f13be7824135b4edbebf4140ff+\"> <revisions> <rev timestamp="20070904200804" revid="31" user="Catrope" minor="" len="" /> <rev timestamp="20070904200753" revid="30" user="Catrope" minor="" len="" /> <rev timestamp="20070904193501" revid="29" user="Catrope" minor="" len="568" /> <rev timestamp="20070904193213" revid="28" user="Catrope" minor="" len="470" /> <rev timestamp="20070904193103" revid="27" user="192.168.1.3" len="568" /> <rev timestamp="20070904193048" revid="26" user="192.168.1.3" len="480" /> </revisions> </page> <page title="User:Catrope" ns="2" token="e4c475f13be7824135b4edbebf4140ff+\"> <revisions> <rev timestamp="20070904143938" revid="24" user="Catrope" len="52" /> <rev timestamp="20070904142758" revid="23" user="Catrope" len="37" /> </revisions> </page> </deletedrevs> </query> </api>
Possible errors
- code: drpermissiondenied
- info: You don't have permission to view deleted revision information
- On most wikis, viewing deleted revisions is restricted to sysops, but other wikis may have stricter rules.
- info: You don't have permission to view deleted revision information
- code: drpermissiondenied
- info: You don't have permission to view deleted revision content
[edit] users / us
Get information about a list of users. This module cannot be used as a generator.
Parameters
ususers: A list of user names to get information forustoken: Which tokens to getuserrights: Token for changing a user's group membership
usprop: Which properties to getblockinfo: Whether the user is blocked, by whom and whygroups: All groups the user belongs toeditcount: The number of edits the user has maderegistration: The time and date the user registered atemailable: Whether the user can and wants to receive e-mail through Special:Emailuser
Example Getting information about a list of users
<?xml version="1.0" encoding="utf-8"?> <api> <query> <users> <user name="1.2.3.4" invalid="" /> <user name="Catrope" editcount="203" registration="2007-06-07T16:36:03Z" emailable="" /> <groups> <g>bot</g> <g>bureaucrat</g> <g>steward</g> <g>sysop</g> <g>trusted</g> </groups> </user> <user name="Vandal01" editcount="1" registration="2006-11-18T21:55:03Z" blockedby="Catrope" blockreason="Intimidating behaviour/harassment" /> <user name="Bob" missing="" /> </users> </query> </api>
Possible errors
None
[edit] random / rn
Get a list of random pages.
Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, "Main Page" is the first random page on your list, "List of fictional monkeys" will always be second, "List of people on stamps of Vanuatu" third, etc.
Parameters
rnlimit: Maximum number of pages to return (1 by default)- If the number of pages in the namespace is lower than
rnlimit, you will get fewer pages. You will not get the same page twice.
- If the number of pages in the namespace is lower than
rnnamespace: Only list pages in these namespacesrnredirect: Only list redirects- By default, only non-redirects are listed
Example Get 5 random pages
<?xml version="1.0" encoding="utf-8"?> <api> <query> <random> <page title="History of Indian Institutes of Technology" ns="0" id="4939430" /> <page title="Talk:International Karate +" ns="1" id="1904217" /> <page title="Selion" ns="0" id="758503" /> <page title="User talk:Yenandzen" ns="3" id="12454962" /> <page title="User talk:66.138.5.211" ns="3" id="9965621" /> </random> </query> </api>
Possible errors
None
[edit] protectedtitles / pt
Get a list of titles protected from creation.
Parameters
ptstart: Start listing at this protection timestampptend: End listing at this protection timestampptdir: Direction to list inolder: List most recently protected titles first (default). Note: ptstart has to be later than ptend.newer: List least recently protected titles first Note: ptstart has to be before ptend.
ptlimit: Maximum number of titles to return (10 by default)ptnamespace: Only list titles in these namespacesptlevel: Only list titles with this protection levelptprop: A pipe-separated list of properties to gettimestamp: Timestamp the title was protected (default)user: User who protected the titlecomment: Protection log commentexpiry: Expiry timestamplevel: Protection level (i.e. the right needed to be able to create the page) (default)
Example Get the first 2 titles only sysops can create
<?xml version="1.0" encoding="utf-8"?> <api> <query> <protectedtitles> <pt ns="0" title="Add article" timestamp="2009-02-13T21:26:59Z" level="sysop" /> <pt ns="0" title="Add an article" timestamp="2008-04-17T12:44:53Z" level="sysop" /> </protectedtitles> </query> </api>
Possible errors
None