Hi,
After you run a SPARQL query in the Wikidata Query Service ( https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
Hi,
There is an option to do that - in fact, each library simply wraps around the existing REST endpoint ( based on https://query.wikidata.org/sparql ). If you look at the available Code tabs, after you execute the query, you can select "URL" tab. This will give you an endpoint that will return json with the response. Usage is quite simple - SPARQL query is a "query" param in a GET request to "https://query.wikidata.org/sparql" endpoint.
Hope that helps!
Regards, Zbyszko
On Wed, Jan 27, 2021 at 3:50 PM Yaron Koren yaron57@gmail.com wrote:
Hi,
After you run a SPARQL query in the Wikidata Query Service ( https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
-- WikiWorks · MediaWiki Consulting · http://wikiworks.com _______________________________________________ Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
If you look through the code examples the query service UI generates for you, you can see that several of them (including the PHP one and the two JavaScript ones) don’t use any special SPARQL libraries. You can also see the “URL” option, which is just the URL you’re looking for. The returned format depends on the Accept request header (or “format” query parameter), so if you add a request header “Accept: text/csv”, you’ll get CSV back.
Cheers, Lucas
On 27.01.21 15:49, Yaron Koren wrote:
Hi,
After you run a SPARQL query in the Wikidata Query Service (https://query.wikidata.org https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
-- WikiWorks · MediaWiki Consulting · http://wikiworks.com http://wikiworks.com
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
Docs please? Can someone point me to the Wikidata docs on this? I'd imagine it's somewhere buried under subpages from https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_H... ???
Thad https://www.linkedin.com/in/thadguidry/ https://calendly.com/thadguidry/
On Wed, Jan 27, 2021 at 9:04 AM Lucas Werkmeister mail@lucaswerkmeister.de wrote:
If you look through the code examples the query service UI generates for you, you can see that several of them (including the PHP one and the two JavaScript ones) don’t use any special SPARQL libraries. You can also see the “URL” option, which is just the URL you’re looking for. The returned format depends on the Accept request header (or “format” query parameter), so if you add a request header “Accept: text/csv”, you’ll get CSV back.
Cheers, Lucas On 27.01.21 15:49, Yaron Koren wrote:
Hi,
After you run a SPARQL query in the Wikidata Query Service ( https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
-- WikiWorks · MediaWiki Consulting · http://wikiworks.com
Wikidata mailing listWikidata@lists.wikimedia.orghttps://lists.wikimedia.org/mailman/listinfo/wikidata
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
I think I found it... https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#SPARQL_end...
Looks like it's missing a bit of that info that all of you were saying.
Thad https://www.linkedin.com/in/thadguidry/ https://calendly.com/thadguidry/
On Wed, Jan 27, 2021 at 9:28 AM Thad Guidry thadguidry@gmail.com wrote:
Docs please? Can someone point me to the Wikidata docs on this? I'd imagine it's somewhere buried under subpages from https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_H... ???
Thad https://www.linkedin.com/in/thadguidry/ https://calendly.com/thadguidry/
On Wed, Jan 27, 2021 at 9:04 AM Lucas Werkmeister < mail@lucaswerkmeister.de> wrote:
If you look through the code examples the query service UI generates for you, you can see that several of them (including the PHP one and the two JavaScript ones) don’t use any special SPARQL libraries. You can also see the “URL” option, which is just the URL you’re looking for. The returned format depends on the Accept request header (or “format” query parameter), so if you add a request header “Accept: text/csv”, you’ll get CSV back.
Cheers, Lucas On 27.01.21 15:49, Yaron Koren wrote:
Hi,
After you run a SPARQL query in the Wikidata Query Service ( https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
-- WikiWorks · MediaWiki Consulting · http://wikiworks.com
Wikidata mailing listWikidata@lists.wikimedia.orghttps://lists.wikimedia.org/mailman/listinfo/wikidata
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
Hi,
Thanks to all of you for your help. Yes, I had missed that "Link > SPARQL endpoint" part of the interface. As Zybszko noted, just creating a URL like "https://query.wikidata.org/sparql?query=SPARQL_HERE" will lead to an automatic download. And, as the documentation that Thad found points out, you can add "&format=json" to have the output be in JSON instead of XML. (As Lucas noted, you can also get other formats like CSV by changing the HTTP request header, but once you get into that sort of thing I don't know if it really counts as a REST API any more.) Anyway, JSON should be great for my purposes.
Thanks again, Yaron
On Wed, Jan 27, 2021 at 10:32 AM Thad Guidry thadguidry@gmail.com wrote:
I think I found it... https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#SPARQL_end...
Looks like it's missing a bit of that info that all of you were saying.
Thad https://www.linkedin.com/in/thadguidry/ https://calendly.com/thadguidry/
On Wed, Jan 27, 2021 at 9:28 AM Thad Guidry thadguidry@gmail.com wrote:
Docs please? Can someone point me to the Wikidata docs on this? I'd imagine it's somewhere buried under subpages from https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_H... ???
Thad https://www.linkedin.com/in/thadguidry/ https://calendly.com/thadguidry/
On Wed, Jan 27, 2021 at 9:04 AM Lucas Werkmeister < mail@lucaswerkmeister.de> wrote:
If you look through the code examples the query service UI generates for you, you can see that several of them (including the PHP one and the two JavaScript ones) don’t use any special SPARQL libraries. You can also see the “URL” option, which is just the URL you’re looking for. The returned format depends on the Accept request header (or “format” query parameter), so if you add a request header “Accept: text/csv”, you’ll get CSV back.
Cheers, Lucas On 27.01.21 15:49, Yaron Koren wrote:
Hi,
After you run a SPARQL query in the Wikidata Query Service ( https://query.wikidata.org), the interface provides a lot of options - you can download the results in formats like CSV and JSON, and it even provides code to let you run that query directly in a variety of different computer languages. What I don't know, though, is whether there is some URL that, when accessed, will directly retrieve the results, in some format like CSV or JSON. The idea is that some code - in any language - can get the results without needing any SPARQL-related libraries or special handling, by just going to the "CSV URL" (for instance) and retrieving the results. Does such a thing exist?
-Yaron
-- WikiWorks · MediaWiki Consulting · http://wikiworks.com
Wikidata mailing listWikidata@lists.wikimedia.orghttps://lists.wikimedia.org/mailman/listinfo/wikidata
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata