API:Blocks
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
For the API for handing out blocks, see API:Block.
| Blocks | ||
|---|---|---|
This module cannot be used as a Generator. |
||
| Prefix | bk | |
| Required rights | none | |
| Post only? | No | |
| Generated help | Current | |
| Version added |
|
|
List all blocks, à la Special:Ipblocklist. This module cannot be used as a generator.
Contents
Parameters
bkstart: The timestamp to start listing frombkend: The timestamp to end listing atbkdir: Direction to list in. (Default:older)older: List newest blocks first. Note: bkstart has to be later than bkend.newer: List oldest blocks first. Note: bkstart has to be before bkend.
bkids: Only list blocks with these IDsbkusers: Only list blocks of these user namesbkip: List all blocks, including range blocks, that apply to this IP address. You can also specify a CIDR range here, in which case only blocks applying to the entire range will be listed. Cannot be used together withbkusers. CIDR ranges broader than /16 are not allowed, as range blocks cannot cross /16 boundariesbklimit: Maximum number of blocks to list (Default: 10)bkprop: A pipe-separated list of properties to get. They appear as keys of returned dictionary. (Default: id|user)id: The ID of the blockuser: The IP address or username that was blocked (does not appear in output for autoblocks)userid: The id of user who was blocked (does not appear in output for autoblocks) 1.18+by: The user who applied the blockbyid: The id of user who applied the blocktimestamp: When the block was appliedexpiry: When the block will expirereason: The reason for the blockrange: If an IP range was blocked, the first and last IP the block applies to- Will appear as
rangestartandrangeendin the answer, both 0.0.0.0 for registered users. Same asuserfor standalone IPs.
- Will appear as
flags: Flags that apply to the block- The appropriate flags will appear as keys of returned dictionary with an empty value. No key if the flag is not valid for the block.
automatic: Automatically blocked because of an autoblock (see also action=block)anononly: Only anonymous edits are blockednocreate: Account creation is disabledautoblock: Automatic blocking is enabled for this blocknoemail: Sending e-mail through the wiki is disabled for the blocked userallowusertalk: The user is allowed to edit his/her own talk page- : This block is hidden from Special:Ipblocklist. Only users with oversight permissions can see these blocks.
Example
Listing the 3 most recent blocks
api.php? action=query& list=blocks& bkprop=id|user|by|timestamp|expiry|reason|range|flags& bklimit=3 [try in ApiSandbox]
| Result |
|---|
<?xml version="1.0" encoding="utf-8"?>
<api>
<query>
<blocks>
<block id="4"
user="123.123.0.0/16"
userid="0"
by="Catrope"
byid="1"
timestamp="2007-11-23T11:44:41Z"
expiry="infinity"
reason="Bad proxies; these folks will just have to register"
rangestart="123.123.0.0"
rangeend="123.123.255.255"
anononly=""
/>
<block
id="2"
user="25.50.100.200"
userid="0"
by="Catrope"
byid="1"
timestamp="2007-11-23T11:37:28Z"
expiry="infinity"
reason="Intimidating behaviour/harassment"
rangestart="25.50.100.200"
rangeend="25.50.100.200"
anononly=""
nocreate=""
/>
<block
id="1"
user="Vandal01"
userid="3"
by="Catrope"
byid="1"
timestamp="2007-11-23T11:36:40Z"
expiry="2007-12-23T11:36:40Z"
reason="Spamming links to external sites"
rangestart="0.0.0.0"
rangeend="0.0.0.0"
nocreate=""
autoblock=""
noemail=""
/>
</blocks>
</query>
</api>
|
Error Codes
None.