API:Query - Lists

From MediaWiki.org

Jump to: navigation, search
Tools clipart.png This page is part of the MediaWiki API documentation.
MediaWiki API


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.

Contents

[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

MediaWiki version: 1.9

Returns a list of pages in a given namespace, ordered by page title.

Parameters

  • apfrom: Start listing at this title. The title need not exist
  • apprefix: Only list titles that start with this value
  • apnamespace: The namespace to enumerate. You can only enumerate one namespace at a time. By default, the main namespace will be enumerated
  • apfilterredir: How to filter redirects
    • all: List all pages regardless of their redirect flag (default)
    • redirects: Only list redirects
    • nonredirects: Don't list redirects
  • apfilterlanglinks: How to filter based on whether a page has language links
    • all: List all pages regardless of whether they have language links (default)
    • withlanglinks: Only list pages with language links
    • withoutlanglinks: Only list pages without language links
  • apminsize: Only list pages that are at least this many bytes in size
  • apmaxsize: Only list pages that are at most this many bytes in size
  • apprtype: Only list pages that have been protected from this type of action
    • edit: Only list edit-protected pages
    • move: 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 without apprtype
    • autoconfirmed: Only autoconfirmed users can edit/move/whatever
    • sysop: 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 list
    • ascending: 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

MediaWiki version: 1.11

Returns a list of (unique) links to pages in a given namespace starting ordered by link title.

Parameters

  • alcontinue: Used to continue a previous request
  • alfrom: Start listing at this title. The title need not exist
  • alprefix: Only list links to titles that begin with this value
  • alnamespace: The namespace to enumerate. You can only enumerate one namespace at a time. By default, the main namespace will be enumerated
  • alunique: If set, multiple links to the same title will be listed only once. Cannot be used in generator mode or with alprop=ids
  • allimit: Maximum amount of links to list (10 by default)
  • alprop: Which properties to return
    • ids: Page IDs of the linking pages. Cannot be used together with alunique
    • title: 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 alunique and alprop=ids together
  • code: alparams
    • info: alcontinue and alfrom cannot be used together

[edit] allcategories / ac

MediaWiki version: 1.12

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 exist
  • acprefix: Only list category titles starting with this value
  • aclimit: Maximum amount of categories to list (10 by default)
  • acdir: In which direction to list
    • ascending: 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 &quot;M&quot; 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

MediaWiki version: 1.11

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 exist
  • auprefix: Only list usernames starting with this value
  • augroup: Only list users in this group
    • bot
    • sysop
    • bureaucrat
    • 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 return
    • editcount: The number of edits the user has made
    • groups: A list of all groups the user is in
    • registration: 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

MediaWiki version: 1.12

Returns a list of all images, ordered by image title.

Parameters

  • aifrom: Start listing at this title. The title need not exist
  • aiprefix: Only list titles that start with this value
  • aiminsize: Only list images that are at least this many bytes in size
  • aimaxsize: Only list images that are at most this many bytes in size
  • ailimit: Maximum amount of images to list (10 by default)
  • aidir: In which direction to list
    • ascending: 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 lottery
  • aisha1base36: Same as aisha1, but in base 36
  • aiprop: Which properties to get
    • timestamp: 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 version
    • comment: The edit comment for the latest upload
    • url: The URL to the most recent version of the image (default)
    • size: The image's size in bytes
    • dimensions: The image's width and height in pixels
    • mime: The image's MIME type
    • sha1: The image's SHA-1 hash
    • metadata: 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&#039;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

MediaWiki version: 1.9

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 exist
  • blnamespace: Only list pages in these namespaces
  • blfilterredir: How to filter redirects
    • all: List all pages regardless of their redirect flag (default)
    • redirects: Only list redirects
    • nonredirects: Don't list redirects
  • bllimit: Maximum amount of pages to list (10 by default). Maximum limit is halved if blredirect is set
  • blredirect: If set, pages linking to bltitle through a redirect will also be listed. See below for more detailed information
  • blcontinue: 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

MediaWiki version: 1.12

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&#039;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&#039;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 titles instead of bltitle (this usage is deprecated) and specify multiple titles
  • code: bl_badcontinue
    • info: Invalid continue param. You should pass the original value returned by the previous query

[edit] blocks / bk

MediaWiki version: 1.12

List all blocks, à la Special:Ipblocklist. This module cannot be used as a generator.

Parameters

  • bkstart: The timestamp to start listing from
  • bkend: The timestamp to end listing at
  • bkdir: 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 IDs
  • bkusers: Only list blocks of these users
  • bkip: 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 with bkusers. CIDR ranges broader than /16 are not allowed, as range blocks cannot cross /16 boundaries
  • bklimit: 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|flags
    • id: 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 to
    • flags: Flags that apply to the block (default)
      • automatic: Automatically blocked because of an autoblock (see also action=block)
      • anononly: Only anonymous edits are blocked
      • nocreate: Account creation is disabled
      • autoblock: Automatic blocking is enabled for this block
      • noemail: Sending e-mail through the wiki is disabled for the blocked user
      • hidden: 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

MediaWiki version: 1.11

List of pages that belong to a given category, ordered by page sort title.

Parameters

  • cmtitle: The category to enumerate
  • cmnamespace: Only list pages in these namespaces
  • cmstart: Start listing at this timestamp. Can only be used with cmsort=timestamp
  • cmend: End listing at this timestamp. Can only be used with cmsort=timestamp
  • cmstartsortkey: Start listing at this sortkey. Can only be used with cmsort=sortkey
  • cmendsortkey: End listing at this sortkey. Can only be used with cmsort=sortkey
  • cmsort: Property to sort by
    • sortkey: The article's sort key (default)
    • timestamp: The time the article was added to the category
  • cmdir: Direction to sort in
    • asc: From A to Z or from 2002 to 2009. Note: cmstart has to be before cmend
    • desc: 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 get
    • ids: page ID (default)
    • title: page title (default)
    • sortkey: sort key
    • timestamp: 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

MediaWiki version: 1.9

List pages that include a certain page.

Parameters

  • eititle: List pages including this title. The title need not exist
  • einamespace: Only list pages in these namespaces
  • eifilterredir: How to filter redirects
    • all: List all pages regardless of their redirect flag (default)
    • redirects: Only list redirects
    • nonredirects: 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 titles instead of eititle (this usage is deprecated) and specify multiple titles
  • code: ei_badcontinue
    • info: Invalid continue param. You should pass the original value returned by the previous query

[edit] exturlusage / eu

MediaWiki version: 1.11

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 omit euquery (not just leave it empty), all external links will be listed, and euprotocol will be ignored
  • euprotocol: 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
  • eunamespace: Only list links from pages in these namespaces
  • eulimit: Maximum amount of pages to list (10 by default)
  • euprop: Which properties to get
    • ids: Page ID of the linking page
    • title: Title of the linking page
    • url: 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

MediaWiki version: 1.11

List of pages that include a given image. Ordered by page title.

Parameters

  • iutitle: List pages using this image. The image need not exist
  • iunamespace: Only list pages in these namespaces
  • iufilterredir: How to filter redirects
    • all: List all pages regardless of their redirect flag (default)
    • redirects: Only list redirects
    • nonredirects: Don't list redirects
  • iulimit: Maximum amount of pages to list (10 by default)
  • iuredirect: If set, pages linking to iutitle through a redirect will also be listed. See the documentation for list=backlinks for more detailed information
  • iucontinue: 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 titles instead of iutitle (this usage is deprecated) and specify multiple titles
  • 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

MediaWiki version: 1.11

Get a list of all logged events, à la Special:Log. This module cannot be used as a generator.

Parameters

  • leprop: Which properties to get
    • ids: 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 type
    • block
    • protect
    • rights
    • delete
    • upload
    • move
    • import
    • patrol
    • merge
    • newusers
    • Extensions may add other log types
  • leuser: Only list log entries made by this user
  • letitle: Only list log entries related to this title
  • lestart: The timestamp to start listing from
  • leend: The timestamp to end listing at
  • ledir: Direction to list in
    • older: List newest log entries first (default). Note: lestart has to be later than leend.
    • newer: List oldest log entries first. Note: lestart has to be before leend.
  • 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 letitle to an invalid title

[edit] recentchanges / rc

MediaWiki version: 1.10

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 from
  • rcend: The timestamp to end listing at
  • rcdir: Direction to list in
    • older: List newest changes first (default). Note: rcstart has to be later than rcend.
    • newer: List oldest changes first. Note: rcstart has to be before rcend.
  • rclimit: Maximum amount of changes to list (10 by default)
  • rcnamespace: Only list changes in these namespaces
  • rctitles: Only list changes to these titles
  • rcuser: Only list changes made by this user
  • rcexcludeuser: Do not list changes made by this user
  • rctype: Only list certain types of changes
    • edit: Regular page edits
    • new: Page creations
    • log: Log entries
  • rcshow: Only list items that meet these criteria. Conflicting options (such as minor and !minor) cannot be used together
    • minor: Only list minor edits
    • !minor: Don't list minor edits
    • bot: Only list bot edits
    • !bot: Don't list bot edits
    • anon: Only list edits by anonymous users
    • !anon: Only list edits by registered users
    • redirect: Only list edits to pages that are currently redirects
    • !redirect: Only list edits to pages that currently aren't redirects
    • patrolled: Only list edits flagged as patrolled. Only available to users with the patrol right
    • !patrolled: Only list edits not flagged as patrolled. Only available to users with the patrol right
  • rcprop: Which properties to get
    • user: The user who made the change
    • comment: The edit/log comment
    • timestamp: 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 change
    • redirect: Whether the changed page is currently a redirect
    • patrolled: Whether the change is patrolled. Only available to users with the patrol right
    • loginfo: If the change was a log event, add the logid, logtype and logaction fields and the log parameters
    • flags:
      • new: A new page was created
      • minor: The change was a minor edit
      • bot: 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

MediaWiki version: 1.11

Search for a string in all articles à la Special:Search

Parameters

  • srsearch: The string to search for
  • srwhat: Where to search in
    • title: 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 searched
  • srredirects: Also list redirects
  • srlimit: 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

MediaWiki version: 1.10

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 for
  • ucuserprefix: List contributions of all users whose name starts with this string. Overrides ucuser
    • 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 from
  • ucend: The timestamp to end listing at
  • uccontinue: When more results are available, use this to continue
  • ucdir: Direction to list in
    • older: List newest contributions first (default). Note: ucstart has to be later than ucend.
      • If using ucuserprefix, users will be listed in descending order (Z to A)
    • newer: List oldest contributions first. Note: ucstart has to be before ucend.
      • If using ucuserprefix, users will be listed in ascending order (A to Z)
  • uclimit: Maximum amount of contributions to list (10 by default)
  • ucnamespace: Only list contributions in these namespaces
  • ucshow: Only list contributions that meet these criteria. Conflicting options (such as minor and !minor) cannot be used together
    • minor: Only list minor edits
    • !minor: Don't list minor edits
    • patrolled: Only list patrolled edits. Only available to users with the patrol right
    • !patrolled: Only list non-patrolled edits. Only available to users with the patrol right
      • If patrolled or !patrolled is used, revisions older than $wgRCMaxAge will not be shown.
  • ucprop: Which properties to get
    • ids: Page ID and revision ID
    • title: Title of the page that was changed
    • timestamp: Time and date of the contribution
    • comment: Edit/log comment
    • patrolled: Whether the change is patrolled. Only available to users with the patrol right
    • flags:
      • new: A new page was created
      • minor: The change was a minor edit
      • bot: The change was a bot edit
      • top: 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

MediaWiki version: 1.10

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 from
  • wlend: The timestamp to end listing at
  • wldir: Direction to list in
    • older: List most recently changed pages first (default). Note: wlstart has to be later than wlend.
    • newer: List least recently changed pages first. Note: wlstart has to be before wlend.
  • wllimit: Maximum amount of pages to list (10 by default)
  • wlnamespace: Only list pages in these namespaces
  • wluser: Only list changes made by this user
  • wlexcludeuser: Do not list changes made by this user
  • wlallrev: Include multiple revisions to the same page. This parameter cannot be used in generator mode
  • wlshow: Only list revisions that meet these criteria. Conflicting options (such as minor and !minor) cannot be used together
    • minor: Only list minor edits
    • !minor: Don't list minor edits
    • bot: Only list bot edits
    • !bot: Don't list bot edits
    • anon: Only list edits by anonymous users
    • !anon: Only list edits by registered users
  • wlprop: Which properties to get
    • user: The user who made the change
    • comment: The edit/log comment
    • timestamp: The time and date of the change
    • 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 change
    • patrol: Whether the change is patrolled. Only available to users with the patrol right
    • flags: (default)
      • new: A new page was created
      • minor: The change was a minor edit
      • bot: The change was a bot edit
      • anon: 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&amp;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

MediaWiki version: 1.12
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:

  1. List deleted revisions for the given titles (through titles or a generator), sorted by timestamp
  2. List deleted contributions for a certain user, sorted by timestamp (druser set, no titles given)
  3. List all deleted revisions in a certain namespace (druser not 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 user
  • drexcludeuser: Don't list revisions by this user
  • drstart: 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 get
    • revid: Revision ID
    • user: User who made the edit (default)
    • comment: Edit comment (default)
    • minor: Whether the edit was minor
    • len: Revision size
    • content: Revision content. You need the undelete right to use this option
    • token: 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.
  • code: drpermissiondenied
    • info: You don't have permission to view deleted revision content

[edit] users / us

MediaWiki version: 1.12

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 for
  • ustoken: Which tokens to get
  • usprop: Which properties to get
    • blockinfo: Whether the user is blocked, by whom and why
    • groups: All groups the user belongs to
    • editcount: The number of edits the user has made
    • registration: The time and date the user registered at
    • emailable: 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

MediaWiki version: 1.12

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.
  • rnnamespace: Only list pages in these namespaces
  • rnredirect: 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

MediaWiki version: 1.15

Get a list of titles protected from creation.

Parameters

  • ptstart: Start listing at this protection timestamp
  • ptend: End listing at this protection timestamp
  • ptdir: Direction to list in
    • older: 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 namespaces
  • ptlevel: Only list titles with this protection level
  • ptprop: A pipe-separated list of properties to get
    • timestamp: Timestamp the title was protected (default)
    • user: User who protected the title
    • comment: Protection log comment
    • expiry: Expiry timestamp
    • level: 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