Jump to content

Module:Sensitive IP addresses/API/doc

From Simple English Wikipedia, the free encyclopedia
Revision as of 23:59, 24 August 2016 by Mr. Stradivarius (talk | changes) (start documenting the API)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:Sensitive IP addresses/API

This module provides an API for information about IP addresses that Wikipedia considers sensitive. The intention is that this one API can be used for templates, Lua modules, and software using the MediaWiki action API such as JavaScript gadgets and bots.

Usage

From templates

Templates wishing to make use of this API need to use an intermediary Lua module to parse the results of API queries. One such module, used to create a wikitable summary of sensitive IPs, exists at Module:Sensitive IP addresses/summary.

From Lua

To load this module from Lua modules, use:

local querySensitiveIPs = require('Module:Sensitive IP addresses/API').query

The query function is called with named parameters. For example:

local result = querySensitiveIPs{
	test = {'1.2.3.4', '5.6.7.8'}
}

Parameters

The following parameters are available to the query function:

  • test - an array of IP addresses and/or IP ranges to test for sensitivity. IP addresses and ranges can be IPv4 or IPv6, and ranges must be in CIDR notation.
  • entities - an array of entity IDs to get information about. An entity is a country or organization which is considered sensitive, and for which blocks should be handled with care. Entity IDs are defined in Module:Sensitive IP addresses/list along with the rest of the sensitive IP data. For example, ushr is the ID for the United States House of Representatives. If the special ID all is contained in the array, information about all entities will be included in the result.
  • format - the format to return results in. Use json to return a JSON-formatted string, and use lua to return a Lua table. If this option is not specified, a Lua table is returned by default.