Module:Sensitive IP addresses/API/doc: Difference between revisions

Content deleted Content added
add "the" to the descriptions, as has been done with the real data
m change source to syntaxhighlight
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{Module rating|protected}}
{{Used in system}}
This module provides an API for information about [[WP:SIP|IP addresses that Wikipedia considers sensitive]]. The intention is that this one API can be used for templates, Lua modules, and software using the [[mw:API:Main page|MediaWiki Action API]] such as JavaScript gadgets and bots.
 
Line 11 ⟶ 13:
To load this module from Lua modules, use:
 
<sourcesyntaxhighlight lang="lua">
local querySensitiveIPs = require('Module:Sensitive IP addresses/API').query
</syntaxhighlight>
</source>
 
The query function is called with named parameters. For example:
 
<sourcesyntaxhighlight lang="lua">
local result = querySensitiveIPs{
test = {'1.2.3.4', '5.6.7.8'}
}
</syntaxhighlight>
</source>
 
== Parameters ==
Line 39 ⟶ 41:
The top level object contains exactly one child object. If the query executed successfully, this object has a key of <code>sensitiveips</code> and contains the query results.
 
<sourcesyntaxhighlight lang="json">
{
"sensitiveips": {
Line 45 ⟶ 47:
}
}
</syntaxhighlight>
</source>
 
If there were any errors when executing the query, the child of the top-level object has a key of <code>error</code> and contains error information. The error object has three keys: <code>code</code>, the error ID; <code>info</code>, the error message; and <code>*</code>, a message about where to find the API documentation. The error IDs all have a prefix of "sipa". For example:
 
<sourcesyntaxhighlight lang="json">
{
"error": {
Line 57 ⟶ 59:
}
}
</syntaxhighlight>
</source>
 
=== Sensitive IPs object ===
Line 103 ⟶ 105:
 
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
test = {'1.2.3.4'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="lua">
{
["sensitiveips"] = {
}
}
</syntaxhighlight>
</source>
 
=== One match ===
 
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
test = {'156.33.5.76'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="lua">
{
["sensitiveips"] = {
Line 166 ⟶ 168:
},
}
</syntaxhighlight>
</source>
 
=== One match, JSON output ===
Line 172 ⟶ 174:
Query:
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
format = 'json',
test = {'156.33.5.76'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="json">
{
"sensitiveips":{
Line 219 ⟶ 221:
}
}
</syntaxhighlight>
</source>
 
=== Entity IDs ===
 
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
format = 'json',
entities = {'usdhs', 'usdoj'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="json">
{
"sensitiveips": {
Line 262 ⟶ 264:
}
}
</syntaxhighlight>
</source>
 
=== Invalid IP error ===
 
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
test = {'foo'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="lua">
{
["error"] = {
Line 282 ⟶ 284:
}
}
</syntaxhighlight>
</source>
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |