I currently have a set of ~100 Wikidata items on artists [Q1234, Q2345, Q3456, ... ] that I have to use in order to extract different properties (place/date of birth/death, labels etc.) I tried iterating through the list and creating a query for each but I am currently facing a bit blockage since many are returning Error 429 (Too Many Requests).
Failed to load resource: the server responded with a status of 429 ()
index.html:1 Access to XMLHttpRequest at 'https://query.wikidata.org/sparql?query='...' from origin 'http://127.0.0.1:51881' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Is there a way in which I can insert the set of items straight in the query?
var subquery = 'SELECT DISTINCT ?nameLabel ?cityBLabel ?countryBLabel ?cityDLabel ?countryDLabel ?dateBLabel ?dateDLabel \n' +
'WHERE\n' +
'{\n' +
' :' + item + ' rdfs:label ?name; \n' +
' wdt:P19 ?cityB; \n' +
' wdt:P20 ?cityD; \n' +
' wdt:P569 ?dateB; \n' +
' wdt:P570 ?dateD. \n' +
' ?cityB wdt:P17 ?countryB .\n' +
' ?cityD wdt:P17 ?countryD .\n' +
' SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } \n' +
' FILTER(LANGMATCHES(LANG(?name), "EN")) \n' +
'}\n';
For example in the query above, instead of creating and running one query for each item
, is there a SPARQL command where I can include the whole set ([Q1234, Q2345, Q3456, ... ]) and have it iterate through all of them in one run?
Thank you!
You can use either a FILTER IN
or VALUES
clause for this.
(created community wiki answer from comments)