Jump to content

Extension:ScribuntoMediawikiApi

From mediawiki.org
MediaWiki extensions manual
ScribuntoMediawikiApi
Release status: beta
Description Provide action API for Lua modules
Author(s) Urfiner (Nikolai Kochkin)
Latest version 0.1.0
MediaWiki 1.39+
License MIT License
Download

The ScribuntoMediawikiApi extension provides Lua modules with the ability to interact with the MediaWiki Action API. This allows Lua scripts to query and manipulate MediaWiki data programmatically.

Please use GitHub issues for leaving feedback, reporting issues and requesting features. I may miss your message on the Discussions tab.

Installation

[edit]
  • Download and place the file(s) in a directory called ScribuntoMediawikiApi in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'ScribuntoMediawikiApi' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage example

[edit]
  1. Create a new Lua module on your MediaWiki with a content like:
    local p = {}
    
    function p.test()
      return mw.api.actionApiCall{
          action = 'query',
          meta = 'userinfo'
      }
    end
    
    return p
    
  2. Try to call the main method in debug console:
    mw.logObject(p.test())
    
       table#1 {
           ["batchcomplete"] = true,
           ["query"] = table#2 {
               ["userinfo"] = table#3 {
                   ["id"] = 1,
                   ["name"] = "Niko",
               },
           },
       }