Get all Wikidata items that are an instance of a given item

前端 未结 2 1285
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 02:47

Wikidata has an item called smartphone model.
I want to get all instances of it.

QUESTION: How to get the identifiers of the instances programma

2条回答
  •  情深已故
    2021-01-05 03:30

    Your question specifies the "Mediawiki API" but this is not possible.

    Wikidata has a SPARQL query service at https://query.wikidata.org

    The query that you want is:

    PREFIX wd: 
    PREFIX wdt: 
    
    SELECT DISTINCT ?item
    WHERE {
        ?item wdt:P31/wdt:P279* wd:Q19723451
    }
    

    This will list the Items that are an 'instance of'(P31) 'smartphone model'(Q19723451) or an 'instance of' a 'subclass of'(P279) 'smartphone model'(Q19723451).

提交回复
热议问题