API:Blocks
| This page is part of the MediaWiki Action API documentation. |
| Please help improve this technical documentation! Take our MediaWiki Action API Technical Documentation User Feedback Survey before 6 January – Note: The survey uses Google Forms. See Privacy Statement – Thanks! |
| 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[edit]
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|by|timestamp|expiry|reason|flags)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.
bkshow: Show only items that meet these criteria. Conflicting options, likeaccount|ip, are allowed, but won't return any results. 1.19+account: Only show account blocks.!account: Show everything except account blocks.temp: Only show temporary blocks.!temp: Show everything except temporary blocks.ip: Only show single IP blocks.!ip: Show everything except single IP blocks.range: Only show range blocks.!range: Show everything except range blocks.
Example[edit]
Listing the 3 most recent blocks
| 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[edit]
None.
See also[edit]
| The following documentation is the output of Special:ApiHelp/query+blocks, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org). |
list=blocks (bk)
- This module requires read rights.
- Source: MediaWiki
- License: GPL-2.0-or-later
List all blocked users and IP addresses.
- bkstart
The timestamp to start enumerating from.
- Type: timestamp (allowed formats)
- bkend
The timestamp to stop enumerating at.
- Type: timestamp (allowed formats)
- bkdir
In which direction to enumerate:
- newer
- List oldest first. Note: bkstart has to be before bkend.
- older
- List newest first (default). Note: bkstart has to be later than bkend.
- One of the following values: newer, older
- Default: older
- bkids
List of block IDs to list (optional).
- Type: list of integers
- Separate values with | or alternative. Maximum number of values is 50 (500 for bots).
- bkusers
List of users to search for (optional).
- Type: list of user names
- Separate values with | or alternative. Maximum number of values is 50 (500 for bots).
- bkip
Get all blocks applying to this IP address or CIDR range, including range blocks.
Cannot be used together with bkusers. CIDR ranges broader than IPv4/16 or IPv6/19 are not accepted.
- bklimit
The maximum number of blocks to list.
- No more than 500 (5,000 for bots) allowed.
- Type: integer or max
- Default: 10
- bkprop
Which properties to get:
- id
- Adds the ID of the block.
- user
- Adds the username of the blocked user.
- userid
- Adds the user ID of the blocked user.
- by
- Adds the username of the blocking user.
- byid
- Adds the user ID of the blocking user.
- timestamp
- Adds the timestamp of when the block was given.
- expiry
- Adds the timestamp of when the block expires.
- reason
- Adds the reason given for the block.
- range
- Adds the range of IP addresses affected by the block.
- flags
- Tags the ban with (autoblock, anononly, etc.).
- restrictions
- Adds the partial block restrictions if the block is not sitewide.
- Values (separate with | or alternative): id, user, userid, by, byid, timestamp, expiry, reason, range, flags, restrictions
- Default: id|user|by|timestamp|expiry|reason|flags
- bkshow
Show only items that meet these criteria.
For example, to see only indefinite blocks on IP addresses, set bkshow=ip|!temp.
- Values (separate with | or alternative): account, !account, temp, !temp, ip, !ip, range, !range
- bkcontinue
When more results are available, use this to continue.
- List blocks.
- api.php?action=query&list=blocks [open in sandbox]
- List blocks of users Alice and Bob.
- api.php?action=query&list=blocks&bkusers=Alice|Bob [open in sandbox]