API:Extensions

Creating API modules in extensions
Extensions can also add API modules. Create a new class that inherits ApiBase (for a top-level module), ApiQueryBase (for a non-generator submodule of action=query) or ApiQueryGeneratorBase (for a submodule of action=query with generator functionality) and implement the methods execute, getAllowedParams, getParamDescription, getDescription and getVersion. Generator modules also need to implement executeGenerator.

When you've created your new class, you need to register it with the API by adding it to $wgAPIModules (top-level modules), $wgAPIPropModules (prop= modules), $wgAPIMetaModules (meta= modules) or $wgAPIListModules (list= modules), like this:

It's possible to override core modules.

Extending core modules
Since MediaWiki 1.14, it's possible to extend core modules' functionality using the following hooks:
 * APIGetAllowedParams to add or modify the module's parameter list
 * APIGetParamDescription to add or modify the module's parameter descriptions
 * APIAfterExecute to do something after the module has been executed (but before the result has been output)
 * Use APIQueryAfterExecute for,   and   modules
 * If the module is run in generator mode, APIQueryGeneratorAfterExecute will be called instead

List of extensions with API functionality
The following MediaWiki extensions add to or extend API functionality:


 * AbuseFilter
 * AssertEdit
 * Categorize
 * CodeReview
 * FlaggedRevs
 * GlobalBlocking
 * GlobalUsage
 * LiquidThreads
 * MWReleases
 * Semantic Forms
 * SiteMatrix
 * TemplateInfo
 * UsabilityInitiative