Search code examples
sparqlwikipedia-apiwikidata

How can I search wikidata based on an external identifier such as a Spotify ID?


If I know that Kanye West's Spotify ID is 5K4W6rqBFWDnAN6FQUkS6x, what is the easiest way to resolve that identifier to his Wikidata page, which is https://www.wikidata.org/wiki/Q15935 ?

Do I need to do this with a SPARQL query or is there a way to do this using the MediaWiki JSON API?


Solution

  • Using SPARQL:

    PREFIX wdt: <http://www.wikidata.org/prop/direct/>
    SELECT * { ?s wdt:P1902 "5K4W6rqBFWDnAN6FQUkS6x" }
    

    Wikidata SPARQL endpoint address is https://query.wikidata.org/sparql.