5

When I want to know the Wikidata identifier of a Wikivoyage article like Barcelona, I usually run this API call:

wget --quiet -O - "http://www.wikidata.org/w/api.php?action=wbgetentities&sites=enwikivoyage&titles=Barcelona&format=xml&props=" | sed -e "s/.id=\"//" | sed -e "s/\".//"

Barcelona -> Q1492

But now I want to get the identifiers for all articles.

How can I get them without making thousands of API calls?
And also without downloading the WHOLE Wikidata database, which is probably huge.
Is there a file that contains just the Wikivoyage article name to Wikidata identifier mapping?

1
  • @StanislavKralin: Sorry I did not remember my own question, I should have read it carefully. Indeed I ws asking for the identifiers of all articles, so your query is perfect. Could you please post it as an answer? Thanks!
    – Nicolas Raoul
    Commented Jun 29, 2017 at 7:45

2 Answers 2

7

The dump that you want is wb_items_per_site.sql.gz. Though it contains mapping between article titles and wikidata ids for all wikis, so it's relatively big (~1.2 GB compressed).

And it's an SQL dump, so you can either import it into a MySQL database and query that, or you can try to parse it based on the unspecified (but reasonably stable) format.

Since you're interested in English Wikivoyage, look for enwikivoyage in the ips_site_id column.

3

Some history.

Approximately since April 2016 you can do it in this way:

SELECT ?item ?sitelink
WHERE 
{
  ?sitelink schema:about ?item .
# ?sitelink schema:inLanguage "en" .
  ?sitelink schema:isPartOf <https://en.wikivoyage.org/> 
}

Try it!

0

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.