Interact with BigCommerce stores via command line.
- Quick start
- Commands
- Options
- Contributing
Install bigcli into isolated python environment using pipx.
brew install pipx
pipx ensurepath
pipx install git+https://github.com/aglensmith/bigcommerce-cli-python@mainRun bigcli env to create and open the ~/.bigcli/.env file.
$ bigcli envReplace hash and token in ~/.bigcli.env with your credentials.
BIGCLI_STORE_HASH_DEV="hash"
BIGCLI_AUTH_TOKEN_DEV="token"Save, and run your first command.
$ bigcli api Productsusage: bigcli [-h]
{api,a,env,e,files,f,settings,s,task,t,themes,th,widgets,w} ...
Interact with BigCommerce stores via command line
optional arguments:
-h, --help show this help message and exit
Commands:
{api,a,env,e,files,f,settings,s,task,t,themes,th,widgets,w}
api (a) make API requests for any resource
env (e) create or open ~/.bigcli/.env file
files (f) list all ~/.bigcli/ files
settings (s) interact with store settings
task (t) run miscellaneous tasks
themes (th) interact with store themes
widgets (w) interact with store widgets
$ bigcli a Products -p include_fields=sku,name,price limit=10 -o csv$ bigcli themes cleanup # prompts for confirmation$ biglci a Products -o
$ bigcli files -o
You can specify an arbitrary number of API keys in ~/.bigcli/.env or a .env in your current working directory.
# used by default
BIGCLI_STORE_HASH_DEV="hash"
BIGCLI_AUTH_TOKEN_DEV="token"
# used when -e foo specified
BIGCLI_STORE_HASH_FOO="hash"
BIGCLI_AUTH_TOKEN_FOO="token"
# used when -e bar specified
BIGCLI_STORE_HASH_BAR="hash"
BIGCLI_AUTH_TOKEN_BAR="token"
# ...You can specify which credentials to use by passing in the suffix on the command line.
$ bigcli api Products -e FOOusage: bigcli api [resource] [method]
optional arguments:
-h, --help show this help message and exit
-l, --list list available api resources
input options:
-d DATA include json data for request body
-in [path] specify file path to request body json
-p [params[params..]] specify params
output options:
-m, --minify minify json output
-o [OUT] specify outfile
-a attribute specify a single resource attribute to
credentials options:
-c, --creds get prompted for api credentials
-e SUFFIX specify .env suffix (ex: PROD)
request:
resource An API resource (run bigcli a -l to see all)
method get, all, update, or delete
-i [id [id ...]] specify resource IDs for path
# list available api resources
$ bigcli a -l
# get first page of products
$ bigcli a Products -p page=1
# get products on all pages
$ bigcli a Products iterall$ bigcli settings -lall list all store settings
logo List logo settings
profile List logo settings
email_statuses List email status settings
# ...Run bigcli themes -l to see a list of theme tasks.
$ bigcli themes -llist List themes
cleanup delete all inactive themes
delete delete a single theme
# ...Run bigcli widgets -l to get a list of widget tasks.
$ bigcli widgets -ltemplates list widget templates by [uuid], name | Ex: bigcli t widget_templates
placements list widget placements by [uuid], name | Ex: bigcli t widget_templates
regions list all widget regions (or specify filenames) Ex: bigcli widgets regions pages/homeUse the env command to open the ~/.bigcli/.env file. If one doesn't exist, bigcli will create it for you.
$ bigcli envusage: bigcli files [-h] [-o] [-e]
List all ~/.bigcli files
optional arguments:
-h, --help show this help message and exit
-o open all .bigcli filesUse files with no options to list all files in ~/.bigcli.
$ bigcli files~/.bigcli/_last.json # latest output will always be here
~/.bigcli/.env
~/.bigcli/h10wocxy6s-Products-get.json # get products for store h10wocxy6sUse -d to pass in request body json on the command line.
# update a page
$ bigcli api Pages -i 8 -d '{"name": "Pages V3 Test", "type": "page"}'use -in to specify an infile for the request body.
# update a page from a json file
$ bigcli api Pages update -i 8 -in data.jsonUse the -o option to save output to ~/.bigcli/.
$ bigcli api Products -oUse bigcli files to list the files in ~/.bigcli.
$ bigcli files
~/.bigcli/_last.json # latest output will always be here
~/.bigcli/.env
~/.bigcli/h10wocxy6s-Products-get.json # get products for store h10wocxy6sYou can also specify a specific file path.
$ bigcli a Store -o ~/Desktop/store.jsonAnd even save json responses as a csv.
$ bigcli a Products -p include_fields=sku,name,price limit=10 -o csvusage: bigcli task [task]
task options:
-h, --help show this help message and exit
-l, --list list available tasks
-D, --dry-run test a task without making changes
input options:
-d DATA include json data for request body
-in [path] specify file path to request body json
-p [params[params..]] specify params
output options:
-m, --minify minify json output
-o [OUT] specify outfile
credentials options:
-c, --creds get prompted for api credentials
-e SUFFIX specify .env suffix (ex: PROD)
# clone repo
git clone git@github.com:aglensmith/bigcommerce-cli-python.git
# install with pip in editable mode
pip install -e ./bigcommerce-cli-python/bigcli
# code changes will be reflected when running bigcli in terminalAdd tasks by adding a function to the Tasks class in bigcli/cli.py.
class Tasks():
# ...
def widget_templates(args, api):
"""
list widget templates by [uuid], name
Ex: bigcli t widget_templates
"""
templates = api.WidgetTemplates.iterall()
return {t['uuid']:t['name'] for t in templates}The function name becomes a CLI argument automatically (ex: bigcli t widget_templates). bigcli t -l prints the docstring.
widget_templates
list widget templates by [uuid], name
Ex: bigcli t widget_templatesbigcli uses a fork of bigcommerce-api-python to generate the arguments for the bigcli a command and to interact with the BigComerce API. Add or edit resources in bigcommerce/resources/v3 and make a pull request to the bigcli branch of the fork.