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.

Special:RecentChanges on any wiki lists these changes. 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. Manual:RCFeed describes the properties of the change, which include the title of the page, the editor's comment about the change, the old and new revision IDs, the old and new length of the page, etc.

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 or analysis of recent changes to wiki content, such as the level of activity, major additions or deletions, new images or other media, and so on. Developers have already written excellent tools that do this by parsing the old IRC messages, such as http://listen.hatnote.com, the audiovisualization, shown above. The reliable and fast RCStream server makes it easier.

Explore the recent changes stream
"RCStream" on Wikitech describes the API. View http://codepen.io/Krinkle/pen/laucI/ for a simple demo. It uses the Socket.IO library to connect with the stream and displays each change. It subscribes to  so changes from all wikis are shown. Try changing it to 'www.wikidata.org' or '*.wikivoyage.org'. Also try changing the callback function in  ; to for example look a #hashtag in the edit comment. Or filter by one of the other RCFeed properties.

There are many implementations of the Socket.IO protocol. The RCStream page shows an equivalent code sample in Python. 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.