API:Page info in search results

Showing useful page information
It's useful to show users context when presenting Wikipedia search results.

When you search in the Wikipedia mobile apps, as you type they show a drop-down list of matching pages. They also show the lead image for the article and a description of it.

The lead image comes from Extension:PageImages, which adds a page_image property to pages giving its guess as to an appropriate image for the page. The description comes from Wikidata, which maintains a localized description of the subject of each wiki page.

A slow way to do this would be to query for pages matching what the user types, then make an API  request for the   property of the set of titles, and make another API query to wikidata.org requesting the Wikidata description. This works but involves multiple API queries.

How it works on Wikimedia wikis
Instead, WMF changed most wikis (but, not ) to load the basic Wikibase client extensions for accessing Wikidata. This allows you to query for  along with   on the source wiki, instead of making a second request to www.wikidata.org.

If you have a set of page titles, you can request their information all at once. Set  to the number of titles you're querying, otherwise it will only return one thumbnail, from the first article in the set that has a plausible image. Also you should reduce the API response size by specifying only the properties you want the API modules to supply, in this case only the the thumbnail and Wikidata description. Finally, you may want the query to handle pages that are redirects.

Querying query results in one request
The above example is incomplete, since the set of page titles we're querying for properties – Albert Einstein||Albert Ellis|Albert Estopinal – must have come from another query.

In many situations you can combine getting the properties you want with the initial query for a set of pages, using the MediaWiki API's generator feature. In a single API request, the list of pages from the generator are the set of pages for the other part of the query. The MediaWiki API's query module has a  submodule that queries for a list of pages starting with the prefix you specify ("Albert E"), and list queries can act as a generator. This is what MobileFrontend extension and mobile apps do this, If you look at MobileFrontend's API query in, you can see it combines the  with a query for the pageimages property and

Further niceties
If the set of articles that start with what the user types does not fill the search results list, the Wikimedia mobile apps go on to search for in-page matches that you would get from Special:Search. The Wikipedia iOS mobile app combines  with querying for the pageterms and pageimages properties and getting a list of search terms. From its implementation file ,

How it works in the MediaWiki code
When MediaWiki writes a change to the RecentChanges page, it also calls. The lets you configure different kinds of recent changes feeds, with different kinds of formatting. includes/rcfeed in core has their implementation. If you run a wiki of your own and would like to adapt these visualizations and monitors to it, you can enable similar feeds to a similar client that publishes changes over WebSockets or on an IRC channel. As usual, all aspects of WMF's setup are free and open source.

Going beyond
The Wikipedia mobile applications use face detection to show a better part of the image...

Alternatives
As an alternative, the Hovercards extension (Popups) uses the TextExtracts extension to show the lead information about an article from the local wiki.