Awesome
wikibase-cli
The Command-line interface interface to Wikibase instances.
This tool is mostly a CLI interface to the JS modules wikibase-edit and wikibase-sdk, + some treats for the CLI lovers. And a batch mechanism to process millions of edits.
It was primarily developed to target Wikidata, but as then been decoupled to support any Wikibase instance.
Supported systems: any system that can run NodeJS (Linux, Mac OS, Windows, and more)
This project received a Wikimedia Project Grant.
<div align="center"> <br> <a href="https://wikiba.se"><img height="150" src="https://raw.githubusercontent.com/maxlath/wikibase-sdk/master/assets/wikibase.png" alt="wikibase"></a> <!-- yeay hacky margin \o/ --> <a href="https://wikidata.org"><img src="https://raw.githubusercontent.com/maxlath/wikibase-sdk/master/assets/wikidata.jpg" alt="wikidata"></a> <br> <br> </div>Show your support by adding {{#babel:Wikibase CLI}}
to your Wikidata user page
Summary
Changelog
See CHANGELOG.md for version info
Dependencies
General
- NodeJs >= v14 (recommended way to install it: use the awesome NVM to install the latest LTS version
nvm install --lts
) - Git
Per feature
- to use the clipboard option: see copy-paste dependencies
Installation
via npm
npm install -g wikibase-cli
Installing globally allows to make the command wb
(and wd
, the Wikidata-bound verion of wb
) accessible from your shell $PATH
.
If you later need to update the package to a different version, you can run the same command but specifying the version you want (here 12.2.0
)
npm install -g wikibase-cli@12.2.0
or just request the latest version
npm install -g wikibase-cli@latest
via docker
# Might require to be run with sudo depending on your Docker installation
docker run --rm -t maxlath/wikibase-cli
# You can make an alias out of it:
alias wb="docker run --rm -it maxlath/wikibase-cli"
# You're then ready to use it as in the documentation examples
wb label Q1
That would work, but all operations cached data (such as the list of all properties) would need to re-fetch those data for each operations, and all write operations would require you to re-enter your credentials everytime. To work around this, you can allow this container to persist some files on your system, using shared volumes:
mkdir -p $HOME/.config/wikibase-cli $HOME/.cache/wikibase-cli
alias wb='docker run --rm -v "$HOME/.config/wikibase-cli:/root/.config/wikibase-cli" -v "$HOME/.cache/wikibase-cli:/root/.cache/wikibase-cli" -it maxlath/wikibase-cli'
NB: Beware that using wikibase-cli through a Docker container has a performance cost of something like 1s per command, so if you need to run many commands (for instance in a script to make mass edit on the desired Wikibase instance), you should probably rather use the NPM package directly
Commands
Read operations
See Read operations
Write operations
See Write operations
Config
Allows to persist options
See Config
Debug
To get debugging informations, set the DEBUG
environment variable:
# Print all wikibase-cli-specific debugging information
export DEBUG=wikibase-cli ; wb
# Also print wikibase-edit debugging information
export DEBUG=wikibase-* ; wb
# Print only request debugging information
export DEBUG=wikibase-cli:request ; wd label Q1
See Also
- wikibase-sdk: A javascript tool suite to query and work with Wikibase data, heavily used by wikibase-cli
- wikibase-edit: Edit Wikibase from NodeJS, used in wikibase-cli for all write operations
- wikibase-dump-filter: Filter and format a newline-delimited JSON stream of Wikibase entities
- wikidata-subset-search-engine: Tools to setup an ElasticSearch instance fed with subsets of Wikidata
- wikidata-taxonomy: A command-line tool to extract taxonomies from Wikidata
- import-wikidata-dump-to-couchdb: Import a subset or a full Wikidata dump into a CouchDB database
- Other Wikidata external tools
You may also like
Do you know Inventaire? It's a web app to share books with your friends, built on top of Wikidata! And its libre software too.