Real-time Wikipedia edit events via the Wikimedia EventStreams Server-Sent Events API.
No setup required — works out of the box.
uv run python examples/wikipedia_example.pyExpected output within a few seconds:
Connecting to Wikipedia edit stream…
Press Ctrl+C to stop.
08:55:00 | Green leafhopper | +522 bytes | Uffda608
08:55:01 | Daniela Avanzini | +102 bytes | ~2026-12581-95
08:55:01 | Dilane Bakwa | -60 bytes | ~2026-12355-66
08:55:04 | Daoist texts | +1473 bytes | ~2026-12409-27
08:55:08 | Daniel K. Ludwig | +0 bytes | Barnej
No API key is needed. The only optional variable is the User-Agent header, which Wikimedia's robot policy requires to be descriptive. A default is set automatically — override it if you want to identify your app:
# .env (optional)
WIKIPEDIA_USER_AGENT=my-hackathon-app/1.0 (contact@example.com)Note: Omitting a
User-Agententirely results in a403with the message "Please set a user-agent and respect our robot policy." The client sets one automatically, so you only need this variable if you want a custom value.
from streams.wikipedia import WikipediaStream
stream = WikipediaStream()
await stream.start()
async for event in stream:
edit = event.payload
print(f"{edit.wiki}: {edit.title} ({edit.delta:+d} bytes) by {edit.user}")Filter to English Wikipedia main articles only:
async for event in stream:
edit = event.payload
if edit.wiki == "enwiki" and edit.namespace == 0:
print(edit.title)| Field | Type | Description |
|---|---|---|
id |
int |
Revision ID |
wiki |
str |
Wiki identifier (e.g. enwiki) |
title |
str |
Page title |
namespace |
int |
MediaWiki namespace (0 = articles) |
user |
str |
Editor username or IP |
is_bot |
bool |
Whether the editor is a bot |
is_new_page |
bool |
Whether this created a new page |
is_minor |
bool |
Whether marked as minor edit |
comment |
str |
Edit summary |
old_length |
int |
Page size before edit (bytes) |
new_length |
int |
Page size after edit (bytes) |
delta |
int |
Bytes added (negative = removed) |
revision_url |
str |
Direct link to diff |
timestamp |
datetime |
Edit time (UTC) |
server_name |
str |
Hostname (e.g. en.wikipedia.org) |
page_url |
str |
Canonical page URL |
- Events arrive within 1–2 seconds of the actual edit
- Volume is roughly 3–10 edits/second across all Wikimedia wikis
- Common
wikivalues:enwiki,dewiki,frwiki,commonswiki,wikidatawiki - Common
namespacevalues:0= articles,1= Talk,4= Wikipedia,10= Template