0

I'm setting up a MediaWiki based website locally. It's running with Apache on localhost. I'd like to set up some scripts to consume my wiki's event stream.

MediaTech has docs that show examples like this:

import json
from sseclient import SSEClient as EventSource

url = 'https://stream.wikimedia.org/v2/stream/recentchange'
for event in EventSource(url):

    if event.event == 'message':

        try:

            change = json.loads(event.data)
        except ValueError:

            pass
        else:

            print('{user} edited {title}'.format(**change))

But I can't find any information on where the default stream endpoint is for a new install. I haven't set up any subdomains or anything, and all the examples I find use WMF streams.

What endpoint do I need to connect to in order to consume my wiki's event stream?

Thanks!

Cyrus
  • 613
  • 1
  • 6
  • 22
  • 1
    Your wiki does not have an event stream. EventStreams is a separate service, and fairly complex to set up. – Tgr Mar 02 '21 at 14:28

1 Answers1

1

'https://stream.wikimedia.org/v2/stream/recentchange' streams all recent changes of all Wikimedia sites. To get recent changes of a single wiki you have to filter it by the returned content e.g. by the 'server_name' key. As an alternative you may use Pywikibot's eventstream implementation:

import pywikibot
from pywikibot.eventstreams import site_rc_listener
site = pywikibot.Site('wikipedia:de')
for change in site_rc_listener(site, total=10):
    print('{type} on page {title} by {user}.'.format_map(change))
xqt
  • 280
  • 1
  • 11