从维基共享资源获取描述
Get depictions from Wikimedia Commons
维基共享资源有一个新功能来描述图片所描绘的内容。 Example:
问题
如何使用 wikimedia-android-data-client 库调用或 REST HTTP 请求获取给定图像的 "depicts",如 JSON?
您可以使用一些 Wikibase APIs(我认为目前 well-documented 究竟是哪个或如何不是)。例如。
https://commons.wikimedia.org/w/api.php?action=wbgetclaims&format=jsonfm&entity=M78893847
{
"claims": {
"P180": [
{
"mainsnak": {
"snaktype": "value",
"property": "P180",
"hash": "7754bb4b4dcf94dd0a6b8524351b22df21328a88",
"datavalue": {
"value": {
"entity-type": "item",
"numeric-id": 12280,
"id": "Q12280"
},
"type": "wikibase-entityid"
},
"datatype": "wikibase-item"
},
"type": "statement",
"id": "M78893847$bf7f116a-4d08-0426-0e81-c9552a89fa63",
"rank": "preferred"
},
{
"mainsnak": {
"snaktype": "value",
"property": "P180",
"hash": "8ed7e126588c21d3cf88387d5ee875d528c00a74",
"datavalue": {
"value": {
"entity-type": "item",
"numeric-id": 1021645,
"id": "Q1021645"
},
"type": "wikibase-entityid"
},
"datatype": "wikibase-item"
},
"type": "statement",
"id": "M7889384730fc04-4a1e-f289-93bc-69d6bbf3b7fd",
"rank": "normal"
}
]
}
}
78893847 是您可以通过 query API 获得的页面 ID:
https://commons.wikimedia.org/w/api.php?action=query&format=jsonfm&formatversion=2&titles=File%3AMomoyo-brug%20in%20Shibaura%2C%20gezien%20richting%20het%20zuidoosten%2C%20-15%20maart%202019.jpg
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 78893847,
"ns": 6,
"title": "File:Momoyo-brug in Shibaura, gezien richting het zuidoosten, -15 maart 2019.jpg"
}
]
}
}
维基共享资源有一个新功能来描述图片所描绘的内容。 Example:
问题
如何使用 wikimedia-android-data-client 库调用或 REST HTTP 请求获取给定图像的 "depicts",如 JSON?
您可以使用一些 Wikibase APIs(我认为目前 well-documented 究竟是哪个或如何不是)。例如。
https://commons.wikimedia.org/w/api.php?action=wbgetclaims&format=jsonfm&entity=M78893847
{
"claims": {
"P180": [
{
"mainsnak": {
"snaktype": "value",
"property": "P180",
"hash": "7754bb4b4dcf94dd0a6b8524351b22df21328a88",
"datavalue": {
"value": {
"entity-type": "item",
"numeric-id": 12280,
"id": "Q12280"
},
"type": "wikibase-entityid"
},
"datatype": "wikibase-item"
},
"type": "statement",
"id": "M78893847$bf7f116a-4d08-0426-0e81-c9552a89fa63",
"rank": "preferred"
},
{
"mainsnak": {
"snaktype": "value",
"property": "P180",
"hash": "8ed7e126588c21d3cf88387d5ee875d528c00a74",
"datavalue": {
"value": {
"entity-type": "item",
"numeric-id": 1021645,
"id": "Q1021645"
},
"type": "wikibase-entityid"
},
"datatype": "wikibase-item"
},
"type": "statement",
"id": "M7889384730fc04-4a1e-f289-93bc-69d6bbf3b7fd",
"rank": "normal"
}
]
}
}
78893847 是您可以通过 query API 获得的页面 ID: https://commons.wikimedia.org/w/api.php?action=query&format=jsonfm&formatversion=2&titles=File%3AMomoyo-brug%20in%20Shibaura%2C%20gezien%20richting%20het%20zuidoosten%2C%20-15%20maart%202019.jpg
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 78893847,
"ns": 6,
"title": "File:Momoyo-brug in Shibaura, gezien richting het zuidoosten, -15 maart 2019.jpg"
}
]
}
}