راهنمای واسط برنامه‌نویسی کاربردی مدیاویکی

این یک صفحهٔ مستندات برای واسط برنامه‌نویسی کاربردی مدیاویکی است که به‌طور خودکار ایجاد شده‌است.

مستندات و نمونه‌ها: https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page

پودمان اصلی

وضعیت: تمام ویژگی‌هایی که در این صفحه نمایش یافته‌اند باید کار بکنند، ولی رابط برنامه‌نویسی کاربردی کماکان در حال توسعه است، و ممکن است در هر زمان تغییر بکند. به عضویت فهرست پست الکترونیکی mediawiki-api-announce در بیایید تا از تغییرات باخبر شوید.

درخواست‌های معیوب: وقتی درخواست‌های معیوب به رابط برنامه‌نویسی کاربردی فرستاده شوند، یک سرایند اچ‌تی‌تی‌پی با کلید «MediaWiki-API-Erorr» فرستاده می‌شود و بعد هم مقدار سرایند و هم کد خطای بازگردانده شده هر دو به یک مقدار نسبت داده می‌شوند. برای اطلاعات بیشتر API: Errors and warnings را ببینید.

آزمایش: برای انجام درخواست‌های API آزمایشی Special:ApiSandbox را ببینید.

پارامترها:
action

کدام عملیات را انجام دهد.

