Mobile Content Service

The Mobile Content Service ("MCS") provides a variety of APIs for shipping mobile friendly content to app clients. It was built to replace the apps' usage of the MediaWiki action API mobileview module (removed in REL1_39) and to incorporate page content transforms that were previously being performed in JavaScript on the client post-page load.

Its successor is the Page Content Service.

MCS is slated for service decommissioning in July 2023.

Phabricator project: #mobile_content_service, shortcut: #mcs

Endpoints

edit

Production routes start with {protocol}://{domain}/api/rest_v1/.

Local dev box routes start with http://localhost:6927/{domain}/v1/ (for MCS directly) or http://localhost:7231/{domain}/v1/ (for RB).

.../?doc (Swagger UI)

edit

Stability: stable

You can access the Swagger UI at the /?doc route. Examples: Prod | Beta cluster | Labs | Local RB | Local MCS

.../page/mobile-sections/{title}

edit

Stability: unstable

.../page/mobile-sections-lead/{title}

edit

Stability: unstable

.../page/mobile-sections-remaining/{title}

edit

Stability: unstable

These three routes are used by the beta Android app when the useRestbase developer option is enabled (which is now enabled by default).

The output has a similar JSON structure to the PHP action=mobileview module, except:

  • mobile-sections:
    • has a top-level object with two properties: lead and remaining. This is an endpoint which gets the contents of the next two endpoints in one single request, which is useful for refreshing saved pages.
    • Examples: Prod | Beta cluster | Labs | Local RB | Local MCS
  • mobile-sections-lead:
    • Is used for the initial page load.
      • Instead of the thumb object to get the URL for the lead image it has a urls property under image. This object contains a hashtable of common lead image widths (640, 800, 1024) pointing to respective URL of the lead image in the size in pixel.
      • If the article has a pronunciation the the pronunciation object has a url string with the fully qualified URL to the pronunciation file.
      • If the article uses one of the Spoken Wikipedia templates the the spoken object has a urls array with the fully qualified URLs to the parts of a recorded audio version of this article.
      • If there are Geo coordinates associated with the article then the geo object will have the latitude and longitude of the place.
      • The sections array includes the information needed to display the lead section and also to build the table of contents. Therefore, it has the section text of the lead section only and the rest of the sections don't include it.
    • Examples: Prod | Beta cluster | Labs | Local RB | Local MCS
  • mobile-sections-remaining:
    • Note that this route's sections array does not include the lead section text since this was already retrieved as part of the lead response.
    • Examples: Prod | Beta cluster | Labs | Local RB | Local MCS
  • For debugging: The HTML content comes from Parsoid. To make it more convenient to debug transformations at a high level here are the respective examples from Parsoid:
  • For comparison, here are the equivalent action=mobileview requests the Android app uses:

.../page/definition/{title}

edit

Stability: stable

This route provides a set of definitions pulled from the Wiktionary page from the term. (It does not provide the Wiktionary content in full.)

Currently used in the Wikipedia Beta Android app, where users can view a popup with definitions by highlighting a word in the app and choosing the "define" option from the context menu.

Available for English Wiktionary only; rollout to other languages pending based on user engagement.

Note: this endpoint is not for Wikipedia sites, only for Wiktionary.

Examples: Prod | Beta cluster (MCS and Parsoid not setup for some reason) | Labs | Local RB | Local MCS (Wiktionary entry of bar)