Module:Sensitive IP addresses/API/doc explained

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 .

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

Parameters

The following parameters are available to the query function:

Results

By default, the query function returns a Lua table, but it can return a JSON object if the format option is set to json. Whether Lua or JSON, the structure of the object returned is similar to the structure of query results from the MediaWiki Action API.

Top-level object

The top level object contains exactly one child object. If the query executed successfully, this object has a key of sensitiveips and contains the query results.

If there were any errors when executing the query, the child of the top-level object has a key of error and contains error information. The error object has three keys: code, the error ID; info, the error message; and *, a message about where to find the API documentation. The error IDs all have a prefix of "sipa". For example:

Sensitive IPs object

If the query was successful, the sensitiveips child object will be present and can contain the following objects and arrays:

IP address objects

An IP address object represents a single IPv4 or IPv6 address that matches a sensitive IP range. IP address objects contain the following fields:

IP range objects

An IP range object represents an IPv4 or IPv6 range that overlaps with a sensitive IP range. IP range objects contain the following fields:

Entity objects

An entity object represents a country or organization that has IP ranges which Wikipedia considers sensitive. Entity objects may contain the following fields:

Examples

Here are some examples of some queries from Lua and the results they produce.

No matches

Query:querySensitiveIPs

Result:

One match

Query:querySensitiveIPs

Result:

One match, JSON output

Query:Query:querySensitiveIPs

Result:

Entity IDs

querySensitiveIPs

Result:

Invalid IP error

Query:querySensitiveIPs

Result: