wdq - command line access to Wikidata Query Service
Access Wikidata Query Service via command line. A SPARQL query is read from STDIN or option query. Default namespaces are added automatically. If a query starts with { a SELECT clause is added.
query
{
SELECT
# get all parts of the solar system wdq -q '{ ?c wdt:P361 wd:Q544 }'
File with query (- for STDIN as default). If query begins with { it is used as WHERE clause of a SPARQL query. PREFIX definitions are included automatically.
-
Output format. Supported formats include json, xml, tsv, and csv SPARQL result format, simple for flat JSON without language tags (default), and ldjson for line delimited flat json. For more flexible output options pipe to another tool such as jq, miller, and catmandu. If Catmandu is installed, its exporters can directly be used with option export.
json
xml
tsv
csv
simple
ldjson
export
Use a Catmandu exporter as output format, for instance XLS (Excel) and Markdown tables (Table). The following produce same output:
XLS
Table
wdq --export Foo wdq --format ldjson | catmandu convert to Foo
Use Catmandu config file (catmandu.yml) to further configure export.
catmandu.yml
Return Wikidata identifiers as strings instead of URIs (except for output format xml and json).
By default output is colored if writing to a terminal. Disable this with --no-color or force color with --color or -C.
--no-color
--color
-C
SPARQL endpoint. Default value: https://query.wikidata.org/bigdata/namespace/wdq/sparql
https://query.wikidata.org/bigdata/namespace/wdq/sparql
Don't execute query but show it in expanded form. Useful to validate and pretty-print queries.
Show usage help
Show information about the RDF ontology used in Wikibase
Show the default prefixes
Don't add default namespace prefixes to the SPARQL query
Show detailled manual
Show version if this script
Copyright by Jakob Voss voss@gbv.de
voss@gbv.de
Based on a PHP script by Marius Hoch hoo@online.de at https://github.com/mariushoch/asparagus.
hoo@online.de
Licensed under GPL 2.0+
To install App::wdq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::wdq
CPAN shell
perl -MCPAN -e shell install App::wdq
For more information on module installation, please visit the detailed CPAN module installation guide.