From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status experimental

ImplementationTemplate:Extension#type Parser function
DescriptionTemplate:Extension#description ApiMagicWord extension provide a wiki text access to enabled Application Programming Interfaces (API) of MediaWiki Web sites.
Author(s)Template:Extension#username Eric Larchertalk
Latest versionTemplate:Extension#version 0.1b
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download No link


Translate the ApiMagicWord extension if it is available at translatewiki.net

Check usage and version matrix.

What can this extension do?[edit]

With a simple magic word #api, ApiMagicWord extension enabled wiki text access to the (enabled :-) Application Programming Interfaces (API) of MediaWiki Web sites.

By this way, it permits to interact, to get and post data from within each wiki page, with all the contents of those sites .

From within each wiki page with all the contents of the local site included, if its API is enabled.


Here, you can find some examples of the syntax call to http://fr.wikipedia.org/w/api.php (the API of the french wikipedia) from another Mediawiki wiki:

Note 1 : That suppose that, in the local wiki, wfrapi was declared as an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1.

Note 2 : ApiMagicWord suppose too a simple relation between interwikilink to index.php and interwikilink to api.php : if wfrapi is an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1, wfr is (one of) the interwikilink for http://fr.wikipedia.org/w/index.php?title=$1.

  • {{#api:wfrapi|action=query|list=recentchanges}}
  • {{#api:wfrapi|action=query|list=recentchanges|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
  • {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...}}
  • {{#api:wfrapi|action=logout}}

Remark :For meaning of {{!}}, see Help:Magic words#Other.

To format the results[edit]

Templates can be used to filter and/or format items send to the current wiki page :

Remark : of course, for a correct rendering, the templates have to bee create before their usage.

  • {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...|template=Api/login}}
  • {{#api:wfrapi|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=encore un nouvel essai api|summary=test api||notbot/template=Api/edit}}
  • {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges}}
  • {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges2|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
  • {{#api:|action=logout|template=Api/Void}}

Tips : As in the line above, it's possible to use an empty template to avoid all trace in the rendered wiki text.

Others ways, are :

  • when the result is not a list of more than one list of results :
  • (since version 0.1c) when the result is a list of one or more list of results :
    {{#arraymap:{{#api:wfrapi|action=query|list=recentchanges|rclimit=10|delimiter=&&}}|&&|x|{{Api/query/recentchanges|x}}|</tr><tr>}}, if for example we want to build a table.<br\>Remark : Of course, for that, #arraymap should be active. See Extension:Semantic Forms.

Access to the Api of a local Mediawiki wiki[edit]

For access to the Api of the local Mediawiki wiki, no need to specify an interwikilink :

  • {{#api:|action=query|list=recentchanges|template=Api/query/recentchanges}}
  • {{#api:|action=logout|template=Void}}
  • {{#api:|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=je recommence encore encore un nouvel essai api|notbot|summary=test api}}


A lot of work !! Every help is welcome !

Download instructions[edit]

Please cut and paste the codes found in subpages :

 Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.


To install this extension, add the following to LocalSettings.php:

#add configuration parameters here
#setup user rights here

Configuration parameters[edit]

If $wgApiMagicWordUseNoPrefixHash is set to true, then magic word api is without the preceding hash symbol, and more like a built-in function.

User rights[edit]

Have to be implemented.


See :

See also[edit]