Jump to content

Extension:GlobalBlocking/API

From mediawiki.org


action=globalblock

(main | globalblock)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: GlobalBlocking
  • License: GPL-2.0-or-later

Globally block or unblock a user.

Specific parameters:
Other general parameters are available.
id

ID of the global block to modify or unblock (obtained through list=globalblocks). Cannot be used together with target.

Type: integer
target

The target IP address or username. Cannot be used together with id.

Type: user, by any of username, IP, Temporary user and IP range
expiry

If specified, will block or reblock the user. Determines how long the block will last for, e.g. "5 months" or "2 weeks". If set to "infinite" or "indefinite" the block will never expire.

Type: expiry (details)
unblock

If specified, will unblock the user.

Type: boolean (details)
reason

The reason for blocking/unblocking.

This parameter is required.
anononly

Specify this if the block should only affect logged-out users globally.

Type: boolean (details)
allow-account-creation

Specify this if the global block should not prevent account creation.

Type: boolean (details)
enable-autoblock

Specify this if the global block should trigger global autoblocks.

Type: boolean (details)
modify

Specify this if the existing block on the target should be modified

Type: boolean (details)
alsolocal

Block the user locally as well. Cannot be used together with id.

Type: boolean (details)
localblockstalk

Revoke talk page access locally. Cannot be used together with id.

Type: boolean (details)
localblocksemail

Revoke email access locally. Cannot be used together with id.

Type: boolean (details)
localanononly

Specify this if the block should only affect logged-out users locally. Cannot be used together with id.

Type: boolean (details)
local-allow-account-creation

Specify this if the local block should not prevent account creation. Cannot be used together with id.

Type: boolean (details)
token

A "csrf" token retrieved from action=query&meta=tokens

This parameter is required.



list=globalblocks (bg)

(main | query | globalblocks)
  • This module requires read rights.
  • Source: GlobalBlocking
  • License: GPL-2.0-or-later

List all globally blocked IP addresses.

Specific parameters:
Other general parameters are available.
bgstart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
bgend

The timestamp to stop enumerating at.

Type: timestamp (allowed formats)
bgdir

In which direction to enumerate:

One of the following values: newer, older
Default: older
bgids

Pipe-separated list of block IDs to list.

Type: list of integers
Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
bgaddresses
Deprecated.

Pipe-separated list of IP addresses to search for.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
bgtargets

Pipe-separated list of usernames, IP addresses, or IP ranges to search for. To search for IP blocks inside a given range, use bgip instead.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
bgip

Get all blocks applying to this IP address or CIDR range, including range blocks. Cannot be used together with bgaddresses or bgtargets. CIDR ranges broader than /16 are not accepted.

bglimit

The maximum amount of blocks to list.

Type: integer or max
The value must be between 1 and 500.
Default: 10
bgprop

Which properties to get.

id
Adds the ID of the global block.
address
Deprecated. Adds the target of the global block. This is deprecated and has been replaced by the 'target' prop.
target
Adds the target of the global block.
by
Adds the username of the blocking user, along with the wiki where they performed the global block.
timestamp
Adds the timestamp of when the global block was given.
expiry
Adds the timestamp of when the global block expires.
reason
Adds the reason given for the global block.
range
Adds the range of IP addresses affected by the global block (not included if the block does not target IP addresses).
Values (separate with | or alternative): by, expiry, id, range, reason, target, timestamp, address
Default: id|target|by|timestamp|expiry|reason
Examples:
List all global blocks
api.php?action=query&list=globalblocks [open in sandbox]
List global blocks applying to IP address 192.0.2.18
api.php?action=query&list=globalblocks&bgip=192.0.2.18 [open in sandbox]