API module "askargs"

From semantic-mediawiki.org
askargs
Allows to do ask queries with as little ask query specific syntax as possible
Keywords
API · API module · ask query · action askargs · askargs
Further Information
Provided by: Semantic MediaWiki
Added: 1.7.0
Removed: still available

The "askargs" API module allows you to do ask queries via action "askargs" (?action=askargs) against Semantic MediaWiki using the MediaWiki API and get results back serialized in one of the supported formats. It was introduced with Semantic MediaWiki 1.7.0Released on 1 January 2012 and compatible with MW 1.16.x - 1.19.x..

The module supports three parameters in un-serialized form, so with as little syntax as possible specific to the #ask parser function:

  1. "conditions": The query conditions, i.e. the requirements for a subject (page or subobject) to be included
  2. "printouts": The query printouts, i.e, the properties to show per subject (page or subobject)
  3. "parameters": The query parameters, i.e. all non-condition and non-printout arguments


Starting with Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. this module supports the "api_version" parameter1 allowing to choose between the dictionary structure { ... } (version "2", which is the default to ensure backwards compatibility for any consumer that uses the API) and the list structure [ ... ] (version "3") for the JSON serialization of the resulting data queried with the API.

Limit and offset

As in regular inline (ask) queries, both "limit" and "offset" are specified in the parameter list, e.g. to get the first 10 results: &parameters=limit%3D10.

The API result contains a "query-continue-offset" key, which can be used to fetch additional results: &parameters=offset%3D10|limit%3D10. If there is no "query-continue-offset" key in the result, the end of the result set was reached.

Examples[edit]

Use "dictionary" structure for JSON serialization

../api.php?action=askargs&conditions=Modification%20date::%2B&printouts=Modification%20date&parameters=sort%3DModification%20date|order%3Ddesc&format=jsonfm

API call includes the three parameters as explained earlier on this page:

  1. &conditions=Modification%20date::%2B
  2. &printouts=Modification%20date
  3. &parameters=sort%3DModification%20date|order%3Ddesc
run example
Use "list" structure for JSON serialization

../api.php?action=askargs&conditions=Modification%20date::%2B&printouts=Modification%20date&parameters=sort%3DModification%20date|order%3Ddesc&format=jsonfm&api_version=3

run example
The arguments to all three modules may be concatenated using the pipe "|" character as demonstrated for the parameters module in the example above.
Further examples

References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:3052