Jump to content

Extension:MobileFrontend/MobileViewAPI

From mediawiki.org

APIs are provided by the MobileFrontend extension and have been deprecated in favour of the Mobile Content Service which itself is deprecated in favor of Page Content Service Use these APIs at your own risk. They will soon be marked as deprecated and may disappear (although we will give you sufficient notice when they do)! If you are using them, please reach out to us on the talk page with any concerns you might have.

Deprecation roadmap

[edit]

The noimages property was removed in 2019. See phab:T99009.

The API

[edit]

Delivers content optimized for mobile devices for use by mobile apps and dynamic section views. Almost like a restricted-functionality action=parse, but more flexible and returns separate sections that are always obtained from full-page parse.

Parameters:


page Title of page to process.
sections Pipe-separated list of section numbers for which to return text or all for all sections.
redirect Whether redirects should be followed, yes (default) or no. This parameter is intentionally made similar to the one to index.php .
prop Which information to get:
  • text: HTML of selected section(s)
  • sections: Information about all sections on page
  • normalizedtitle: Normalized page title, will be returned only if it differs from the specified one.
sectionprop What information about sections to get: pipe-separated list of value types defined by parser. It's the same as in action=parse: toclevel, level, line, number, index, fromtitle, anchor. "byteoffset" has been excluded as it makes no sense for this action.
noheadings Return HTML without headings.

Returned section information also includes the id for every section - its zero-based number; and for sections that contains references added by Cite , there's also references data member.

Examples:

Result
{
    "mobileview": {
        "sections": [
            {
                "id": 0,
                "text": "<p>Hi<sup id=\"cite_ref-1\" class=\"reference\"><a href=\"#cite_note-1\">[1]</a></sup></p>"
            },
            {
                "toclevel": 1,
                "line": "This is first section",
                "id": 1
            },
            {
                "toclevel": 2,
                "line": "This is nested section",
                "id": 2
            },
            {
                "toclevel": 1,
                "line": "References",
                "id": 3,
                "references": ""
            }
        ]
    }
}

Same request for XML:

Result
<?xml version="1.0"?>
<api>
  <mobileview>
    <sections>
      <section id="0" xml:space="preserve">&lt;p&gt;Hi&lt;sup id=&quot;cite_ref-1&quot; class=&quot;reference&quot;&gt;&lt;a href=&quot;#cite_note-1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;</section>
      <section toclevel="1" line="This is first section" id="1" />
      <section toclevel="2" line="This is nested section" id="2" />
      <section toclevel="1" line="References" id="3" references="" />
    </sections>
  </mobileview>
</api>

api.php?action=mobileview&page=Extension:MobileFrontend/Example&sections=0&prop=text|sections&format=xml