User:SSethi (WMF)/Sandbox/Investigate and improve MediaWiki Action API docs

This document contains research on the state of the docs of MediaWiki Action API, suggests recommendations for next steps and lists work already in progress related to improving the docs:

Target for Q1, July-September 2018
Massviews analysis of pages under Category:MediaWiki_Action_API gives some idea of which API pages are viewed more frequently. For Q1:July-September2018, the target is to focus on the first twenty commonly viewed pages. These pages include documentation of 7-8 API modules and rest are overview pages (such as Errors and warnings, Etiquettes, etc.). So, we are planning to improve the documentation of 7-8 API modules and API:Main_page and all the pages it covers.

Research on the state of the docs of MediaWiki Action API
Both the abstract and concrete details in the sections below reflect the issues with the current state of the MediaWiki Action API:

The big picture

 * The MediaWiki Action API supports not just querying but also a lot of other actions like authenticating, searching, changing content on Wiki. Though, the API's main page links to documentation of other modules, it is not highlighted well what the capabilities of MediaWiki Action API are.
 * There are several other Wikimedia APIs linked from the API:Main_page (e.g., Rest API, Wikidata API, Commons API, etc.). It is not clear what would be the advantage of choosing one over another. On other note, we do not need to publicize other APIs here.
 * Some parts of the Action API doc explains a concept using another Wikimedia API (e.g. Rest API or MediaWiki core internal API) which is confusing.
 * It is not apparent which is the central hub for Action APIs. Somewhat similar pages show up in the Google results:
 * API:Main_page - It seems to be the hub of MediaWiki action APIs, but the page name does not reflect the same.
 * API:Tutorial - This is about the REST API.
 * API:Web_APIs_hub - It seems to be the hub of all Wikimedia APIs, but the page name does not reflect the same, nor it lists all the Wikimedia APIs.
 * API:Query - It is about one query module which is supported by the Action API.
 * Action APIs modules docs (API:Query, API:Login, API:Block, etc.) lacks sample code. Though, there are code samples in a few; they are inconsistent and written in different languages.
 * The content for individual actions supported by API sometimes mixes the audience: wiki administrators, library developers, API users, extension developers, etc.

Specific details about the API:Main_page

 * Page name does not reflect that API:Main_page is the hub for the MediaWiki Action APIs
 * The menu bar on the right displays an input box and a search button below it. It is not clear if they are related. Perhaps, we only need one. The actions in the menu are not categorized well and seem to be mixed up with some of the other page links such as FAQ’s, introduction, etc.
 * Introduction section
 * Two prominent notices in gray box need language work - the first one about internal API can be a bit clearer and the other one more newcomer-friendly.
 * There could be a separate section about the web clients examples.
 * Give more context on the outward facing interfaces; why they are mentioned here.
 * The point about restricting the use of API does not go well here - it is perhaps for API developers or administrators and could be left in a note separately.
 * A simple example section
 * Needs style improvement
 * All action parameters, format, endpoints could be in a table format
 * Add an example of fetching the content of a Wikipedia page via a programming language like Python
 * Explanation of the RSD format is not clear
 * FAQ document is incomplete and mostly about the errors related to Action API
 * Getting started section - there is some overlap in the information contained in the three docs linked from here: FAQ, errors and warnings and data formats
 * Identifying your client section - the sample code in there is confusing. For example, it uses MediaWiki internal API (mw.API) to demonstrate how to fetch data and it could be unclear to users who are not familiar with it
 * Query module is highlighted in the overall document but not some of the other modules supported by the API
 * Logging section can be removed
 * Useful links could be split into sections: a place to report bugs, contact, API documentation, etc.
 * Other Action API subpages that needs improvement
 * API:Properties and subpages
 * API:Query and subpages
 * API reference
 * API:Data formats
 * API:FAQ
 * API:Errors and Warnings
 * API:Tutorial
 * API:Client code
 * API:Etiquette

Recommendations for next steps

 * Add code samples for individual actions supported by the API (e.g. API:Edit, API: Login, etc.)
 * Explore some other API docs (Twitter, FB, etc)
 * https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline
 * https://developers.facebook.com/docs/instagram-api/
 * Design a consistent writing style format for each action page. It could contain:
 * Short description of what the API does
 * API endpoints / Web hooks
 * Link to try the API in a Sandbox
 * Parameters
 * Replace on-wiki API documentation with Special:ApiHelp transclusion Phab:T89318
 * Possible errors
 * Make a list of all the actions supported by the Action API and re-categorize them in the right menu on API:Main_page


 * Improve the writing style and discoverability of API:Main_page / main hub for Action API
 * Give a better explanation of when to use Action APIs; pros or cons of using them over some of the other APIs in the Wikimedia universe
 * Overall review and make improvements to all the docs that are in the MediaWiki Action API category

Phase 1
Sandbox to Mainspace migration steps:


 * Create these two pages first:
 * API:Geosearch
 * API:Languagesearch
 * Link API:Geosearch and API:Languagesearch with Template:API
 * Help from Sarah to review Template:API
 * Replace Template:API with User:SSethi (WMF)/Sandbox/Template:API
 * Move MediaWiki Action API Module Template out of SSethi (WMF)/Sandbox
 * Embed Template:API on the moved MediaWiki Action API Module Template
 * Replace API:Main page with API_landing_sandbox. Few points to note:
 * Rename API:Main page
 * Add links for missing pages (API overview pages such as FAQ, Data formats, Errors and warnings, etc)
 * Add a note saying -- if folks couldn’t find what they were looking for, there are other APIs in the Wikimedia universe to explore, and for that go to   Web API Hub
 * API:Tutorial (a demo link) / Srishti plans to revise this tutorial
 * Move User:SSethi_(WMF)/Sandbox/API:All_search_modules out of Sandbox
 * Move content of module listed below from Sandbox to real pages:
 * API:Opensearch
 * API:Prefixsearch (TODO w/ Guillaume)
 * API:Search
 * API:Parse / (name change from Parsing wikitext to API:Parse)
 * API:Login (TODO w/ Guillaume)
 * API:Tokens (TODO w/ Guillaume)
 * Things to kill or redirect:
 * Redirect API:Search and discovery to API:All_search_modules
 * Kill API:Showing_nearby_wiki_information or redirect to either API:All_search_modules or API:Geosearch
 * Kill API:Page_info_in_search_results  / redirect to either API:All_search_modules or API:Geosearch
 * Kill API:Other_services
 * Move CirrusSearch info from API:Search and discovery to Extension:CirrusSearch page
 * Link API:Etiquette from the API:Main_page (TODO w/ Guillaume)
 * Check with Wikidata folks if it is okay to get rid of the sidebar on the Wikibase/API page (not getting rid; as per the follow-up)
 * Remove the link to API:Search and discovery page from the Sidebar


 * Some more pages (top 20 most viewed) that could be reviewed/ improved:
 * API:Tutorial. Add ideas for demo apps:
 * Show nearby pages with images that have more red links (API:GeoSearch + API:Parsing_WikiText)
 * API:Query
 * API:Client code
 * API:Data formats
 * API:Properties
 * API:Error and warnings
 * API:Info
 * API:Edit
 * API:FAQ
 * API:Revisions
 * API:Categorymembers
 * API:Cross-site requests

Results
In the task description: https://phabricator.wikimedia.org/T198916