abusefiltercheckmatch
بررسی کنید تا ببینید پالایهٔ ویرایش با مجموعه‌ای از متغیرها، یک ویرایش، یا یک رویداد سیاههٔ پالایهٔ ویرایش کاربر مطابق است یا خیر.
abusefilterchecksyntax
نحو یک پالایهٔ ویرایش را بررسی کنید.
abusefilterevalexpression
یک عبارت پالایهٔ ویرایش را ارزشیابی می‌کند.
abusefilterunblockautopromote
باز کردن یک کاربر از ارتقاء خودکار بر پایهٔ نتیجهٔ پالایهٔ ویرایش.
abuselogprivatedetails
مشاهدهٔ جزئیات خصوصی یک مدخل سیاههٔ ویرایش.
block
بستن یک کاربر.
changeauthenticationdata
تغییر دادۀ اصالت‌سنجی برای کاربر کنونی
changecontentmodel
تغییر مدل محتوای یک صفحه
checktoken
بررسی اعتبار بلیط از action=query&meta=tokens.
clearhasmsg
پرچم hasmsg را برای کاربر جاری پاک کن.
clientlogin
Log in to the wiki using the interactive flow.
compare
تفاوت بین ۲ صفحه را بیابید.
createaccount
ایجاد یک حساب تازه کاربری
delete
حذف صفحه
echomarkread
علامت گذاری آگاه‌سازی‌ها به عنوان خوانده شده برای کاربر کنونی
echomarkseen
علامت گذاری آگاه‌سازی‌ها به عنوان دیده شده برای کاربر کنونی.
echomute
بی‌صدا یا باصدا کردن اعلان‌ها از کاربران یا صفحه‌های خاص.
edit
ایجاد و ویرایش صفحه
editmassmessagelist
ویرایش فهرست گیرندگان پیام انبوه.
emailuser
ایمیل به کاربر
embedvideo
Get generated video embed code for given parameters.
expandtemplates
گسترش همه الگوها در ویکی نبشته
feedcontributions
خوراک مشارکت‌های یک کاربر را برمی‌گرداند.
feedrecentchanges
خوراک تغییرات اخیر را برمی‌گرداند.
feedwatchlist
برگرداندن خوراک فهرست پیگیری‌.
filerevert
واگردانی فایل به یک نسخه قدیمی
help
نمایش راهنمای پودمان‌های مشخص‌شده.
imagerotate
چرخاندن یک یا چند تصویر
import
Import a page from another wiki, or from an XML file.
linkaccount
Link an account from a third-party provider to the current user.
login
Log in and get authentication cookies.
logout
خروج به همراه پاک نمودن اطلاعات این نشست
managetags
Perform management tasks relating to change tags.
massmessage
فرستادن یک پیام به فهرستی از صفحه‌ها.
mergehistory
ادغام تاریخچه‌های صفحه
move
انتقال صفحه
opensearch
جستجو در ویکی بااستفاده از پروتکل اوپن‌سرچ.
options
تغییر ترجیحات کاربر جاری
paraminfo
Obtain information about API modules.
parse
Parses content and returns parser output.
patrol
گشت‌زنی یک صفحه یا نسخهٔ ویرایشی.
protect
تغییر سطح محافظت صفحه
purge
Purge the cache for the given titles.
query
Fetch data from and about MediaWiki.
removeauthenticationdata
Remove authentication data for the current user.
resetpassword
Send a password reset email to a user.
revisiondelete
Delete and undelete revisions.
rollback
Undo the last edit to the page.
rsd
Export an RSD (Really Simple Discovery) schema.
setnotificationtimestamp
Update the notification timestamp for watched pages.
setpagelanguage
Change the language of a page.
spamblacklist
Validate one or more URLs against the spam block list.
tag
Add or remove change tags from individual revisions or log entries.
templatedata
واکشی داده‌های ذخیره‌شده توسط افزونهٔ الگوداده.
titleblacklist
Validate a page title, filename, or username against the TitleBlacklist.
unblock
بازکردن کاربر.
undelete
احیای نسخه‌های یک صفحهٔ حذف‌شده.
unlinkaccount
Remove a linked third-party account from the current user.
upload
بارگذاری یک پرونده یا دریافت وضعیت بارگذاری‌های در انتظار.
userrights
تغییر گروهی که کاربر در آن عضو است.
validatepassword
Validate a password against the wiki's password policies.
watch
Add or remove pages from the current user's watchlist.
webapp-manifest
بازگشت بیانیهٔ اپلیکیشن وب
categorytree
داخلی پودمان داخلی برای افزونهٔ درخت رده
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.
record-lint
داخلی ذخیره خطاهای نحوی پنهان در پایگاه داده
scribunto-console
داخلی Internal module for servicing XHR requests from the Scribunto console.
stashedit
داخلی Prepare an edit in shared cache.
visualeditor
داخلی HTML5 یک صفحه را از خدمت پارسوید برمی‌گرداند.
visualeditoredit
داخلی ذخیره صفحه HTML5 به مدیاویکی (تبدیل به متن ویکی با سرویس پارسوید)
یکی از مقدارهای زیر: abusefiltercheckmatch، abusefilterchecksyntax، abusefilterevalexpression، abusefilterunblockautopromote، abuselogprivatedetails، block، changeauthenticationdata، changecontentmodel، checktoken، clearhasmsg، clientlogin، compare، createaccount، delete، echomarkread، echomarkseen، echomute، edit، editmassmessagelist، emailuser، embedvideo، expandtemplates، feedcontributions، feedrecentchanges، feedwatchlist، filerevert، help، imagerotate، import، linkaccount، login، logout، managetags، massmessage، mergehistory، move، opensearch، options، paraminfo، parse، patrol، protect، purge، query، removeauthenticationdata، resetpassword، revisiondelete، rollback، rsd، setnotificationtimestamp، setpagelanguage، spamblacklist، tag، templatedata، titleblacklist، unblock، undelete، unlinkaccount، upload، userrights، validatepassword، watch، webapp-manifest، categorytree، cspreport، record-lint، scribunto-console، stashedit، visualeditor، visualeditoredit
پیش‌فرض: help
format

فرمت خروجی.

json
خروجی داده در قالب جی‌سان.
jsonfm
خروجی داده در قالب جی‌سان (چاپ زیبا در اچ‌تی‌ام‌ال).
none
بیرون‌ریزی هیچ.
php
Output data in serialized PHP format.
phpfm
Output data in serialized PHP format (pretty-print in HTML).
rawfm
Output data, including debugging elements, in JSON format (pretty-print in HTML).
xml
Output data in XML format.
xmlfm
Output data in XML format (pretty-print in HTML).
یکی از مقدارهای زیر: json، jsonfm، none، php، phpfm، rawfm، xml، xmlfm
پیش‌فرض: 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

