API:Extensions

From MediaWiki.org
Jump to: navigation, search
Tools clipart.png This page is part of the MediaWiki API documentation.
Language: English  • Deutsch
MediaWiki API

Quick overview:

[edit] 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, selected using action=), $wgAPIPropModules (prop= modules), $wgAPIMetaModules (meta= modules) or $wgAPIListModules (list= modules), like this:

 // Register the ApiMyExt class as handler for action=myext
$wgAPIModules['myext'] = 'ApiMyExt';

It's possible to override core modules.

[edit] Extending core modules

Since MediaWiki 1.14, it's possible to extend core modules' functionality using the following hooks:

[edit] List of extensions with API functionality

See API extensions for examples of extensions that add or extend to the API.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox