{"id":16010155,"url":"https://github.com/nichtich/wdq","last_synced_at":"2025-08-03T22:39:44.070Z","repository":{"id":46863518,"uuid":"43569944","full_name":"nichtich/wdq","owner":"nichtich","description":"Command line interface to Wikidata Query Service","archived":false,"fork":false,"pushed_at":"2024-04-10T11:03:31.000Z","size":143,"stargazers_count":55,"open_issues_count":14,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T18:56:28.444Z","etag":null,"topics":["cli","wikidata"],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/distribution/App-wdq/script/wdq","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nichtich.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-02T18:42:02.000Z","updated_at":"2024-12-13T08:06:13.000Z","dependencies_parsed_at":"2024-06-21T17:45:48.202Z","dependency_job_id":null,"html_url":"https://github.com/nichtich/wdq","commit_stats":{"total_commits":110,"total_committers":3,"mean_commits":"36.666666666666664","dds":"0.036363636363636376","last_synced_commit":"cdb5437943bc65227a8f7188ce1b72e8ee10bf6e"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/nichtich/wdq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichtich%2Fwdq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichtich%2Fwdq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichtich%2Fwdq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichtich%2Fwdq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nichtich","download_url":"https://codeload.github.com/nichtich/wdq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichtich%2Fwdq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268624130,"owners_count":24280148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","wikidata"],"created_at":"2024-10-08T13:04:46.648Z","updated_at":"2025-08-03T22:39:44.045Z","avatar_url":"https://github.com/nichtich.png","language":"Perl","funding_links":[],"categories":["Other Awesome","Misc"],"sub_categories":["BBedit"],"readme":"# NAME\n\nwdq - command line access to Wikidata Query Service\n\n# STATUS\n\n[![Build Status](https://travis-ci.org/nichtich/wdq.png)](https://travis-ci.org/nichtich/wdq)\n[![Coverage Status](https://coveralls.io/repos/nichtich/App-wdq/badge.png)](https://coveralls.io/r/nichtich/App-wdq)\n[![Kwalitee Score](http://cpants.cpanauthors.org/dist/App-wdq.png)](http://cpants.cpanauthors.org/dist/App-wdq)\n\n# SYNOPSIS\n\nAccess [Wikidata Query Service](https://query.wikidata.org/) via command line\nto perform SPARQL queries (`query` mode), lookup entities (`lookup`), or\nsearch items and properties (`search` or `psearch`):\n\n    wdq -g en solar system        # search 'solar system' in English\n    wdq psearch -g es parte       # search property 'parte' in Spanish\n    wdq P361 Q544                 # lookup properties and items\n    wdq '?c wdt:P361 wd:Q544'     # query parts of the solar system\n\nSee the manual for details or get help via `wdq help`:\n\n    wdq help options              # list and explain command line options\n    wdq help modes                # list and explain request modes\n    wdq help output               # explain output control\n    wdq help formats              # list and explain output formats\n    wdq help ontology             # show Wikidata ontology in a nutshell\n    wdq help prefixes             # list RDF prefixes allowed in queries\n    wdq help version              # show version of wdq\n\n# DESCRIPTION\n\nThe command line script `wdq`, included in CPAN module [App::wdq](https://metacpan.org/pod/App::wdq), provides a\ntool to access [Wikidata Query Service](https://query.wikidata.org/). It\nsupports formulation and execution of [SPARQL SELECT\nqueries](http://www.w3.org/TR/sparql11-query/#select) to extract selected\ninformation from Wikidata or other Wikibase instances.\n\n# INSTALLATION\n\nPerl should already installed at most operating systems. Otherwise\n[get Perl!](https://www.perl.org/get.html)\n\n## FROM CPAN\n\nInstall sources from CPAN including all dependencies:\n\n    cpanm App::wdq\n\nFirst [install cpanm](https://github.com/miyagawa/cpanminus/#installation) if\nmissing. If installation of `App::wdq` fails try cpanm option `--notest` or\ninstall dependencies as packages as described below.\n\n## PREBUILD PACKAGES\n\nInstall dependencies as prebuild packages for your operating system:\n\n    # Debian based systems e.g. Ubuntu (\u003e= 14.04)\n    sudo apt-get install libhttp-tiny-perl librdf-query-perl\n\n    # Windows/ActiveState\n    ppm install HTTP-Tiny\n    ppm install RDF-Query\n\nThen install `wdq` from CPAN as described above or copy the script to some\nplace in your `$PATH`:\n\n    wget https://raw.githubusercontent.com/nichtich/wdq/main/script/wdq\n    chmod +x wdq\n\nThe latter method will not install this documentation.\n\n# MODES\n\nRequest mode `query` (default), `lookup`, `serch`, or `psearch` can\nexplicitly be set via first argument or it's guessed from arguments.\n\n## query\n\nRead SPARQL query from STDIN, option `--query|-q`, or argument. Namespace\ndefinitions and `SELECT` clause are added if missing.\n\n    wdq '?c wdt:P361 wd:Q544'\n    wdq '{ ?c wdt:P361 wd:Q544 }'                 # equivalent\n    wdq 'SELECT * WHERE { ?c wdt:P361 wd:Q544 }'  # equivalent\n    wdq \u003c queryfile\n\n## lookup\n\nRead Wikidata entity ids, URLs, or Wikimedia project URLs from STDIN or\narguments. Result fields are `label`, `description`, and `id`:\n\n    wdq Q1\n    wdq lookup Q1                                 # equivalent\n    echo Q1 | wdq lookup                          # equivalent\n    wdq http://de.wikipedia.org/wiki/Universum    # same result\n\n## search / psearch\n\nSearch for items or properties. Result fields are `label`, `id`,\n`description`, and possibly matched `alias`. Search and result language is\nread from environment or option `--language`/`-g`:\n\n    wdq search -g sv Pippi Långstrump\n\nDefault output format in search mode is `text`.\n\n# OPTIONS\n\n- --query|-q QUERY\n\n    Query or query file (`-` for STDIN as default)\n\n- --format|-f FORMAT|TEMPLATE\n\n    Output format or string template. Call `wdq help formats` for details.\n\n- --export EXPORTER\n\n    Use a [Catmandu](https://metacpan.org/pod/Catmandu) exporter as output format.\n\n- --no-header|-H\n\n    Exclude header in CSV output or other exporter.\n\n- --enumerate|-e\n\n    Enumerate results by adding a counter variable `n`\n\n- --limit INTEGER\n\n    Add or override a LIMIT clause to limitate the number of results. Single-digit\n    options such as `-1` can also be used to also set a limit.\n\n- --ids|-i\n\n    Abbreviate Wikidata identifier URIs as strings.\n\n- --language|-g\n\n    Language to query labels and descriptions in. Set to the locale by default.\n    This option is currentl only used on lookup mode.\n\n- --count|-c VARS\n\n    Prepend SPARQL QUERY to count distinct values\n\n- --label|-l VARS\n- --description|-d VARS\n- --text|-t VARS\n\n    Add label, description, or both. Adds `label`/`description` for variable `id`\n    or `xLabel`/`xDescription` for any `x`.\n\n- --ignore\n\n    Ignore empty results instead of issuing warning and exit code.\n\n- --color|-C\n\n    By default output is colored if writing to a terminal. Disable this with\n    `--no-color`, `--monochrome`, or `-M`. Force color with `--color` or `-C`.\n\n- --api URL\n\n    SPARQL endpoint. Default value:\n    `https://query.wikidata.org/bigdata/namespace/wdq/sparql`\n\n- --no-mediawiki|-m\n\n    Don't query MediaWiki API to map URLs to Wikidata items.\n\n- --no-execute|-n\n\n    Don't execute SPARQL queries but show them in expanded form. Useful to\n    validate and pretty-print queries. MediaWiki API requests may be\n\n- -N\n\n    Don't execute any queries. Same as `--no-mediawiki --no-execute`.\n\n- --help|-h|-?\n\n    Show usage help\n\n- --ontology\n\n    Show information about the Wikidata Ontology\n\n- --no-default-prefixes\n\n    Don't add default namespace prefixes to the SPARQL query\n\n- --man\n\n    Show detailled manual\n\n- --version|-V\n\n    Show version if this script\n\n# OUTPUT\n\nOutput can be controlled with options `--format`/`-f`, `--export`,\n`--header`/`--no-header`/`-H`, and `--color`/`--no-color`/`-C`.\n\n## Formats\n\nOption `--format`/`-f` sets an output format or string template:\n\n- `simple` (default in query and lookup mode)\n\n    Flat JSON without language tags\n\n- `text` (default in search mode)\n\n    Print `label`, `alias`, `id` and `description` or `count` when counting.\n    Also sets option `--ids`.\n\n- `ldjson`\n\n    Line delimited Flat JSON\n\n- `csv`\n\n    SPARQL Query Results CSV Format. Suppress header with option\n    `--no-header`/`-H`.  Use Catmandu CSV exporter for more options\n\n- `tsv`\n\n    SPARQL Query Results TSV Format\n\n- `xml`\n\n    SPARQL Query Results XML Format\n\n- `json`\n\n    SPARQL Query Results JSON Format\n\n- `...`\n\n    String template.  Call `wdq help pretty` for details\n\n## Pretty\n\nOption `--format` can be set to a string template with bracket expressions\nwith optional template parameters (for instance `{id|pre= (|post=)}`).\n\n- style\n\n    Highlight `n` name, `v` value, `i` identifier, `t` title, or `e` error\n\n- length\n\n    Abbreviate long values\n\n- align\n\n    Use `left` or `right` to align short values to a given `length`\n\n- pre/post\n\n    Add string before/after value\n\n## Export\n\nOption `--export` sets a [Catmandu](https://metacpan.org/pod/Catmandu) exporter to create output with.  Given\nthe corresponding exporter modules installed, one can write results as `YAML`,\nExcel (`XLS`), and Markdown table (`Table`) among other formats:\n\n    wdq --export YAML                               # short form\n    wdq --format ldjson | catmandu convert to YAML  # equivalent\n\nUse Catmandu config file (`catmandu.yml`) to further configure export.  See\nalso tools such as [jq](http://stedolan.github.io/jq/) and\n[miller](http://johnkerl.org/miller/) for processing results.\n\n# EXAMPLES\n\n    # search \"solar system\" in English (=\u003e Q544)\n    wdq -g en solar system\n\n    # search part-of property (=\u003e P361)\n    wdq psearch -g en part\n\n    # get all parts of the solar system\n    wdq '?c wdt:P361 wd:Q544'\n\n    # look up label and description\n    wdq Q42 P9\n\n    # look up German Wikipedia article and get label description in French\n    wdq -g fr http://de.wikipedia.org/wiki/Argon\n\n    # get all references used at an item\n    wdq 'wd:Q1 ?prop [ prov:wasDerivedFrom ?ref ]'\n\n    # get doctoral advisor graph (academic genealogy) as CSV\n    wdq '?student wdt:P184 ?advisor' --ids --format csv\n\n    # print expanded SPARQL query\n    wdq -n '?c wdt:P361 wd:Q544'\n\n    # execute query and return first 10 tab-separated values\n    wdq -f tsv --limit 10 \u003c query\n\n    # print result as Markdown Table (requires Catmandu::Exporter::Table)\n    wdq --export Table \u003c query\n\n    # count instances (P31) of books (Q571)\n    wdq --count x '?x wdt:P31 wd:Q571'\n\n    # list types (P279) of Exoplanets (Q44559) with label and description\n    wdq '?id wdt:P279 wd:Q44559:' --text id --format text\n\n# WIKIDATA ONTOLOGY\n\n    Entity (item/property)\n     wd:Q* \u003c-- owl:sameAs --\u003e wd:Q*\n           --\u003e rdfs:label, skos:altLabel, schema:description \"*\"@*\n           --\u003e schema:dateModified, schema:version\n           --\u003e wdt:P* \"*\", URI, _:blank\n           --\u003e p:P* Statement\n\n    Item\n     wd:Q* \u003c-- schema:about \u003chttp://*.wikipedia.org/wiki/*\u003e\n                              --\u003e schema:inLanguage, wikibase:badge\n\n    Property\n     wd:P* --\u003e wikibase:propertyType PropertyType\n           --\u003e wkibase:directClaim        wdt:P*\n           --\u003e wikibase:claim             p:P*\n           --\u003e wikibase:statementProperty ps:P*\n           --\u003e wikibase:statementValue    psv:P*\n           --\u003e wikibase:qualifier         pq:P*\n           --\u003e wikibase:qualifierValue    pqv:P*\n           --\u003e wikibase:reference         pr:P*\n           --\u003e wikibase:referenceValue    prv:P*\n           --\u003e wikibase:novalue           wdno:P*\n\n    PropertyType\n     wikibase: String, Url, WikibaseItem, WikibaseProperty, CommonsMedia, Math,\n               Monolingualtext, GlobeCoordinate, Quantity, Time, ExternalId\n\n\n    Statement\n     wds:* --\u003e wikibase:rank Rank\n           --\u003e a wdno:P*\n           --\u003e ps:P* \"*\", URI, _:blank\n           --\u003e psv:P* Value\n           --\u003e pq:P* \"*\", URI, _:blank\n           --\u003e pqv:P* Value\n           --\u003e prov:wasDerivedFrom Reference\n\n    Reference\n     wdref:* --\u003e pr:P* \"*\", URI\n             --\u003e prv:P* Value\n\n    Rank\n     wikibase: NormalRank, PreferredRank, DeprecatedRank, BestRank\n\n    Value (GlobecoordinateValue/QuantityValue/TimeValue)\n     wdv:* --\u003e wikibase: geoLatitude, geoLongitude, geoPrecision, geoGlobe URI\n           --\u003e wikibase: timeValue, timePrecision, timeTimezone, timeCalendarModel\n           --\u003e wikibase: quantityAmount, quantityUpperBound, quantityLowerBound,\n                         quantityUnit URI\n\n# COPYRIGHT AND LICENSE\n\nCopyright by Jakob Voss `voss@gbv.de`\n\nBased on a PHP script by Marius Hoch `hoo@online.de`\nat [https://github.com/mariushoch/asparagus](https://github.com/mariushoch/asparagus).\n\nLicensed under GPL 2.0+\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichtich%2Fwdq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnichtich%2Fwdq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichtich%2Fwdq/lists"}