Extension:BotQuery

From MediaWiki.org

Jump to: navigation, search

This extension is obsolete!
It has been replaced by core functionality in the MediaWiki software.

Manual on MediaWiki Extensions
List of MediaWiki Extensions
BotQuery

Release status: unstable

Description provides read-only access to various metadata about pages of the wiki
License No license specified
Download Download snapshot

Subversion [Help]
Browse source code

Query.php provides read-only access to various metadata about pages of MediaWiki projects. It has been installed on all Wikimedia projects, see also installation on other MediaWiki projects.

What follows is derived from {{SERVER}}/w/query.php, for this site http://www.mediawiki.org/w/query.php , see that page for up-to-date info. The example queries on that page apply to the site concerned. Similarly the examples below apply for this site.

Contents

[edit] Summary

This API provides a way for your applications to query data directly from the MediaWiki servers. One or more pieces of information about the site and/or a given list of pages can be retrieved.

Information may be returned in various machine readable formats; the default format xmlfm - XML format in HTML - is, with a browser, fairly suitable for human reading also; however, it is "cluttered" with xml tags, and the pagenames in the output are not linked.

More than one piece of information may be requested with a single query.

[edit] Usage

{{SERVER}}/w/query.php ? format=... & what=...|...|... & titles=...|...|... & ...

[edit] Common parameters

  • format - How should the output be formatted. See formats section below.
  • what - What information the server should return. See the list of available properties below. More than one property may be requested at the same time, separated by pipe '|' symbol.
  • titles - A list of titles, separated by the pipe '|' symbol.
  • pageids - A list of page ids, separated by the pipe '|' symbol.
  • revids - List of revision ids, separated by '|' symbol. See 'revisions' property for additional information.
  • noprofile - When present, each sql query execution time will be hidden.
  • proxysite - Access alternative site (wikipedia/wikinews/wikiquote/...)
  • proxylang - Access alternative language (en/ru/he/commons/...)
    • Note: proxying is a security workaround for the browser-based scripts. Avoid using it if you can.
  • User is treated as anonymous, and only sites/languages hosted at the same cluster are accessible.

[edit] Examples

http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Template - Get a list of all links and templates used on the page Help:Template.

http://www.mediawiki.org/w/query.php?what=revisions&titles=Main_Page&rvlimit=100&rvstart=20060401000000&rvcomments - Get a list of 100 last revisions of the main page with comments, but only if it happened after midnight April 1st 2006

http://www.mediawiki.org/w/query.php?what=revisions&revids=403918&rvcomments - Get revision 403918 with some of its properties.

[edit] Notes

Some queries marked with *slow query* are known to be database intensive. Please optimize their use. Some properties may add status information to the <query> element. For example, http://www.mediawiki.org/w/query.php?what=allpages&aplimit=3 will set an element <query>/<allpages next='B'> to the next available value. For the next request, set '__from' to that value to continue paging: http://www.mediawiki.org/w/query.php?what=allpages&aplimit=3&apfrom=B In addition, <query> element has performance time (in ms) for both database and total processing to allow request optimization.

[edit] Supported properties

[edit] Properties of the entire site

info - General site information

Example: http://www.mediawiki.org/w/query.php?what=info

namespaces - List of localized namespace names

Example: http://www.mediawiki.org/w/query.php?what=namespaces

userinfo - Information about current user. The information will always include 'name' element, and optionally 'anonymous' or 'bot' flags. Parameters supported:

  • uiisblocked- If present, and current user or IP is blocked, a 'blocked' flag will be added.
  • uihasmsg - If present, and current user or IP has messages waiting, a 'messages' flag will be added.
  • uiextended - If present, includes additional information such as rights and groups.
  • uioptions - A list of user preference options to get, separated by '|'. For the complete list see User.php source file.

Examples:

recentchanges - Adds recently changed articles to the output list.

Parameters supported:
rcfrom - Timestamp of the first entry to start from. The list order reverses.
rclimit - How many total links to return.
Smaller size is possible if pages changes multiple times.
rchide - Which entries to ignore 'minor', 'bots', 'anons', 'liu' (loged-in users).
Cannot specify both anons and liu.
Example: http://www.mediawiki.org/w/query.php?what=recentchanges&rchide=liu|bots

allpages - Enumerates all available pages to the output list.

Parameters supported:
aplimit - How many total pages to return
apfrom - The page title to start enumerating from.
apnamespace - Limits which namespace to enumerate. Default 0 (Main)
apfilterredir- Which pages to list: 'all' (default), 'redirects', or 'nonredirects'
Example: http://www.mediawiki.org/w/query.php?what=allpages&aplimit=50 (first 50 pages)
http://www.mediawiki.org/w/query.php?what=allpages&aplimit=20&apnamespace=10&apfrom=C&apfilterredir=nonredirects
(20 templates starting with 'C' that are not redirects)

nolanglinks - Enumerates pages without language links to the output list (automatically filters out redirects).

Parameters supported:
nllimit - How many total pages to return
nlfrom - The page title to start enumerating from.
nlnamespace - Limits which namespace to enumerate. Default 0 (Main)
Example: http://www.mediawiki.org/w/query.php?what=nolanglinks&nllimit=10&nlfrom=A

category - Adds pages in a given category to the output list.

Parameters supported:
cptitle - A category name, either with or without the 'Category:' prefix.
cplimit - How many total pages (in category) to return.
cpfrom - The category sort key to continue paging. Starts at the beginning by default.
cpnamespace- Optional namespace id: Includes only the pages in the category that are in one namespace.
cpextended - Add extra information like sortkey and timestamp to the category output.
Example: http://www.mediawiki.org/w/query.php?what=category&cptitle=Days
http://www.mediawiki.org/w/query.php?what=category&cptitle=Time&cpnamespace=14 -- show subcategories of category Time

