API:Recent changes stream

A core MediaWiki feature is all changes to pages are visible. You can see who made what change to a page. On an active wiki, the overall pattern of activity is as interesting as the specific changes to pages: you can see spikes in overall activity, sudden interest in particular pages in response to news events, when editors are active, etc.

All activity on the server appears in Special:RecentChanges. So you could reload this page and scan it to look for patterns. But there's a better way.

stream.wikimedia.org broadcasts all changes to all public wikis run by Wikimedia Foundation to clients over websockets.

How it works on Wikimedia wikis
For years, the one recent change feed was, which sent formatted IRC messages to an Internet Relay Chat daemon on irc.wikimedia.org that broadcast changes on IRC channels.

In 2014, developers added another feed that formats each recent change as JSON and sends it out over Redis to a simple "RCStream" server at stream.wikimedia.org.

The RCStream daemon uses Socket.IO library to broadcast 'change' events on the endpoint. Socket.IO provides a nicer interface on top of websockets in recent browsers, and falls back to alternative transports in earlier browsers.

This allows anyone to write a visualization of recent changes, such as 'XXX what's a good client to showcase? ' listen.hatnote.com is still using the IRC feed

Explore the recent changes stream
http://codepen.io/Krinkle/pen/laucI/ is a simple sandbox demo that connects to this stream and displays the changes. It loads the socket.io JavaScript library. It subscribes to  so shows all changes to all wikis; try changing it to 'www.wikidata.org' or '*.wikivoyage.org'. Also try changing the callback function ; for example to try and spot #hashtags in the edit comment.

There are many implementations of the Socket.IO protocol. If you like Python, the RCStream page shows the equivalent Python sample code, and the powerful pywikibot library implements an object that yields recent changes.

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.

Alternatives: request changes through the MediaWiki API
The regular MediaWiki API has various modules that report on changes. These use a "pull" model, you make an API request asking for changes rather than consuming a stream of changes "pushed" over WebSockets or IRC.

feedrecentchanges action
This module provides changes to pages as an RSS feed. The  you specify (  or , both XML output) determines the format of the API response, overriding the   parameter

For more information, see Special:ApiHelp/feedcontributions.

recentchanges query module
You can use this to query for changes. It doesn't generate the same ← Older revision 	Revision as of some date output as feedrecentchanges, but it provides the revision IDs of page changes and can provide other information. To make a similar kind of request as the  example above, use a generator of. (Broken?)

For more information, see Special:ApiHelp/query+recentchanges.

Real-Time Recent Changes is a JavaScript tool that uses the  query module to monitor recent changes of a wiki in real-time.