Extension:GlobalBlocking/API

From MediaWiki.org
Jump to navigation Jump to search

Global blocking[edit]

Allows you to create a new block, remove a block, or modify one.

Parameters[edit]

  • target: Target IP address/range
  • expiry: How long block should last for
  • unblock: If set, will unblock the address/range
  • reason: (un)block reason
  • anononly: If set, the block will only affect anonymous users
  • modify: If set, the block will modify an existing block
  • token: Edit token

Example[edit]

Note: Request must be POSTed.

Blocking 127.0.0.1 indefinitely with the reason of "Cross wiki abuse"

List global blocks[edit]

View a list of currently blocked IP addresses/ranges.

Parameters[edit]

  • bgstart: The timestamp to start enumerating from
  • bgend: The timestamp to stop enumerating at
  • bgdir: The direction in which to enumerate (older, newer)
  • bgids: Pipe-separated list of block IDs to list (optional)
  • bgaddresses: Pipe-separated list of addresses to search for (optional)
  • bgip: Get all blocks applying to this IP or CIDR range, including range blocks. (Cannot be used together with bkusers. IPv4 CIDR ranges broader than /16 are not accepted; however, IPv6 ranges can be of any size less than /4)
  • bglimit: The maximum number of blocks to list
  • bgprop: Which properties to get (id|address|by|timestamp|expiry|reason|range)

Errors codes[edit]

  • cidrtoobroad: CIDR ranges broader than /16 are not accepted.
  • invalidtitle: Bad title 'title'.
  • readapidenied: You need read permission to use this module.

Example[edit]

List all global blocks




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.

Parameters:
target

The target IP address.

This parameter is required.
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.

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.

Type: boolean (details)
modify

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

Type: boolean (details)
token

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

This parameter is required.