Page MenuHomePhabricator

[5.2.8 Epic]: Create dedicated API modules extension APIs
Open, Needs TriagePublic

Description

Background

The MediaWiki REST API currently reflects both APIs native to MediaWiki Core and those that are defined through extensions. Documentation is reflected as a single list, and ownership over specific components can be muddy in terms of API and spec versioning.

By breaking extensions into API modules, we are able to create clear boundaries between API functional areas, which will result in clearer ownership and management of related endpoints.

Conditions of acceptance

  • Complete an API Maintainer's list: https://docs.google.com/spreadsheets/d/1-fcgVYgM0elpTizqN93VEsBINgcs88Gp_6Kw-wrczIs/edit?gid=0#gid=0
  • Create at least one or more extension API modules
    • Identify simple/commonly used APIs based on Wikimedia configurations
    • Assume public modules if not otherwise indicated
    • Consult with owning teams to determine if there is need for private or internal modules --> Halley will facilitate this
  • Create a repeatable technical solution that makes it easy to create a module when registering a new extension API
    • Simplify deployment processes
    • Investigate better encapsulation/abstraction options
    • [Stretch]: Create an integrated linting PoC
    • Potential option: Create a web form/toolforge tool for creating module definition JSON files (possibly a new feature in the linting tool?)
  • Document how to create and maintain a module for future API authors & owners
  • Document guidelines for module versioning
  • [Stretch/Optional] Reroute/redirect non-module friendly paths to versioned modules
    • Mark non-versioned endpoints as deprecated, along with redirect

Event Timeline

The Stretch/Optional goal from the task description implies this, but just to make it explicit: this task is about adding modules to extensions that expose endpoints via the MediaWiki REST API. It is not about removing existing endpoints from those extensions.

I'm assuming that the rerouting mentioned in the task description means rerouting at the REST Gateway level, so that the extension, on WMF wikis, never sees calls to the old paths anymore.

This would be good for the WMF use case, and would facilitate removing the existing non-module endpoint definitions more quickly. However, many extensions may be deployed on third party MediaWiki installations, for which that rerouting will not apply. We therefore, even with rerouting, shouldn't (for most extensions, maybe there are exceptions) just remove the existing endpoints without causing breakage/disruption.

We have (at least) two options for the old endpoints:

  1. redirect the existing endpoints to the new ones. MW REST API supports this via a "redirect" definition. If we use this option, the old endpoints will return 302s to callers. Well-behaved callers will then follow the redirect to the new endpoint. Downsides include possible breakage for non-well-behaved callers, no motivation for callers to switch to the new endpoints, and increased server load (the application layer will need to service two API calls for every call to an old endpoint, one for the redirect and another for the actual call).
  2. make the existing endpoints as deprecated. The MW REST API supports this via RFC9745 compliance, and via marking the endpoint as deprecated in the REST Sandbox. See T405038: [SPIKE] Propose an in-code mechanism for marking endpoints as deprecated. A working example in production is here. This makes it more apparent to callers that are paying attention that the old endpoints are going away. Some callers may not notice (or may notice and not doing anything). But it at least is a friendly step.

Technically, I don't see any reason we couldn't combine those and do both the redirect in the old endpoint definition AND the deprecation header. I've never actually tried combining those, though, so we should make sure it works.

HCoplin-WMF renamed this task from [5.2.8 Epic]: Create dedicated API modules for all extension APIs to [5.2.8 Epic]: Create dedicated API modules extension APIs.Jan 6 2026, 6:53 PM
HCoplin-WMF updated the task description. (Show Details)

@HCoplin-WMF / @BPirkle: This open task is in the "Done" column of [MWI] FY2025-26 Q3. If no further work is needed, please set the task status to "Resolved" so this task does not show up in search results for unresolved tasks. Thanks.

@HCoplin-WMF / @BPirkle: This open task is in the "Done" column of [MWI] FY2025-26 Q3. If no further work is needed, please set the task status to "Resolved" so this task does not show up in search results for unresolved tasks. Thanks.