تنظيم s-maxage سرآیند کنترل حافضهٔ نهان HTTP بر اين تعداد ثانيه‌ها. خطاها هرگز در حافظه نهان نمی‌شوند.

نوع: عدد صحیح
پیش‌فرض: 0
assert

تأیید این که کاربر وارد سامانه شده با تنظیم روی user، وارد سامانه نشده در صورت تنظیم روی anon یا دارای پرچم ربات در صورتی تنظیم روی bot.

یکی از مقدارهای زیر: anon، bot، user
assertuser

تأیید این که کاربر کنونی همان کاربر نام‌دار است.

نوع: کاربر، توسط نام کاربری
requestid

هر مقداری که در اینجا وارد شود در پاسخ گنجانده می‌شود. ممکن است برای تمايز بين درخواست‌ها بکار رود.

servedby

نام ميزبانی که درخواست را سرويس داده در نتايج گنجانده شود.

نوع: بولی (جزئیات)
curtimestamp

برچسب زمان کنونی را در نتیجه قرار دهید.

نوع: بولی (جزئیات)
responselanginfo

گنجاندن زبان مورد استفاده برای userlang و errorlang در نتیجه.

نوع: بولی (جزئیات)
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

Language to use for message translations. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify user to use the current user's language preference, or specify content to use this wiki's content language.

پیش‌فرض: user
variant

گونهٔ زبان. تنها در صورتی کار می‌کند که زبان مبنا از تبدیل گونه پشتیبانی کند.

errorformat

قالبی به‌منظور استفاده برای متن خروجی هشدار و خطا

plaintext
ویکی‌متن با برچسب‌های اچ‌تی‌ام‌ال حذف‌شده و موجودیت‌های جایگزین‌شده.
wikitext
ویکی‌متن تجزیه‌نشده.
html
HTML
raw
کلید پیام و پارامترها.
none
بدون متن خروجی، فقط شناسه‌های خطا.
bc
قالب مورد استفاده تا پیش از مدیاویکی ۱.۲۹. از errorlang و errorsuselocal چشم‌پوشی می‌شود.
یکی از مقدارهای زیر: bc، html، none، plaintext، raw، wikitext
پیش‌فرض: bc
errorlang

Language to use for warnings and errors. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify content to use this wiki's content language, or specify uselang to use the same value as the uselang parameter.

پیش‌فرض: uselang
errorsuselocal

در صورت وارد شدن، متن خطاها از پیام‌های سفارشی‌سازی‌شدهٔ محلی از فضای نام مدیاویکی استفاده خواهند کرد.

نوع: بولی (جزئیات)
نمونه‌ها:
راهنما برای پودمان اصلی.
api.php?action=help [باز کردن در صفحهٔ تمرین]
همهٔ راهنماها در یک صفحه.
api.php?action=help&recursivesubmodules=1 [باز کردن در صفحهٔ تمرین]
Permissions:
writeapi
به‌کارگیری API نوشتن
Granted to: 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.
Granted to: bot و sysop

Data types

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

Boolean parameters work like HTML checkboxes: if the parameter is specified, regardless of value, it is considered true. For a false value, omit the parameter entirely.

expiry

Expiry values may be relative (e.g. 5 months or 2 weeks) or absolute (e.g. 2014-09-18T12:34:56Z). For no expiry, use infinite, indefinite, infinity or 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 developers:

  • Yuri Astrakhan (creator, lead developer Sep 2006–Sep 2007)
  • Roan Kattouw (lead developer Sep 2007–2009)
  • Victor Vasiliev
  • Bryan Tong Minh
  • Sam Reed
  • Brad Jorsch (lead developer 2013–2020)

Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org or file a bug report at https://phabricator.wikimedia.org/.