API:Інформація про сайт

This page is a translated version of the page API:Siteinfo and the translation is 21% complete.

GET Request to get overall site information.

Версія MediaWiki:
1.8

Документація API

meta=siteinfo (si)

(main | query | siteinfo)

Return general information about the site.

Specific parameters:
Other general parameters are available.
siprop

Which information to get:

general
Overall system information.
namespaces
List of registered namespaces and their canonical names.
namespacealiases
List of registered namespace aliases.
specialpagealiases
List of special page aliases.
magicwords
List of magic words and their aliases.
interwikimap
Returns interwiki map (optionally filtered, optionally localised by using siinlanguagecode).
dbrepllag
Returns database server with the highest replication lag.
statistics
Returns site statistics.
usergroups
Returns user groups and the associated permissions.
autocreatetempuser
Returns configuration for the automatic creation of temporary user accounts (also known as IP masking).
clientlibraries
Returns client-side libraries installed on the wiki
libraries
Returns libraries installed on the wiki.
extensions
Returns extensions installed on the wiki.
fileextensions
Returns list of file extensions (file types) allowed to be uploaded.
rightsinfo
Returns wiki rights (license) information if available.
restrictions
Returns information on available restriction (protection) types.
languages
Returns a list of languages MediaWiki supports (optionally localised by using siinlanguagecode).
languagevariants
Returns a list of language codes for which LanguageConverter is enabled, and the variants supported for each.
skins
Returns a list of all enabled skins (optionally localised by using siinlanguagecode, otherwise in the content language).
extensiontags
Returns a list of parser extension tags.
functionhooks
Returns a list of parser function hooks.
showhooks
Returns a list of all subscribed hooks (contents of $wgHooks).
variables
Returns a list of variable IDs.
protocols
Returns a list of protocols that are allowed in external links.
defaultoptions
Returns the default values for user preferences.
uploaddialog
Returns the upload dialog configuration.
autopromote
Returns the automatic promotion configuration.
autopromoteonce
Returns the automatic promotion configuration that are only done once.
Values (separate with | or alternative): autocreatetempuser, autopromote, autopromoteonce, clientlibraries, dbrepllag, defaultoptions, extensions, extensiontags, fileextensions, functionhooks, general, interwikimap, languages, languagevariants, libraries, magicwords, namespacealiases, namespaces, protocols, restrictions, rightsinfo, showhooks, skins, specialpagealiases, statistics, uploaddialog, usergroups, variables
Default: general
sifilteriw

Return only local or only nonlocal entries of the interwiki map.

One of the following values: !local, local
sishowalldb

List all database servers, not just the one lagging the most.

Type: boolean (details)
sinumberingroup

Lists the number of users in user groups.

Type: boolean (details)
siinlanguagecode

Language code for localised language names (best effort) and skin names.


Приклади

Запит GET

Отримати загальну інформацію про сайт

Response

{
    "batchcomplete": true,
    "query": {
        "general": {
            "mainpage": "Main Page",
            "base": "https://en.wikipedia.org/wiki/Main_Page",
            "sitename": "Wikipedia",
            ...
        }
    }
}

Приклад коду

Python

#!/usr/bin/python3

