@todoforai/woocommerce-api
v0.1.0
Published
JSON-first CLI for the WooCommerce REST API (wc/v3): products, orders, customers, coupons, refunds
Downloads
210
Readme
WooCommerce REST API CLI
Independent CLI for one WooCommerce store's REST API (wc/v3). It is not an official WooCommerce product. It prints JSON, uses the API's own query and body field names, and requires an explicit --yes for every write.
Auth
Use a store URL plus a REST key pair, sent with HTTP Basic auth over HTTPS. Plain HTTP is accepted only for localhost. WooCommerce rejects consumer keys over plain HTTP.
- WooCommerce key: WP Admin → WooCommerce → Settings → Advanced → REST API → Add key (Read/Write). This gives you a
ck_…key and acs_…secret. - WordPress application password: Users → Profile → Application Passwords. The key is the username and the secret is the generated password.
printf '%s' "$CS" | woocommerce-api auth --url https://shop.example.com --key ck_… --secret-stdin # verifies via /system_status
woocommerce-api whoamiSetting all three of WOOCOMMERCE_URL, WOOCOMMERCE_KEY and WOOCOMMERCE_SECRET overrides the saved credentials. Credentials are saved in ~/.config/woocommerce-api/credentials.json with mode 0600.
Commands
There are 155 commands in 15 groups. scripts/generate.py generates them from WooCommerce's own route index (GET /wp-json/wc/v3?context=help), dumped from a vanilla WooCommerce 11.1.2 store. Commands are named <group> <sub-resource->verb [ids]:
woocommerce-api products list --search mug --per_page 20
woocommerce-api products create --data '{"name":"Mug","type":"simple","regular_price":"9.99"}' --yes
woocommerce-api products variations-list 10
woocommerce-api orders list --status processing --all
woocommerce-api orders update 123 --data '{"status":"completed"}' --yes
woocommerce-api orders notes-create 123 --data '{"note":"Shipped","customer_note":true}' --yes
woocommerce-api orders refunds-create 123 --data '{"amount":"5.00","api_refund":false}' --yes
woocommerce-api customers delete 7 --force true --yes
woocommerce-api products create --schema # body fields, offline
woocommerce-api request GET /wp-json/wc-analytics/reports/revenue/stats # other namespaces / plugins--allfollowsX-WP-TotalPageswithper_page=100.- DELETE moves items to the trash unless you pass
--force true. Customers and terms require--force true. - Routes added by extensions are not generated; reach them with
request.
Develop
bun test && bun run test:nodeTested against a local WordPress 7.1.2 + WooCommerce 11.1.2 (docker), with a consumer key over an HTTPS tunnel: product, customer and order create/update/delete, order notes, refunds and --all pagination.
