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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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