Special:PageData serves as a data retrieval endpoint, as described by T161527: RFC: Canonical data URLs for machine readable page content. Its purpose is not to provide an API, but to offer a unified naming scheme for accessing machine readable page content via any API.
The initial implementation of Special:PageData should do the following:
- From the request, extract a page title and a slot name:
- Subpage syntax should be supported; e.g. Special:PageData/main/User:Foo means slot "main", title "User:Foo". If subpage syntax is used, both, slot and title, must be given.
- Simple request parameters can be used; e.g. Special:PageData?title=User:Foo&slot=main means slot "main", title "User:Foo". The slot parameter is optional and defaults to "main".
- If no title is given in the request, a message explaining the purpose of the special page should be shown. A form for entering title and slot would be nice, but it not initially required.
- Check that the given slot is supported by the given page.
- Until T107595: [RFC] Multi-Content Revisions is implemented, all pages support the "main" slot, and only the "main" slot. So for now, this can just check that the slot parameter is "main".
- If the client send an Accept header for content negotiation, check that the page's (default) serialization format (mime type) is compatible with that header. If not, send status 406.
- It should be possible to extend/override content negotiation using a hook.
- Respond with a HTTP redirect (status 303) to the page's raw data
- The default target for the redirect is the action=raw API, i.e. $title->getFullUrl( [ 'action' => 'raw' ] ). The slot name can be added in the future. A setting should be provided that allows this to be changed to use the MediaWiki REST API.
- Call a hook that allows modifying the redirect target. For instance, Wikibase may redirect to its own Special:EntityData instead of action=raw.
- The redirect should be marked as non-cacheable for now. Caching the redirect would require web caches to vary on the Accept header.
- Special:PageData should not be listed on Special:SpecialPages.