Allows to persist options
wb config <key> [value]# Output the current config and the help menu
wb config
# Output the config value for the key 'clipboard'
wb config clipboard
# For wb config credentialswb config clipboard trueget config file path
wb config pathReset a single parameter to come back to its default value
wb config instance resetor clear the whole config
wb config resetRequired for write operations
# Output the current credentials for a given instance
# If no credentials are set for this instance, start a prompt session to add credentials,
# either OAuth tokens (recommended) or a username and password
wb config credentials https://www.wikidata.org
# Reset those credentials
wb config credentials https://www.wikidata.org reset
# Get the prompt again
wb config credentials https://www.wikidata.org
# Test your credentials validity
wb config credentials https://www.wikidata.org test(*) Yes, just the sight of word OAuth might give you chills, but setting up an owner-only consumers is actually super fast (no need for validation) and rather simple: just follow the wb config credentials https://my.wikibase.instance prompt instructions.
wb do re-login every time, as cookies are not stored between sessions. An excessive number of logins to Wikibase should be avoided: if you need to perform a lot of edits, you are strongly advised to use the batch mode.
Set a bot flag on requests made by a bot account is required and can be done by setting the config.bot value:
# Default: false
wb config bot trueSet the maxlag value
# Default: 5
wb config maxlag 10Set the preferred language (same as -l, --lang)
# Default: process.env.LANG.slice(0, 2)
wb config lang nlFormat the output of commands as JSON, when possible (same as -j, --json)
# Default: false
wb config json trueCopy command results to the clipboard, when this option is available (same as -c, --clipboard)
# Default: false
wb config clipboard trueSet commands to print verbose output (same as -v, --verbose)
# Default: false
wb config verbose trueYou may want to use those commands against a different Wikibase than wikidata.org (same as -i, --instance)
# Default: https://wikidata.org/w/api.php
wb config instance https://mywikibase.instance/w/api.phpYou're all set to make requests against your custom instance:
wb label Q1
wb claims Q1
wb data Q1
wb open Q1You can also set a custom SPARQL endpoint (same as -e, --sparql-endpoint)
# Default: https://query.wikidata.org/sparql
wb config sparql-endpoint https://example.com/sparqlYou're all set to make requests against your custom instance:
wb query --property P2002 --object timberners_leeAlternatively to using wb config, you can set environment variables. Priority is given to the command line options, then environment variables, then config values.
export WB_INSTANCE=https://wikibase-registry.wmflabs.org/w/api.php ; wb label Q2
# => Wikibase
export WB_INSTANCE=https://www.wikidata.org/w/api.php ; wb label Q2
# => EarthAvailable variables:
WB_BOTWB_CLIPBOARDWB_INSTANCEWB_JSONWB_LANGWB_MAXLAGWB_SPARQL_ENDPOINTWB_VERBOSE
Those variables can be useful if you work with several instances, you could set aliases in your shell environment to target specifically one instance or the other:
wdt(){
export WB_INSTANCE=https://test.wikidata.org
wb "$@"
}
wdt search fooBackup:
wb config --json > config.json
# or
cp $(wb config path) config.jsonRestore:
cp config.json $(wb config path)