API:Assert
From MediaWiki.org
| This page is part of the MediaWiki action API documentation. |
MediaWiki action API
- Introduction and quick start
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Searching (by title, content, coordinates...)
- 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.23 |
To make sure your bot doesn't edit while logged out, the action API provides an assert parameter which you can add to any request.
assert=user: Checks that your account is logged inassert=bot: Checks that your account has the "bot" user right
If the assertion fails, error codes of assertuserfailed or assertbotfailed will be returned.
Checking if you are logged in[edit]
If you simply want to check whether you are logged into the action API, you can issue a request with parameters action=query&assert=user. This will return a simple blank response ({} in the JSON format) if you are indeed logged in, or the assertuserfailed error if not.
Normally, you will not need to do this. Instead, add the assert=user parameter to all requests that should be made by a logged-in user.

