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
# Output the config value for a specific config file
wb config clipboard --config ./custom_config.json
# Same but specifying the config path via the `WB_CONFIG` environment variable
export WB_CONFIG=./custom_config.json ; wb config clipboard
wb config clipboard true
# Set the `clipboard` in a specific config file
wb config clipboard true --config ./custom_config.json
get config file path
wb config path
Reset a single parameter to come back to its default value
wb config instance reset
or clear the whole config
wb config reset
The --config
option, just like the WB_CONFIG
environment variable, works for every command, including wb config
:
wb config lang es --config ./custom_config.json
wb label Q1 --config ./custom_config.json
Required 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 true
Set the maxlag
value
# Default: 5
wb config maxlag 10
Set the preferred language (same as -l, --lang
)
# Default: process.env.LANG.slice(0, 2)
wb config lang nl
Format the output of commands as JSON, when possible (same as -j, --json
)
# Default: false
wb config json true
Copy command results to the clipboard, when this option is available (same as -c, --clipboard
)
# Default: false
wb config clipboard true
Set commands to print verbose output (same as -v, --verbose
)
# Default: false
wb config verbose true
You 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.php
You're all set to make requests against your custom instance:
wb label Q1
wb claims Q1
wb data Q1
wb open Q1
You 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/sparql
You're all set to make requests against your custom instance:
wb query --property P2002 --object timberners_lee
Alternatively 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.world ; wb label Q3
# => Wikibase World
export WB_INSTANCE=https://www.wikidata.org ; wb label Q3
# => life
export WB_INSTANCE=https://commons.wikimedia.org ; wb label M83175040
Thos are equivalent to the --instance
parameter
wb label Q3 --instance https://wikibase.world ;
wb label Q3 --instance https://www.wikidata.org
wb label M83175040 --instance https://commons.wikimedia.org
but can be useful in different contexts, such as when writting shell scripts.
Available variables:
WB_CONFIG
WB_BOT
WB_CLIPBOARD
WB_INSTANCE
WB_JSON
WB_LANG
WB_MAXLAG
WB_SPARQL_ENDPOINT
WB_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 foo
Backup:
wb config --json > config.json
# or
cp $(wb config path) config.json
Restore:
cp config.json $(wb config path)