Search code examples
mediawikiwikipediawikipedia-apimediawiki-api

What do the parameters in Wikipedia API response mean?


When calling the Wikipedia API, what do the keys in the links objects mean?

  • I'm guessing ns stands for namespace, but why is it an integer?
  • Why is exists empty for every object?
  • Why is what appears to be the page name title key called *?

For example, calling:

https://en.wikipedia.org/w/api.php?action=parse&page=List_of_cognitive_biases&prop=links

Response:

{
    "parse": {
        "title": "List of cognitive biases",
        "pageid": 510791,
        "links": [{
            "ns": 0,
            "exists": "",
            "*": "Anthropomorphism"
        }, {
            "ns": 0,
            "exists": "",
            "*": "Apophenia"
        }, 
        ...
        ]
    }
}

Solution

  • You are right, the ns stands for namespace, and the all "35 namespaces in Wikipedia are numbered for programming purposes...".

    The empty exists means that the link to this page is available in Wikipedia. If the link doesn't exist (it is a redlink), this line will missing (example with Wikipedia:Most-wanted articles).

    By the way you can get the same but more compact result by using action query:

    https://en.wikipedia.org/w/api.php?action=query&titles=List_of_cognitive_biases&prop=links&pllimit=500
    

    For your example the result will be:

    "links": [
        {
            "ns": 0,
            "title": "Anthropomorphism"
        },{
            "ns": 0,
            "title": "Apophenia"
        },
        ...
    ]