维基百科 API 响应中的参数是什么意思?

What do the parameters in Wikipedia API response mean?

调用维基百科 API 时,链接 object 中的键是什么意思?

例如,呼叫:

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

回复:

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

当您了解到 API 内部使用主要用于 XML 输出而非 JSON 的结果格式时,属性 名称可能更有意义您正在查看的格式。如果您查看 XML 中的查询结果,它们是

<parse title="List of cognitive biases" pageid="510791">
  <links>
    <pl ns="14" exists="" xml:space="preserve">Category:Articles with unsourced statements from November 2013</pl>
    <pl ns="10" exists="" xml:space="preserve">Template:Biases</pl>
    …
    <pl ns="0" exists="" xml:space="preserve">Academic bias</pl>

现在,回答您的问题。

I'm guessing ns stands for "namespace"?

是的。

but why is it an integer?

因为它是命名空间 ID。命名空间的名称可能会改变,它可能会得到别名和类似的东西。你可以 query those.

Why is exists empty for every object?

因为它是一个布尔属性。当链接页面不存在时,它将完全丢失。

Why is what appears to be the page name title key called *?

因为它是 "XML tag" 对象的内容。

你是对的,ns代表namespace, and the all "35 namespaces in Wikipedia are numbered for programming purposes..."

exists 表示此页面的 link 在维基百科中可用。如果 link 不存在(它是 redlink), this line will missing (example with Wikipedia:Most-wanted articles)。

顺便说一下,您可以使用 action query:

获得相同但更紧凑的结果
https://en.wikipedia.org/w/api.php?action=query&titles=List_of_cognitive_biases&prop=links&pllimit=500

对于您的示例,结果将是:

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