users - Adds user pages to the output list.

Parameters supported:
usfrom - Start user listing from...
uslimit - How many total links to return.
Example: http://www.mediawiki.org/w/query.php?what=users&usfrom=Y

[edit] Properties of specified pages

[edit] redirects

For all given redirects, provides additional information such as page IDs and double-redirection

Examples:

[edit] permissions

For all found pages, check if the user can edit them.

Parameters supported:
prcanmove - Also check if the page can be moved.

Example:

[edit] links

List of regular page links, including a link to a non-existing page produced by attempting to include the page.

Example:

[edit] langlinks

Inter-language links

Example:

[edit] templates

List of pages embedded in a given page (the same list as given on the edit page, except that an attempt to embed a non-existing page, producing a link, counts for the query functions as linking, not embedding.

Example:

[edit] categories

List of categories the page belongs to

Parameters supported:
clextended - Add extra information like sortkey and timestamp

Example:

[edit] backlinks

List of pages linking to a given page (the entries of "What links here" not marked with "inclusion", plus those marked with "inclusion" which not only include the given page but also link to it)

Parameters supported:
blfilter - Of all given pages, which should be queried:
'redirects', 'nonredirects', 'existing' (blue links, default), or 'all' (red links)
blnamespace- Optional namespace id: limits the namespace of the originating pages
bllimit - How many total links to return
blcontfrom - From which point to continue. Use the 'next' value from the previous queries.

Examples:

[edit] embeddedin

List of pages a given page is embedded in as template (the entries of "What links here" marked with "inclusion")

Parameters supported:
eifilter - Of all given pages, which should be queried:
'redirects', 'nonredirects', 'existing' (blue links, default), or 'all' (red links)
einamespace- Optional namespace id: limits the namespace of the originating pages
eilimit - How many total links to return
eicontfrom - From which point to continue. Use the 'next' value from the previous queries.

Example:

[edit] imagelinks

What pages use this image(s)

ilfilter - Of all given images, which should be queried:
'existing', 'all' (default, includes non-existent or those stored on Wikimedia Commons)
ilnamespace- Optional namespace id: limits the namespace of the originating pages
illimit - How many total links to return
ilcontfrom - From which point to continue. Use the 'next' value from the previous queries.

Example:

[edit] revisions

Revision history - Lists edits performed to the given pages

Parameters supported:
rvuniqusr - Get last #rvlimit revisions by unique authors. *slow query*
rvcomments - Include summary strings.
rvcontent - Include raw wiki text. *slow query*
rvlimit - How many links to return *for each title*. Defaults to 10, or 0 if revids=... was specified.
rvoffset - When too many results are found, use this to page. *obsolete* This option is likely to disappear soon.
rvstart - Timestamp of the earliest entry.
rvend - Timestamp of the latest entry.
rvrbtoken - If logged in as an admin, a rollback tokens for top revisions will be included in the output.

Examples:

[edit] usercontribs

User contribution history - Lists last edits performed by the given user(s)

Parameters supported:
uccomments - If specified, the result will include summary strings.
uclimit - How many links to return *for each user*.
uctop - Filter results by contributions that are still on top:
'all' (default), 'only' (only the ones marked as top), 'exclude' (all non-top ones)
ucstart - Timestamp of the earliest entry.
ucend - Timestamp of the latest entry.
ucrbtoken - If logged in as an admin, a rollback tokens for top revisions will be included in the output.

Example:

[edit] imageinfo

Image information

Parameters supported:
iiurl - Add image URLs.
iihistory - Include all past revisions of the image.
iishared - Include image info from the shared image repository (commons)

Example:

[edit] content

Raw page content - Retrieves raw wiki markup for all found pages.

*slow query* Please optimize content requests to reduce load on the servers.
Duplicate results may be obtained through revisions+rvcontent request

Example:

[edit] Supported formats

xmlfm - XML format in HTML (Default)

The data is presented as an indented syntax-highlighted XML format. With a browser the output seems the best available for human readability, although it is "cluttered" with xml tags. Errors will return the usage screen, unless 'nousage' parameter is given.

Example:

jsonfm - JSON format in HTML

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=jsonfm (Format info: http://en.wikipedia.org/wiki/JSON)

txt - print_r() output (HTML)

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=txt (Format info: http://www.php.net/print_r)

dbg - PHP source code using var_export() (HTML)

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=dbg (Format info: http://www.php.net/var_export)

xml - XML format

Optional indentation can be enabled by supplying 'xmlindent' parameter.
Errors will return the usage screen, unless 'nousage' parameter is given.
Internet Explorer is known to have many issues with text/xml output.
Please use other browsers or switch to xmlfm format while debugging.
Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=xml

json - JSON format

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=json (Format info: http://en.wikipedia.org/wiki/JSON)

php - PHP serialized format using serialize()

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=php (Format info: http://www.php.net/serialize)

wddx - WDDX - Web Distributed Data eXchange format

Example: http://www.mediawiki.org/w/query.php?what=links|templates&titles=Help:Go%20button&format=wddx (Format info: http://en.wikipedia.org/wiki/WDDX)

[edit] Links

[edit] Credits

This feature was written and is being maintained by Yuri Astrakhan (<Firstname><Lastname>@gmail.com) Please leave your comments and suggestions at http://en.wikipedia.org/wiki/User_talk:Yurik

This extension came as the result of IRC discussion between Yuri Astrakhan (en:Yurik), Tim Starling (en:Tim Starling), and Daniel Kinzler(de:Duesentrieb) The extension was first implemented by Tim to provide interlanguage links and history summary. It was later completely rewritten by Yuri, introducing the rest of properties, meta information, and various formatting options.

Personal tools