I use api.php to get the QID of something using its English label.
Example: MozambiqueQ1029

$ wget --quiet -O - "http://www.wikidata.org/w/api.php?action=wbgetentities \

<?xml version="1.0"?><api success="1"><entities><entity id="Q1029" type="item" /></entities></api>

QUESTION: How to do the same with a single small SPARQL request?

1 Answer 1


Yes, you can, but it isn't short:

SELECT distinct ?item ?itemLabel ?itemDescription WHERE{  
  ?item ?label "Mozambique"@en.  
  ?item wdt:P31 wd:Q6256 .
  ?article schema:about ?item .
  ?article schema:inLanguage "en" .
  ?article schema:isPartOf <https://en.wikipedia.org/>. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }    

You can see it here.

  • This worked, but when I searched for "I Robot", I got back the 1977 progressive rock album and no way to disambiguate.
    – Noumenon
    Commented Jun 27, 2022 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.