Open main menu

MediaWiki β

API:Restricting API usage


Other languages:
dansk • ‎Deutsch • ‎English • ‎español • ‎Հայերեն • ‎日本語 • ‎polski • ‎русский • ‎sicilianu • ‎中文
This page is part of the MediaWiki action API documentation.

MediaWiki action API

v · d · e

There are several ways to restrict usage of (certain parts of) the API to certain groups of users, or to disable it altogether. Some of these require changing group permissions.

Disabling the entire APIEdit

You can disable the API as a whole by setting $wgEnableAPIManual:$wgEnableAPI = false; in LocalSettings.phpManual:LocalSettings.php. The API is enabled by default.

  Note: This configuration setting was deprecated starting with MediaWiki 1.31.0 and will be removed in future versions meaning that disabling the API will no longer be possible.

Disabling the write APIEdit

You can disable all write modules by setting $wgEnableWriteAPIManual:$wgEnableWriteAPI = false; in LocalSettings.php. The write API is enabled by default as of MediaWiki 1.14, and disabled by default in older versions.

  Note: This configuration setting was deprecated starting with MediaWiki 1.31.0 and will be removed in future versions meaning that disabling the write API will no longer be possible.

Restricting access to the write APIEdit

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 $wgEnableWriteAPI = true; are required in order to use the write API.

Disabling modulesEdit

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:

ExampleEdit

To disable anyone who isn't a sysop from using action=edit:

if ( !in_array( 'sysop', $wgUser->getGroups() ) ) {
	$wgAPIModules['edit'] = 'ApiDisabled';
}