Skip to main content
The askargs module provides the same querying capability as action=ask, but accepts the query components as separate parameters instead of a single serialized ask-syntax string. This makes it easier to construct queries programmatically without manually encoding pipe-delimited ask syntax.

Endpoint

GET api.php?action=askargs

Parameters

conditions
string
required
The query conditions — the requirements a subject must meet to be included in results. Accepts multiple values separated by |.This corresponds to the [[...]] part of an #ask query. For example, Modification date::+ matches all pages that have any modification date.
printouts
string
default:""
The query printouts — the properties to display for each matching subject. Accepts multiple values separated by |.This corresponds to the ?Property parts of an #ask query. Omit this parameter to return only subject page names.
parameters
string
default:""
Additional query parameters — everything that is neither a condition nor a printout. Accepts multiple values separated by |.This includes options like sort=, order=, limit=, and offset=. For example: sort=Modification date|order=desc|limit=20.
api_version
string
default:"2"
Controls the serialization format of the response. Accepted values: 2 or 3.
format
string
default:"json"
The MediaWiki API output format. Use json for machine-readable output, jsonfm for browser-readable pretty-printed JSON, or xml for XML output.

How conditions map to ask syntax

In action=ask, conditions are written inside double brackets: [[Category:Books]]. In action=askargs, you supply the condition content directly, without the brackets:
action=askaction=askargs
[[Modification date::+]]conditions=Modification date::+
[[Category:Books]]conditions=Category:Books
[[Has author::Jane]][[Category:Books]]conditions=Has author::Jane|Category:Books
Multiple conditions are separated by | in the conditions parameter. Each condition implicitly receives the [[...]] wrapping.

Examples

curl "https://example.org/wiki/api.php?action=askargs\
&conditions=Modification%20date::%2B\
&printouts=Modification%20date\
&parameters=sort%3DModification%20date%7Corder%3Ddesc\
&format=json"

Response structure

The response format is identical to action=ask. See the ask response structure for the full field reference.
{
  "query-continue-offset": 50,
  "query": {
    "printrequests": [
      {
        "label": "",
        "typeid": "_wpg",
        "mode": 2,
        "format": false
      },
      {
        "label": "Modification date",
        "typeid": "_dat",
        "mode": 1,
        "format": ""
      }
    ],
    "results": {
      "Main Page": {
        "printouts": {
          "Modification date": [
            "1381456128"
          ]
        },
        "fulltext": "Main Page",
        "fullurl": "http://localhost:8080/mw/index.php/Main_Page",
        "namespace": 0,
        "exists": true
      }
    },
    "meta": {
      "hash": "a9abdb34024fa8735f6b044305a48619",
      "count": 50,
      "offset": 0
    }
  }
}

Comparison with action=ask

Featureaction=askaction=askargs
Query syntaxSingle query string, fully encoded ask syntaxSeparate conditions, printouts, parameters
Ease of constructionRequires serialization of the full ask stringEasier to build programmatically
ExpressivenessFull ask languageSame underlying engine — equivalent power
Multiple conditionsConcatenated in the query stringPipe-separated in conditions
Output formatIdenticalIdentical
Use action=askargs when building queries dynamically in application code. Use action=ask when you have a pre-composed ask query string or are porting an existing #ask parser function call.

Build docs developers (and LLMs) love