MediaWiki API ヘルプ

このページは自動生成された MediaWiki API の説明文書ページです。

説明文書と例: https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page

メイン モジュール

状態: MediaWiki APIは、積極的にサポートされ、改善された成熟した安定したインターフェースです。避けようとはしていますが、時には破壊的変更を行う必要があるかもしれません。更新の通知を受け取るには、mediawiki-api-announce メーリングリストに参加してください。 誤ったリクエスト: 誤ったリクエストが API に送られた場合、"MediaWiki-API-Error" HTTP ヘッダーが送信され、そのヘッダーの値と送り返されるエラーコードは同じ値にセットされます。より詳しい情報は API:Errors and warnings を参照してください。

パラメーター:
action

実行する操作です。

block
利用者をブロックします。
changeauthenticationdata
現在の利用者の認証データを変更します。
changecontentmodel
Change the content model of a page
checktoken
action=query&meta=tokens のトークンの妥当性を確認します。
clearhasmsg
現在の利用者の hasmsg フラグを消去します。
clientlogin
インタラクティブフローを使用してウィキにログインします。
compare
2つの版間の差分を取得します。
createaccount
新しい利用者アカウントを作成します。
delete
ページを削除します。
edit
ページを作成、編集します。
emailuser
利用者にメールを送信します。
expandtemplates
ウィキテキストに含まれるすべてのテンプレートを展開します。
feedcontributions
利用者の投稿記録フィードを返します。
feedrecentchanges
最近の更新フィードを返します。
feedwatchlist
ウォッチリストのフィードを返します。
filerevert
ファイルを古い版に差し戻します。
help
指定したモジュールのヘルプを表示します。
imagerotate
1つ以上の画像を回転させます。
import
別のウィキまたはXMLファイルからページをインポートする。
linkaccount
Link an account from a third-party provider to the current user.
login
ログインして認証クッキーを取得します。
logout
ログアウトしてセッションデータを消去します。
managetags
Perform management tasks relating to change tags.
mergehistory
ページの履歴を統合する。
move
ページを移動します。
opensearch
OpenSearch プロトコルを使用してウィキ内を検索します。
options
現在の利用者の設定を変更します。
paraminfo
API モジュールに関する情報を取得します。
parse
Parses content and returns parser output.
patrol
ページまたは版を巡回済みにする。
protect
ページの保護レベルを変更します。
purge
指定されたページのキャッシュを破棄します。
query
MediaWikiからデータを取得します。
removeauthenticationdata
Remove authentication data for the current user.
resetpassword
利用者にパスワードをリセットするメールを送信します。
revisiondelete
版の削除および復元を行います。
rollback
ページの最後の編集を取り消す。
rsd
Export an RSD (Really Simple Discovery) schema.
setnotificationtimestamp
Update the notification timestamp for watched pages.
setpagelanguage
ページの言語を変更します。
tag
個々の版または記録項目に対しタグの追加または削除を行います。
unblock
利用者のブロックを解除します。
undelete
削除されたページの版を復元します。
unlinkaccount
Remove a linked third-party account from the current user.
upload
Upload a file, or get the status of pending uploads.
userrights
利用者の所属グループを変更します。
validatepassword
Validate a password against the wiki's password policies.
watch
現在の利用者のウォッチリストにページを追加/除去します。
cspreport
内部で使用。 Used by browsers to report violations of the Content Security Policy. This module should never be used, except when used automatically by a CSP compliant web browser.
stashedit
内部で使用。 Prepare an edit in shared cache.
値 (次の値のいずれか1つ): blockchangeauthenticationdatachangecontentmodelchecktokenclearhasmsgclientlogincomparecreateaccountdeleteeditemailuserexpandtemplatesfeedcontributionsfeedrecentchangesfeedwatchlistfilereverthelpimagerotateimportlinkaccountloginlogoutmanagetagsmergehistorymoveopensearchoptionsparaminfoparsepatrolprotectpurgequeryremoveauthenticationdataresetpasswordrevisiondeleterollbackrsdsetnotificationtimestampsetpagelanguagetagunblockundeleteunlinkaccountuploaduserrightsvalidatepasswordwatchcspreportstashedit
既定: help
format

出力する形式です。

json
データを JSON 形式で出力します。
jsonfm
データを JSON 形式 (HTML に埋め込んだ形式) で出力します。
none
何も出力しません。
php
データを PHP のシリアル化した形式で出力します。
phpfm
データを PHP のシリアル化した形式 (HTML に埋め込んだ形式) で出力します。
rawfm
データをデバッグ要素付きで JSON 形式 (HTML に埋め込んだ形式) で出力します。
xml
データを XML 形式で出力します。
xmlfm
データを XML 形式 (HTML に埋め込んだ形式) で出力します。
値 (次の値のいずれか1つ): jsonjsonfmnonephpphpfmrawfmxmlxmlfm
既定: jsonfm
maxlag

Maximum lag can be used when MediaWiki is installed on a database replicated cluster. To save actions causing any more site replication lag, this parameter can make the client wait until the replication lag is less than the specified value. In case of excessive lag, error code maxlag is returned with a message like Waiting for $host: $lag seconds lagged.
See Manual: Maxlag parameter for more information.

型: 整数
smaxage

s-maxage HTTP キャッシュ コントロール ヘッダー に、この秒数を設定します。エラーがキャッシュされることはありません。