"""
    general_site_info.py

    MediaWiki API Demos
    Demo of `Siteinfo` module: Obtain general site info.

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "meta": "siteinfo",
    "formatversion": "2",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

PHP

<?php

/*
    general_site_info.php

    MediaWiki API Demos
    Demo of `Siteinfo` module: Obtain general site info.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "meta" => "siteinfo",
    "formatversion" => "2",
    "format" => "json"
];

$url = $endPoint . "?" . http_build_query( $params );

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );

echo( $output );

JavaScript

/*
    general_site_info.js

    MediaWiki API Demos
    Demo of `Siteinfo` module: Obtain general site info.

    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    meta: "siteinfo",
    formatversion: "2",
    format: "json"
};
request.get({ url: url, qs: params }, function(error, res, body) {
    if (error) {
        return;
    }
    console.log(body);
});

MediaWiki JS

/*
	general_site_info.js

    MediaWiki API Demos
    Demo of `Siteinfo` module: Obtain general site info.

    MIT License
*/

var params = {
    action: "query",
    meta: "siteinfo",
    formatversion: "2",
    format: "json"
},
api = new mw.Api();

api.get( params ).done( function ( data ) {
console.log( data );
} );

Результати

This section documents only those result sections where there are numerous or non-obvious return values. Results like those found in namespacealiases or libraries, where the meaning of each item can be readily inferred, are not listed here.

Розширення

  • type: The extension type. The same extension can be registered in more than one type, in which case the results will be repeated for each different type. Default values include specialpage, parserhook, variable, media, antispam, skin, api, and other. Extension-defined types are allowed, though only the coded value is emitted—there is currently no way to retrieve the user-friendly type name (as seen on Special:Version) via the API. 1.14+
  • name: The class name of the extension. 1.14+
  • namemsg: The system message name for the user-friendly name of the extension. 1.24+
  • description: User-friendly description of the extension. 1.14+
  • descriptionmsg: The system message name for the user-friendly description of the extension. This can be emitted in conjunction with the description value. 1.14+
  • descriptionmsgparams: If the descriptionmsg takes parameters, they will be emitted here as an array. 1.16+
  • author: The author or authors as a comma-delimited string. 1.14+
  • url: The URL for the homepage of the extensions. 1.16+
  • version: The version of the extension. This can be taken either from its version or svn-revision entry, with priority given to version in the event of a conflict. 1.14+
  • vcs-system: Which version control system is in use for the extension, if any. This can be either git or svn 1.23+
  • vcs-version: The version number of the extension in the version control system. 1.23+
  • vcs-url: The URL of the repository. 1.23+
  • vcs-date: (Git only) The date of the latest version. 1.23+
  • license-name: The license name under which the extension is published (e.g., GPL-2.0) 1.23+
  • license: The relative path to the license page published on the wiki (equivalent to Special:Version/License/Extension) 1.23+
  • credits: The relative path to the credits page published on the wiki (equivalent to Special:Version/Credits/Extension) 1.23+

General

The general option can return the following results:

  • articlepath: The relative or absolute path to any article. $1 should be replaced by the article name. See $wgArticlePath . 1.16+
  • base: The absolute path to the main page. 1.8+
  • case: Whether the first letter in a title is case-insensitive ("first-letter") or case-sensitive ("case-sensitive"). See $wgCapitalLinks . 1.8+
  • dbtype: The database type, as found in $wgDBtype . 1.16+
  • dbversion: The database version, as output by the relevant database (see dbtype, above). 1.16+
  • externalimages: If external images are disallowed by default, a list of URL fragments that are exceptions to that policy. See $wgAllowExternalImagesFrom . 1.22+
  • fallback: For wikis using language variants, a list of fallback languages for the UI and messages. 1.19+
  • fallback8bitEncoding: (Note the uppercase E.) The code page to use if a URL is not in UTF-8 format. See Language::fallback8bitencoding. 1.13+
  • favicon: The absolute URL to the site's Favicon. See $wgFavicon . 1.23+
  • generator: API version information as found in $wgVersion . 1.8+
  • git-branch: The current Git branch, if applicable. 1.24+
  • git-hash: The SHA1 hash of the HEAD of the current Git repository, if applicable. 1.20+
  • hhvmversion: If applicable, the HHVM version, as defined by the HHVM_VERSION constant. 1.24+
  • imagelimits: A list of maximum image sizes, as seen in preferences. See $wgImageLimits . 1.23+
  • imagewhitelistenabled: Whether the external image whitelist is enabled. See $wgEnableImageWhitelist . Тип: boolean 1.22+
  • invalidusernamechars: Characters to prevent during new account creations. See $wgInvalidUsernameCharacters . 1.26+
  • lang: The language code for the wiki. See $wgLanguageCode . 1.11+
  • langconversion: The boolean opposite of $wgDisableLangConversion . 1.21+
  • legaltitlechars: The Perl-compatible regular expression that defines all legal characters in a wiki title. See $wgLegalTitleChars . 1.25+
  • linkprefix: See linkprefixcharset, below. This version includes additional regular expression fragments before and after the character set, but is otherwise the same. 1.21+ (deprecated in 1.23)
  • linkprefixcharset: The Perl-compatible regular expression that defines any prefix characters that should be included as part of a wiki link. See Language::linkPrefixCharset(). 1.23+
  • linktrail: The Perl-compatible regular expression that defines any trailing characters that should be included as part of a wiki link. See Language::linkTrail(). 1.21+
  • : The protocol-relative path to the main logo based on $wgLogo . 1.22+
  • mainpage: The title of the main page, as found in MediaWiki:Mainpage. 1.8+
  • maxuploadsize: The maximum upload size on the wiki. See $wgMaxUploadSize . Note: this is always an integer for the primary maximum upload size; retrieving the by-URL size is not currently available. 1.20+
  • misermode: Whether the wiki is running in miser mode. See $wgMiserMode . 1.18+
  • phpsapi: The PHP Server API version, as defined by the PHP_SAPI constant. 1.16+
  • phpversion: The PHP version, as defined by the PHP_VERSION constant. 1.16+
  • readonly: Emitted if the wiki is in read-only mode. 1.13+
  • readonlyreason: The reason the wiki is in read-only mode, if applicable. See $wgReadOnly and $wgReadOnlyFile . 1.16+
  • rev: The revision number of the current Subversion build, if applicable. 1.12+
  • rights: The rights text. See $wgRightsText . 1.9-1.23 (removed in 1.23)
  • rightscode: This was intended to be the lower-case code associated with the wiki license (e.g., gfdl). In practice, however, Siteinfo was the only place it was ever used. 1.15-1.23 (removed in 1.23)
  • rtl: This will be emitted if the wiki's language reads right-to-left. 1.13+
  • script: The path of index.php relative to the document root. See $wgScript . 1.16+
  • scriptpath: The base URL path relative to the document root. See $wgScriptPath . 1.16+
  • server: The absolute or protocol-relative base URL for the server. See $wgServer . 1.16+
  • servername: The base URL of the server with no protocol or trailing slash. See $wgServerName . 1.24+
  • sitename: The name of the wiki from $wgSitename . 1.8+
  • thumblimits: A list of allowable thumbnail sizes. See $wgThumbLimits . 1.23+
  • time: The current time on the server, in ISO 8601 format. 1.16+
  • timeoffset: The offset of the wiki's time zone, in minutes, from UTC. See $wgLocalTZoffset . 1.13+
  • timezone: The name of the wiki's time zone. See $wgLocaltimezone . 1.13+
  • uploadsenabled: check if uploads are enabled 1.27+
  • titleconversion: The binary opposite of $wgDisableTitleConversion . 1.21+
  • variantarticlepath: Similar to articlepath, but incorporates appropriate language variant into the link as $2, if applicable. In JSON, this value can be emitted as false. See $wgVariantArticlePath . 1.16+
  • variants: All possible language variants for the wiki's parent language (e.g., zh, zh-hans, zh-cn, etc.). 1.20+
  • wikiid: An ASCII string identifying the wiki. See wfWikiID(). 1.16+
  • writeapi: Emitted if the API can be used to perform data-modifying actions like editing or deleting pages. See $wgEnableWriteAPI . 1.13+

Interwikimap

The attributes provided in each iw element include:

  • prefix: Is the prefix of the interwiki link; this is used the same way as a namespace is used when editing. 1.11+
  • local: Whether the interwiki prefix points to a site belonging to the current wiki farm. The value is read straight out of the iw_local column of the interwiki table. 1.11+
  • trans: Whether transcluding pages from this wiki is allowed. Note that this has no effect unless crosswiki transclusion is enabled on the current wiki. 1.23+
  • language: If the interwiki prefix is a language code defined in Language::fetchLanguageNames() from $wgExtraLanguageNames , this will be the name of that language. 1.13+
  • localinterwiki: Whether the interwiki link points to the current wiki, based on Special:MyLanguage/Manual:$wgLocalInterwikis. 1.24+
  • extralanglink: Whether the interwiki prefix is to be considered a language link, despite the prefix not matching a known language code. 1.24+
  • linktext: If the interwiki prefix is an extra language link, this will contain the display text used for the links. 1.24+
  • sitename: If the interwiki prefix is an extra language link, this will contain the friendly site name used in the tooltip text of the links. 1.24+
  • url: The URL of the wiki, with "$1" as a placeholder for an article name. 1.11+
  • protorel: Whether the value of url can be treated as protocol-relative. Note, however, that the URL actually returned will always include the current protocol. 1.24+
  • wikiid: The internal name of the database. Not filled in by default; it may be missing for you. The value is read straight out of the iw_wikiid column of the interwiki table. 1.18+
  • api: The URL of the file api.php on that wiki. Not filled in by default; it may be missing for you. The value is read straight out of the iw_api column of the interwiki table. 1.18+

Простори назв

Each namespace is given within its own element, which contains several attributes:

  • id: An integer identification number which is unique for each namespace.
  • case: Either "first-letter" or "case-sensitive". If the first letter of the namespace name is capitalized (the default), then the value of this attribute will be "first-letter". Otherwise, the value will be "case-sensitive" in order to indicate that the namespace name in question intentionally does not use a capital first letter. Note: "case-insensitive" is reserved for future use 1.16+
  • name: The displayed name for the namespace. In XML formats, this is the value for the ns element, not a property, and therefore has no name. In JSON, prior to MediaWiki 1.25, the parameter name was *.
  • subpages: This attribute indicates that subpages are allowed within the namespace. Тип: boolean 1.13+
  • canonical: Provides the canonical namespace name of the namespace, which may or may not be the same as the actual namespace name. For example, all wikis have a "Project:" namespace, but the actual namespace name is normally changed to the name of the wiki (on Wikipedia for example, the "Project:" namespace is "Wikipedia:"). 1.14+
  • content: This attribute indicates that pages within this namespace should be treated as the main content of the wiki. Pages within namespaces with the content value set are counted for statistical purposes, among other things. Тип: boolean 1.16+
  • nonincludable: Whether or not pages in this namespace can be transcluded. Тип: boolean 1.20+
  • defaultcontentmodel: The default content model for the namespace 1.21+

Restrictions

Provides information about the various forms of page protection available.

Rightsinfo

In the best case this will provide:

  • url: A URL for the license applied to the wiki. If $wgRightsPage is set, this will be the external link to that page; otherwise, $wgRightsUrl is used.
  • text: The text to display for the license link (usually the license name). If $wgRightsText is set, that value will be used; otherwise, the title of $wgRightsPage is used. Prior to version 1.23, the license text (only) was also provided in the general section.

Статистика

This section provides similar info to Special:Statistics, along with the number of jobs in the job queue, in the following elements:

  • pages: The total number of pages on the wiki, including talk pages, redirects, etc. 1.11+
  • articles: The number of content pages on the wiki. 1.11+
  • edits: The number of edits since the wiki began. 1.11+
  • images: The number of files in File space. 1.11+
  • users: The number of registered users. 1.11+
  • activeusers: The number of users who have performed an action in the last $wgActiveUserDays days. 1.14+
  • admins: The number of administrators on the site. 1.11+
  • jobs: The number of jobs remaining in the job queue. This number may be estimated. See Job queue for more information. 1.11+

Other statistics may be included via the APIQuerySiteInfoStatisticsInfo hook.

Usergroups

This retrieves a list of all groups on the wiki, along with their rights and possibly other statistics.

  • name: The internal name of the group. 1.13+
  • rights: The internal name of the rights for the group. For a description of each right, look at the same group on Special:ListGroupRights. 1.13+
  • number: The number of users in this group. This will not be emitted for the all-users (*) group or autopromoted groups. Requires sinumberingroup parameter to be set. 1.16+
  • add: Groups that members of this group can add other users to. 1.17+
  • remove: Groups that members of this group can remove other users from. 1.17+
  • add-self: Groups that members of this group can add themselves to. 1.17+
  • remove-self: Groups that members of this group can remove themselves from. 1.17+

Possible errors

Code Info
includeAllDenied Не можна переглядати інформацію щодо всіх серверів, якщо тільки $wgShowHostnames не вказано як «true».

Parameter history

  • v1.29: Introduced languagevariants
  • v1.25: Introduced libraries
  • v1.23: Introduced extensions, restrictions, defaultoptions
  • v1.21: Introduced protocols
  • v1.20: Introduced variables
  • v1.19: Introduced siinlanguagecode
  • v1.18: Introduced skins, extensiontags, functionhooks, showhooks
  • v1.16: Introduced languages, sinumberingroup
  • v1.15: Introduced fileextensions, rightsinfo
  • v1.14: Introduced magicwords
  • v1.13: Introduced specialpagealiases, usergroups
  • v1.12: Introduced namespacealiases
  • v1.11: Introduced interwikimap, sishowalldb, statistics, sifilteriw, sishowalldb

Additional notes

See also