1

I was using the API https://commons.wikimedia.org/w/api.php?action=help&modules=wbsearchentities to fetch depictions In Wikimedia Commons.

On modifying the attributes language/strictlanguage should return depiction in the corresponding language

I found that none of the calls

... returns depiction in the desired language.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373

1 Answers1

1

Since you know the entity ID, there is no point in searching, you can just use wbgetentities:

https://commons.wikimedia.org/w/api.php?format=jsonfm&action=wbgetentities&ids=Q528943&props=labels|aliases|descriptions&languages=hi

{
    "entities": {
        "Q528943": {
            "type": "item",
            "id": "Q528943",
            "labels": {
                "hi": {
                    "language": "hi",
                    "value": "\u0917\u0941\u0906\u0928 \u092c\u094d\u0932\u094b\u092b\u094b\u0930\u094d\u0921"
                }
            },
            "descriptions": {
                "hi": {
                    "language": "hi",
                    "value": "\u0905\u092e\u0947\u0930\u093f\u0915\u0940 \u0905\u0902\u0924\u0930\u093f\u0915\u094d\u0937 \u092f\u093e\u0924\u094d\u0930\u0940"
                }
            },
            "aliases": {}
        }
    },
    "success": 1
}

For wbsearchentities, you'd have to use uselang as opposed to language (which sets the language to search descriptions in, not to display descriptions in... this is very unintuitive, but sort of mentioned in the API description).

Tgr
  • 27,442
  • 12
  • 81
  • 118