Data structures

From Apibot
Jump to: navigation, search

Everything you can use Apibot for is about wiki data - reading it, processing it , writing it back to the wiki. This data will typically be wiki pages, but sometimes can be other types of wiki data - users, page revisions, recentchanges, files, usercontribs etc.

Wiki data can be represented in two forms: either as PHP arrays (rarely - strings or numerics), or as objects.

Every type of data can be represented as an array or scalar. This is the data representation originally returned by MediaWiki.

Most types can be represented also as objects. Where available, the objects representation is usually preferable. They represent the data array key/value pairs as object properties and their values. In addition, they often have methods that operate on the data.

Some of the wiki data is collected in special objects. The prime example is the Info object, which handles all types of wiki info.

Some of the Apibot data is also available as objects.

Wiki data

Wiki info

The info about the wiki and the bot user account in it is available through the Info object. See there for a description.

Wiki objects


There are several types of frequently basic wiki data that participate in most wiki objects:

  • Title (of a page)
  • Pageid
  • Revid (revision ID)
  • User (name)
  • By_User (denotes in some structures who created them, or did something else)
  • Userid
  • By_Userid
  • Timestamp
  • Expiry (timestamp of the end of the validity of something)
  • Nsid (namespace ID)
  • Rcid (recentchange ID)
  • Logid (log record ID)
  • Blockid (user block ID)
  • Size (of something, typically in bytes)
  • Extlink (external link)


Page properties

Some Apibot functions and objects allow specifying only selected page properties. Some, however, can accept the full range of MediaWiki page properties. In this case, these are specified with the following structure:

The properties data is formed as an array, with keys named for the page properties. The value for each property will also be an array, with keys named for the property parameters. The value for each parameter will be either a scalar (where a single value should be given), or an array (where more than one value can be given). For example:

$properties = array (
  'info' => array (
    'prop' => array (
       "protection", "url"
  'revisions' => array (
    'prop' => array (
      "ids", "flags", "timestamp", "comment", "content"
    'limit' => 5,
    'user' => "MyUsername",

Please note that the parameters names should not contain the MediaWiki paramname prefaces ('in' for the info parameters, 'rv' for the revisions parameters etc).

See also