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

Content deleted Content added
No edit summary
m change source to syntaxhighlight
 
Line 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 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 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 59:
}
}
</syntaxhighlight>
</source>
 
=== Sensitive IPs object ===
Line 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 168:
},
}
</syntaxhighlight>
</source>
 
=== One match, JSON output ===
Line 174:
Query:
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
format = 'json',
test = {'156.33.5.76'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="json">
{
"sensitiveips":{
Line 221:
}
}
</syntaxhighlight>
</source>
 
=== Entity IDs ===
 
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
format = 'json',
entities = {'usdhs', 'usdoj'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="json">
{
"sensitiveips": {
Line 264:
}
}
</syntaxhighlight>
</source>
 
=== Invalid IP error ===
 
Query:
<sourcesyntaxhighlight lang="lua">
querySensitiveIPs{
test = {'foo'}
}
</syntaxhighlight>
</source>
 
Result:
<sourcesyntaxhighlight lang="lua">
{
["error"] = {
Line 284:
}
}
</syntaxhighlight>
</source>
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |