Trợ giúp về API MediaWiki
This is an auto-generated MediaWiki Action API documentation page.
General information
Status: The MediaWiki API is a mature and stable interface that is actively supported and improved. While we try to avoid it, we may occasionally need to make breaking changes; subscribe to the mediawiki-api-announce mailing list for notice of updates.
Erroneous requests: When erroneous requests are sent to the API, an HTTP header will be sent with the key "MediaWiki-API-Error" and then both the value of the header and the error code sent back will be set to the same value. For more information see API: Errors and warnings.
Testing: For ease of testing API requests, see Special:ApiSandbox.
Request methods
Action API requests may use GET and POST methods. Prefer using the GET method, which allows requests to be routed to faster replica servers and responses to be cached, unless the length of the URL with parameters would exceed its length limit (commonly 8000 bytes), or a module only accepts POST requests.
Parameters for POST requests may be sent in the query part of the request URL (like in GET requests) and in the POST request body, and mixing both ways in one request is allowed. Certain parameters such as passwords must be sent in the request body. If the same parameter is sent as part of the URL and also in the request body, it must have the same value in both places.
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. The string now may be used to specify the current time.
Limits
Most API modules can accept up to 50 inputs in multivalue parameters, and can return up to 500 results per query (50 results for slow queries).
For users with the apihighlimits right (Bot và Bảo quản viên), the limits are increased to 500 inputs and 5.000 results (500 results for slow queries).
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.
Mô đun chính
- Source: MediaWiki
- License: GPL-2.0-or-later
Specify the action to perform, the format of the response, and options that apply to all API modules.
- action
Tác vụ nào để thực hiện. Tham số này nên được gửi như một phần của URL yêu cầu (không phải thân POST) để dễ dàng sử dụng trong việc gỡ lỗi, phân tích và định tuyến hoặc lọc yêu cầu.
- abusefiltercheckmatch
- Kiểm tra xem bộ lọc sai phạm có khớp với một tập hợp các biến, một sửa đổi hoặc một mục nhật trình sai phạm hay không.
- abusefilterchecksyntax
- Kiểm tra cú pháp của bộ lọc sai phạm.
- abusefilterevalexpression
- Đánh giá một biểu thức bộ lọc sai phạm.
- abusefilterunblockautopromote
- Bỏ cấm một người dùng khỏi việc tự động cấp quyền do kích hoạt bộ lọc.
- abuselogprivatedetails
- Xem chi tiết riêng tư của nhật trình sai phạm.
- acquiretempusername
- Nếu tính năng tạo tài khoản tạm thời được kích hoạt và thành viên hiện tại đã đăng xuất, hàm sẽ lấy tên người dùng thành viên tạm thời và lưu trữ nó trong phiên hiện tại. Nếu một tên đã được lưu trữ sẵn, hàm sẽ trả về chính tên đó.
- antispoof
- Kiểm tra xem tên người dùng qua quá trình kiểm tra tiêu chuẩn của AntiSpoof.
- block
- Cấm người dùng.
- centralauthtoken
- Fetch a centralauthtoken for making an authenticated request to an attached wiki.
- centralnoticecdncacheupdatebanner
- Request the purge of banner content stored in the CDN (front-end) cache for anonymous users, for the requested banner and language
- centralnoticechoicedata
- Get data needed to choose a banner for a given project and language
- centralnoticequerycampaign
- Get all configuration settings for a campaign.
- changeauthenticationdata
- Change authentication data for the current user.
- changecontentmodel
- Change the content model of a page
- checktoken
- Check the validity of a token from action=query&meta=tokens.
- clearhasmsg
- Xóa cờ
hasmsgcho người dùng hiện tại. - clientlogin
- Log in to the wiki using the interactive flow.
- communityconfigurationedit
- Change the content of a configuration provider in Community configuration
- compare
- Get the difference between two pages.
- createaccount
- Mở tài khoản mới.
- createlocalaccount
- Forcibly create a local account. The central account must exist.
- cxdelete
- Delete a draft translation created using the Content Translation extension.
- cxtoken
- Get JWT tokens to authenticate with cxserver.
- delete
- Xóa trang.
- deleteglobalaccount
- Delete a global user.
- discussiontoolsedit
- Đăng lời bình luận trên một trang thảo luận.
- discussiontoolsfindcomment
- Find a comment by its ID or name.
- discussiontoolsgetsubscriptions
- Nhận trạng thái theo dõi của các chủ đề nhất định.
- discussiontoolssubscribe
- Theo dõi (hoặc ngừng theo dõi) để nhận thông báo về một chủ đề.
- discussiontoolsthank
- Send a public thank-you notification for a comment.
- echocreateevent
- Manually trigger a notification to a user
- echomarkread
- Mark notifications as read for the current user.
- echomarkseen
- Mark notifications as seen for the current user.
- echomute
- Mute or unmute notifications from certain users or pages.
- edit
- Tạo và sửa trang.
- editmassmessagelist
- Sửa danh sách gửi thông báo hàng loạt.
- emailuser
- Gửi thư cho người dùng.
- expandtemplates
- Bung tất cả bản mẫu trong mã wiki.
- featuredfeed
- Returns a featured content feed.
- feedcontributions
- Trả về nguồn cấp đóng góp người dùng.
- feedrecentchanges
- Trả về nguồn cấp thay đổi gần đây.
- feedwatchlist
- Trả về nguồn cấp danh sách theo dõi.
- filerevert
- Phục hồi một tập tin sang một phiên bản cũ.
- globalblock
- Globally block or unblock a user.
- globalpreferenceoverrides
- Change local overrides for global preferences for the current user.
- globalpreferences
- Change global preferences of the current user.
- globaluserrights
- Add/remove a user to/from global groups.
- growthmanagementorlist
- Manage information in the structured mentor list (usually stored in MediaWiki:GrowthMentors.json). This module can be used by both current and future mentors (to add themselves or change their details) and administrators (for all users).
- growthmentordashboardupdatedata
- Schedule an extraordinary update of the mentee overview module in the mentor dashboard. You can only schedule one update per two hours for performance reasons.
- growthsetmenteestatus
- Set mentee's status (allows mentees to enable/disable mentorship module, or to opt-out entirely, which deletes the mentee/mentor relationship)
- growthsetmentor
- Đặt cố vấn của người dùng. Thay đổi sẽ được ghi lại một cách công khai.
- growthstarmentee
- Đánh dấu hoặc bỏ đánh dấu sao một người được cố vấn bởi người dùng hiện tại (lưu trữ riêng tư và không được ghi lại)
- help
- Hiển thị trợ giúp cho các mô-đun xác định.
- homepagequestionstore
- Lấy các câu hỏi được định dạng được đăng qua các mô-đun trang chủ
- imagerotate
- Mô đun này đã bị vô hiệu hóa.
- import
- Import a page from another wiki, or from an XML file.
- jsonconfig
- Allows direct access to JsonConfig subsystem.
- languagesearch
- Tìm kiếm tên ngôn ngữ trong bất kỳ tập lệnh nào.
- linkaccount
- Link an account from a third-party provider to the current user.
- login
- Log in and get authentication cookies.
- logout
- Thoát ra và xóa dữ liệu phiên làm việc.
- managetags
- Perform management tasks relating to change tags.
- massmessage
- Gửi thông báo đến một danh sách các trang.
- mergehistory
- Hợp nhất lịch sử trang.
- move
- Di chuyển trang.
- opensearch
- Tìm kiếm trong wiki qua giao thức OpenSearch.
- options
- Change preferences of the current user.
- paraminfo
- Lấy thông tin về các module API.
- parse
- Parses content and returns parser output.
- patrol
- Patrol a page or revision.
- protect
- Change the protection level of a page.
- 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
- Lùi lại sửa đổi gần đây nhất trên trang này.
- rsd
- Export an RSD (Really Simple Discovery) schema.
- setglobalaccountstatus
- Hide or lock (or unhide or unlock) a global user account.
- setnotificationtimestamp
- Update the notification timestamp for watched pages.
- setpagelanguage
- Change the language of a page.
- shortenurl
- Shorten a long URL into a shorter one.
- sitematrix
- Get Wikimedia sites list.
- spamblacklist
- Validate one or more URLs against the spam block list.
- streamconfigs
- Exposes event stream config. Returns only format=json with formatversion=2.
- strikevote
- Allows admins to strike or unstrike a vote.
- sxdelete
- Delete the draft section translation and its parallel corpora from database.
- tag
- Add or remove change tags from individual revisions or log entries.
- templatedata
- Trích xuất dữ liệu được lưu bởi phần mở rộng TemplateData.
- thank
- Gửi thông báo cảm ơn đến một biên tập viên.
- titleblacklist
- Validate a page title, filename, or username against the TitleBlacklist.
- torblock
- Check if an IP address is blocked as a Tor exit node.
- transcodereset
- Users with the 'transcode-reset' right can reset and re-run a transcode job.
- unblock
- Unblock a user.
- undelete
- Undelete revisions of a deleted page.
- unlinkaccount
- Remove a linked third-party account from the current user.
- upload
- Upload a file, or get the status of pending uploads.
- userrights
- Change a user's group membership.
- validatepassword
- Validate a password against the wiki's password policies.
- watch
- Add or remove pages from the current user's watchlist.
- webapp-manifest
- Trả về bảng kê khai ứng dụng web.
- webauthn
- Mô-đun API để giao tiếp giữa máy chủ và máy khách trong quá trình đăng ký/xác thực.
- wikilove
- Give WikiLove to another user.
- bouncehandler
- Internal. Receive a bounce email and process it to handle the failing recipient.
- categorytree
- Internal. Internal module for the CategoryTree extension.
- chartinfo
- Internal. Retrieve current count of how many unique Chart page usages there are. Multiple uses of the same chart on the same page are considered a single use.
- cirrus-check-sanity
- Internal. Reports on the correctness of a range of page ids in the search index
- cirrus-config-dump
- Internal. Dump of CirrusSearch configuration.
- cirrus-profiles-dump
- Internal. Dump of CirrusSearch profiles for this wiki.
- cirrus-schema-dump
- Internal. Dump of CirrusSearch schema (settings and mappings) for this wiki.
- codemirror-validate
- Internal. Kiểm tra lỗi trong nội dung đã cho
- collection
- Internal. API module for performing various operations on a wiki user's collection.
- cspreport
- Internal. 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.
- cxcheckunreviewed
- Internal. Check if any fast, unreviewed translation has been published recently for the current user.
- cxfavoritesuggestions
- Internal. Add or remove a favorite suggestion to the current user's list.
- cxpublish
- Internal. Save a page created using the Content Translation extension.
- cxpublishsection
- Internal. Save a section created using the Content Translation extension's section translation feature.
- cxsave
- Internal. This module allows to save draft translations by section to save bandwidth and to collect parallel corpora.
- cxsplit
- Internal. Create and save a section translation to database, for every translated section of the given article translation
- discussiontoolscompare
- Internal. Nhận thông tin về các thay đổi bình luận giữa hai lần sửa đổi trang.
- discussiontoolspageinfo
- Internal. Trả về siêu dữ liệu cần thiết để khởi tạo công cụ thảo luận.
- discussiontoolspreview
- Internal. Preview a message on a discussion page.
- echopushsubscriptions
- Internal. Manage push subscriptions for the current user.
- editcheckreferenceurl
- Internal. Check the status of a URL for use as a reference.
- fancycaptchareload
- Internal. Get a new FancyCaptcha.
- growthinvalidateimagerecommendation
- Internal. Invalidate an image recommendation.
- growthinvalidatepersonalizedpraisesuggestion
- Internal. Invalidates a suggestion of a praiseworthy mentee in the Personalized praise module on the Mentor dashboard
- growthinvalidaterevisetonerecommendation
- Internal. Drop a 'Revise Tone' recommendation for a given page.
- helppanelquestionposter
- Internal. Xử lý các câu hỏi được đăng qua cửa sổ trợ giúp cho người dùng hiện tại.
- jsondata
- Internal. Retrieve localized JSON data.
- jsontransform
- Internal. Retrieve JSON data transformed by a Lua function.
- parser-migration
- Internal. Parse a page with two different parser configurations.
- readinglists
- Internal. Thao tác ghi danh sách đọc.
- sanitize-mapdata
- Internal. Performs data validation for Kartographer extension
- scribunto-console
- Internal. Mô đun nội bộ để phản hồi các yêu cầu XHR từ console Scribunto.
- securepollauth
- Internal. Allows a remote wiki to authenticate users before granting access to vote in the election.
- stashedit
- Internal. Prepare an edit in shared cache.
- sxsave
- Internal. Save the draft section translation and store the parallel corpora
- timedtext
- Internal. Provides timed text content for usage by <track> elements
- ulslocalization
- Internal. Lấy bản dịch ULS trong ngôn ngữ được chỉ định.
- ulssetlang
- Internal. Cập nhật ngôn ngữ giao diện ưa thích của người dùng.
- visualeditor
- Internal. Returns HTML5 for a page from the Parsoid service.
- visualeditoredit
- Internal. Save an HTML5 page to MediaWiki (converted to wikitext via the Parsoid service).
- wikimediaeventsblockededit
- Internal. Log information about blocked edit attempts
- wikimediaeventshcaptchaeditattempt
- Internal. Log edit diff when hCaptcha challenge is shown but edit is incomplete
- Một trong các giá trị: abusefiltercheckmatch, abusefilterchecksyntax, abusefilterevalexpression, abusefilterunblockautopromote, abuselogprivatedetails, acquiretempusername, antispoof, block, centralauthtoken, centralnoticecdncacheupdatebanner, centralnoticechoicedata, centralnoticequerycampaign, changeauthenticationdata, changecontentmodel, checktoken, clearhasmsg, clientlogin, communityconfigurationedit, compare, createaccount, createlocalaccount, cxdelete, cxtoken, delete, deleteglobalaccount, discussiontoolsedit, discussiontoolsfindcomment, discussiontoolsgetsubscriptions, discussiontoolssubscribe, discussiontoolsthank, echocreateevent, echomarkread, echomarkseen, echomute, edit, editmassmessagelist, emailuser, expandtemplates, featuredfeed, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, globalblock, globalpreferenceoverrides, globalpreferences, globaluserrights, growthmanagementorlist, growthmentordashboardupdatedata, growthsetmenteestatus, growthsetmentor, growthstarmentee, help, homepagequestionstore, imagerotate, import, jsonconfig, languagesearch, linkaccount, login, logout, managetags, massmessage, mergehistory, move, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata, resetpassword, revisiondelete, rollback, rsd, setglobalaccountstatus, setnotificationtimestamp, setpagelanguage, shortenurl, sitematrix, spamblacklist, streamconfigs, strikevote, sxdelete, tag, templatedata, thank, titleblacklist, torblock, transcodereset, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, webapp-manifest, webauthn, wikilove, bouncehandler, categorytree, chartinfo, cirrus-check-sanity, cirrus-config-dump, cirrus-profiles-dump, cirrus-schema-dump, codemirror-validate, collection, cspreport, cxcheckunreviewed, cxfavoritesuggestions, cxpublish, cxpublishsection, cxsave, cxsplit, discussiontoolscompare, discussiontoolspageinfo, discussiontoolspreview, echopushsubscriptions, editcheckreferenceurl, fancycaptchareload, growthinvalidateimagerecommendation, growthinvalidatepersonalizedpraisesuggestion, growthinvalidaterevisetonerecommendation, helppanelquestionposter, jsondata, jsontransform, parser-migration, readinglists, sanitize-mapdata, scribunto-console, securepollauth, stashedit, sxsave, timedtext, ulslocalization, ulssetlang, visualeditor, visualeditoredit, wikimediaeventsblockededit, wikimediaeventshcaptchaeditattempt
- Default: help
- format
Định dạng của dữ liệu được cho ra.
- Một trong các giá trị: json, jsonfm, none, rawfm, xml, xmlfm
- Default: jsonfm
- maxlag
Độ trễ tối đa có thể được sử dụng khi MediaWiki được cài đặt trên một cụm cơ sở dữ liệu được sao chép. Để tránh các thao tác gây ra độ trễ sao chép trang web quá mức, tham số này có thể làm khiến máy khách chờ cho đến khi độ trễ sao chép nhỏ hơn giá trị được chỉ định. Trong trường hợp độ trễ quá mức, mã lỗi maxlag sẽ được trả về kèm theo một thông báo như Đang chờ $host: trễ $lag giây.
Xem Manual: Maxlag parameter để biết thêm thông tin.- Type: integer
- smaxage
Chỉnh đầu đề điều khiển bộ nhớ đệm HTTP
s-maxagethành số giây nhiều như thế này. Lỗi sẽ không bao giờ được lưu vào bộ nhớ đệm.- Type: integer
- The value must be no less than 0.
- Default: 0
- maxage
Chỉnh đầu đề điều khiển bộ nhớ đệm HTTP
max-agethành số giây nhiều như thế này. Lỗi sẽ không bao giờ được lưu vào bộ nhớ đệm.- Type: integer
- The value must be no less than 0.
- Default: 0
- assert
Xác minh rằng thành viên đã đăng nhập (kể cả có thể là thành viên tạm thời) nếu được chỉnh thành user, not đã đăng nhập nếu được chỉnh thành anon, hoặc có quyền thành viên bot nếu bot.
- Một trong các giá trị: anon, bot, user
- assertuser
Xác minh rằng thành viên hiện tại là thành viên có tên.
- Kiểu: người dùng, bằng một giá trị bất kỳ trong tên người dùng và Người dùng tạm thời
- requestid
Bất kỳ giá trị nào được cung cấp ở đây sẽ được bao gồm trong phản hồi. Có thể được sử dụng để phân biệt các yêu cầu.
- servedby
Bao gồm tên máy chủ đã xử lý yêu cầu trong kết quả.
- Type: boolean (details)
- curtimestamp
Bao gồm dấu thời gian hiện tại trong kết quả.
- Type: boolean (details)
- responselanginfo
Bao gồm các ngôn ngữ được sử dụng cho uselang và errorlang trong kết quả.
- Type: boolean (details)
- origin
Khi truy cập API bằng yêu cầu AJAX liên tên miền (CORS), hãy đặt tham số này thành tên miền gốc. Giá trị này phải được bao gồm trong bất kỳ yêu cầu pre-flight nào, và do đó phải là một phần của URL yêu cầu (không phải thân POST). Đối với các yêu cầu đã xác thực, giá trị này phải khớp chính xác với một trong các nguồn gốc trong tiêu đề
Origin, vì vậy nó cần được đặt thành một địa chỉ dạng như https://en.wikipedia.org hoặc https://meta.wikimedia.org. Nếu tham số này không khớp với tiêu đềOrigin, phản hồi 403 sẽ được trả về. Nếu tham số này khớp với tiêu đềOriginvà nguồn gốc đó được cho phép, các tiêu đềAccess-Control-Allow-OriginvàAccess-Control-Allow-Credentialssẽ được thiết lập. Đối với các yêu cầu chưa xác thực, hãy chỉ định giá trị *. Điều này sẽ làm cho tiêu đềAccess-Control-Allow-Originđược thiết lập, nhưngAccess-Control-Allow-Credentialssẽ làfalsevà tất cả dữ liệu riêng của người dùng sẽ bị hạn chế.- crossorigin
Khi truy cập API bằng yêu cầu AJAX liên miền (CORS) và sử dụng nhà cung cấp phiên an toàn trước các cuộc tấn công giả mạo yêu cầu liên trang web (CSRF) (chẳng hạn như OAuth), hãy sử dụng tùy chọn này thay vì
origin=*để yêu cầu được xác thực (tức là không bị đăng xuất). Tùy chọn này phải được đưa vào bất kỳ yêu cầu pre-flight nào, và do đó phải là một phần của URL yêu cầu (chứ không phải phần thân POST).Lưu ý rằng hầu hết các nhà cung cấp phiên, bao gồm cả các phiên dựa trên cookie tiêu chuẩn, không hỗ trợ CORS được xác thực và không thể sử dụng với tham số này.
- Type: boolean (details)
- uselang
Ngôn ngữ để sử dụng cho các bản dịch thông điệp. action=query&meta=siteinfo&siprop=languages trả về một danh sách các mã ngôn ngữ. Bạn có thể định rõ user để sử dụng ngôn ngữ của người dùng hiện tại hoặc content để sử dụng ngôn ngữ nội dung của wiki này.
- Default: user
- variant
Biến thể của ngôn ngữ. Chỉ hoạt động nếu ngôn ngữ gốc hỗ trợ chuyển đổi biến thể.
- errorformat
Định dạng để sử dụng cho văn bản cảnh báo và lỗi đầu ra
- plaintext
- Mã Wiki có thẻ HTML đã bị xóa và các thực thể đã được thay thế.
- wikitext
- Mã wiki chưa được phân tích.
- html
- HTML
- raw
- Khóa và tham số của thông báo.
- none
- Không có văn bản nào được hiển thị, chỉ có mã lỗi.
- bc
- Định dạng được sử dụng trước MediaWiki 1.29. errorlang và errorsuselocal bị bỏ qua.
- Một trong các giá trị: bc, html, none, plaintext, raw, wikitext
- Default: bc
- errorlang
Ngôn ngữ để sử dụng cho cảnh báo và lỗi. action=query&meta=site info&siprop=languages trả về một danh sách mã ngôn ngữ. Hãy chỉ định content để sử dụng ngôn ngữ nội dung của wiki này hoặc uselang để sử dụng giá trị tương tự với tham số uselang.
- Default: uselang
- errorsuselocal
Nếu được cung cấp, văn bản lỗi sẽ sử dụng thông báo được tùy chỉnh cục bộ từ không gian tên MediaWiki.
- Type: boolean (details)
- centralauthtoken
When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user. Use action=centralauthtoken on this wiki to retrieve the token, before making the CORS request. Each token may only be used once, and expires after 60 seconds. This should be included in any pre-flight request, and therefore should be included in the request URI (not the POST body).
On this wiki the expected value is a JSON Web Token, which may be validated by proxy servers in front of MediaWiki. If the token has expired or is otherwise invalid, you may receive a HTTP error from a proxy in a different format than a normal API error.
- Trợ giúp cho các mô-đun chính.
- api.php?action=help [open in sandbox]
- Tất cả trợ giúp trong một trang
- api.php?action=help&recursivesubmodules=1&toc [open in sandbox]
Ghi công
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/.