型: 整数
既定: 0
maxage

max-age HTTP キャッシュ コントロール ヘッダー に、この秒数を設定します。エラーがキャッシュされることはありません。

型: 整数
既定: 0
assert

user に設定した場合は利用者がログインしていることを、 anon に設定した場合はログインしていないことを、bot の場合はボット利用者権限があることを検証します。

値 (次の値のいずれか1つ): anon、bot、user
assertuser

現在の利用者が指定された利用者であることを確認します。

型: 利用者名を使った利用者
requestid

任意の値を指定でき、その値が結果に含められます。リクエストを識別するために使用できます。

servedby

リクエストを処理したホスト名を結果に含めます。

型: 真偽値 (詳細)
curtimestamp

現在のタイムスタンプを結果に含めます。

型: 真偽値 (詳細)
responselanginfo

結果にuselangerrorlangに使用される言語を含めます。

型: 真偽値 (詳細)
origin

When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body).

For authenticated requests, this must match one of the origins in the Origin header exactly, so it has to be set to something like https://en.wikipedia.org or https://meta.wikimedia.org. If this parameter does not match the Origin header, a 403 response will be returned. If this parameter matches the Origin header and the origin is allowed, the Access-Control-Allow-Origin and Access-Control-Allow-Credentials headers will be set.

For non-authenticated requests, specify the value *. This will cause the Access-Control-Allow-Origin header to be set, but Access-Control-Allow-Credentials will be false and all user-specific data will be restricted.

uselang

メッセージの翻訳に使用する言語です。action=query&meta=siteinfosiprop=languages を付けると言語コードの一覧を返します。user を指定することで現在の利用者の個人設定の言語を、content を指定することでこのウィキの本文の言語を使用することもできます。

既定: user
variant

言語変種。基本言語が言語変種変換をサポートしている場合のみ機能します。

errorformat

警告およびエラーテキストの出力に使用する形式

plaintext
HTMLタグを除去し、実体を置換したウィキテキスト。
wikitext
パースされていないウィキテキスト。
html
HTML
raw
メッセージキーとパラメーター。
none
テキスト出力なし、エラーコードのみ。
bc
MediaWiki 1.29より前に使われていた形式。 errorlang および errorsuselocal は無視されます。
値 (次の値のいずれか1つ): bc、html、none、plaintext、raw、wikitext
既定: bc
errorlang

警告およびエラーで使用する言語。 action=query&meta=siteinfosiprop=languages があると言語コードの一覧を返し、 content を指定するとこのウィキのコンテンツ言語を使用し、uselang を指定すると uselang パラメーターと同じ値を使用します。

既定: uselang
errorsuselocal

指定された場合、エラーテキストはMediaWiki名前空間からローカルにカスタマイズされたメッセージを使用します。

型: 真偽値 (詳細)
例:
メイン モジュールのヘルプ
api.php?action=help [サンドボックスで開く]
すべてのヘルプを1つのページに
api.php?action=help&recursivesubmodules=1 [サンドボックスで開く]
権限:
writeapi
書き込み API を使用
権限を持つグループ: all、user および bot
apihighlimits
Use higher limits in API queries (slow queries: 500; fast queries: 5000). The limits for slow queries also apply to multivalue parameters.
権限を持つグループ: bot および sysop

データ型

Input to MediaWiki should be NFC-normalized UTF-8. MediaWiki may attempt to convert other input, but this may cause some operations (such as edits with MD5 checks) to fail.

Parameters that take multiple values are normally submitted with the values separated using the pipe character, e.g. param=value1|value2 or param=value1%7Cvalue2. If a value must contain the pipe character, use U+001F (Unit Separator) as the separator and prefix the value with U+001F, e.g. param=%1Fvalue1%1Fvalue2.

Some parameter types in API requests need further explanation:

boolean

真偽値のパラメーターはHTMLのチェックボックスのように機能します: パラメーターが指定されていれば、値に関わらず、真であると推定します。偽の値については、パタメーター自体を省略してください。

expiry

期間は、相対値(例えば、5 months2 weeks)または絶対値(例えば、2014-09-18T12:34:56Z)のどちらかで指定します。期間を定めない場合は、infinite, indefinite, infinity または never を用います。

timestamp

Timestamps may be specified in several formats, see the Timestamp library input formats documented on mediawiki.org for details. ISO 8601 date and time is recommended: 2001-01-15T14:56:00Z. Additionally, the string now may be used to specify the current timestamp.

Templated parameters

Templated parameters support cases where an API module needs a value for each value of some other parameter. For example, if there were an API module to request fruit, it might have a parameter fruits to specify which fruits are being requested and a templated parameter {fruit}-quantity to specify how many of each fruit to request. An API client that wants 1 apple, 5 bananas, and 20 strawberries could then make a request like fruits=apples|bananas|strawberries&apples-quantity=1&bananas-quantity=5&strawberries-quantity=20.

クレジット

API の開発者:

  • Yuri Astrakhan (作成者、2006年9月-2007年9月の主任開発者)
  • Roan Kattouw (2007年9月-2009年の主任開発者)
  • Victor Vasiliev
  • Bryan Tong Minh
  • Sam Reed
  • Brad Jorsch (2013年-2020年の主任開発者)

コメント、提案、質問は mediawiki-api@lists.wikimedia.org にお送りください。 バグはこちらへご報告ください: https://phabricator.wikimedia.org/