API:Watch
From MediaWiki.org
![]() |
This page is part of the MediaWiki API documentation. |
Language: | English • Deutsch • 日本語 • polski |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
MediaWiki version: | 1.18 |
Token[edit | edit source]
To (un)watch a page, a token is required. This token is the same for all pages (and is not different for watch vs unwatch), but changes at every login. Watch/unwatch tokens can be obtained via action=tokens with type=watch (MW 1.20+), or by using the following method:
Obtaining a watch token
Result |
---|
<?xml version="1.0"?> <api> <query> <pages> <page pageid="1" ns="0" title="Main Page" touched="2012-02-07T17:27:37Z" lastrevid="2" counter="21" length="440" starttimestamp="2012-02-09T18:03:17Z" watchtoken="f2583b3edcdc2142f7256be161764d91+\" /> </pages> </query> </api> |
Watching and unwatching pages[edit | edit source]
Pages can be watched (added to your watchlist) and unwatched (removed from your watchlist) with action=watch. Of course, you can only add and remove pages to/from your own watchlist.
Parameters[edit | edit source]
title
: Single page to (un)watch (Deprecated (MW 1.24)+ in favour oftitles
)titles
: List of one or more pages to (un)watchentirewatchlist
: If set, unwatches all pages in bulk. This can be useful for some situations with prolific accounts that have accidentally overfilled their watchlists and have trouble managing it. Can only be used along withunwatch
parameter. Since 1.24unwatch
: If set, unwatch the page. If not set, watch the page.token
: Your (un)watch token.
Requests Must be "POST"ed, but for example's sake, "GET"s are used here:
Examples[edit | edit source]
Watching Main Page
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <watch title="Main Page" watched="" /> </api> |
Unwatching Dog
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <watch title="Dog" unwatched="" /> </api> |
Possible errors[edit | edit source]
Only the usual stuff.