API:Restricting API usage/zh

此处有几种方式来对用户组用户限制使用（某些）API或完全禁用它. 其中的某些需要修改用户权限.

禁用整个API
您可以通过在中设置 来完全禁用API. API默认是启用的.

该配置设置在MediaWiki 1.31.0版本开始弃用，且将在未来版本中被移除. 这意味着将无法再禁用API.

禁用写入API
您可以禁用所有写入模块通过在LocalSettings.php中设置. 写入API在MediaWiki 1.14版本时被默认启用，但在更旧版本中默认禁用.

该配置设置在MediaWiki 1.31.0版本开始弃用，且将在未来版本中被移除. 这意味着将无法再禁用写入API.

限制访问写入API
You can deny certain groups the right to use the write API by denying them the writeapi right. By default, all groups have the writeapi right. However, both the writeapi right and  are required in order to use the write API.

Disabling modules
You can disable individual modules for all users by adding a line to LocalSettings.php. Exactly what to add depends on the type of module you want to disable:


 * For  modules, use
 * For  modules, use
 * For  modules, use
 * For  modules, use

Examples
To disable anyone who isn't a sysop from using :

To limit the access of an API action, add the following hook for :

Replace,   and   with the appropriate values.