lsq-mini-cli
v0.1.3
Published
Unofficial minimal Lemon Squeezy CLI for Node.js
Maintainers
Readme
Lemon Squeezy Mini CLI (Unofficial)
Unofficial, community CLI for the Lemon Squeezy API. Runs locally (no browser) and is not affiliated with or endorsed by Lemon Squeezy.
Security: Keep your API key secret. Do not commit
~/.lsq-mini-cli.jsonor any.envfiles to source control.
Features
- Configure once (API key + optional store) and reuse across commands.
- List and inspect stores, products, variants, prices, orders, customers.
- Create checkouts, manage discounts, webhooks, subscriptions, license keys, usage records.
- Works with env vars or a local config file (
~/.lsq-mini-cli.jsonby default).
Requirements
- Node.js >= 18
- Lemon Squeezy API key (
LEMONSQUEEZY_API_KEYorLEMON_SQUEEZY_API_KEY)
Install
Local (inside repo):
pnpm install # or npm installGlobal (so you can run lsq directly):
npm install -g lsq-mini-cliSet env vars (optional if you prefer lsq config set):
echo "LEMONSQUEEZY_API_KEY=..." > .env
echo "LEMONSQUEEZY_STORE_ID=..." >> .env # optionalConfig location: ~/.lsq-mini-cli.json (override with LSQ_CONFIG_PATH).
Quick start
If installed globally, use
lsq <command>. If calling through npm scripts, usenpm run lsq -- <command>(the--separates npm args).
# Check config (masked)
lsq config get
# Save API key + store to config
lsq config set --api-key sk_test_xxx --store 12345
# List products for the default store
lsq products:list
# Create a checkout (replace IDs/emails)
lsq checkout:create --store 12345 --variant 6789 --email [email protected] --previewCommon commands
- Config:
lsq config set|get|import-env - Stores:
lsq stores:list - Products/variants/prices:
lsq products:list,lsq variants:list --product <id>,lsq prices:list --variant <id> - Orders:
lsq orders:list [--store <id>] [--email <email>] - Customers:
lsq customers:list [--store <id>] [--email <email>] - Checkouts:
lsq checkouts:list ...,lsq checkout:create --store <id> --variant <id> [...] - Discounts:
lsq discounts:list|create|delete|redemptions - Webhooks:
lsq webhooks:list|create|delete - Subscriptions:
lsq subscriptions:list|cancel|invoices - License keys:
lsq license-keys:list|instances|update - Usage records:
lsq usage:list|create
Example output
$ lsq config get
Config: { apiKey: 'sk_***xxx', storeId: '12345', fromEnv: true }
$ lsq stores:list
┌─────────┬───────┬──────────┬─────────┬──────────────────┬──────────┐
│ (index) │ id │ name │ slug │ domain │ currency │
├─────────┼───────┼──────────┼─────────┼──────────────────┼──────────┤
│ 0 │ '123' │ 'My Dev' │ 'mydev' │ 'mydev.lemonsq…' │ 'USD' │
└─────────┴───────┴──────────┴─────────┴──────────────────┴──────────┘
$ lsq checkout:create --store 123 --variant 456 --email [email protected] --preview
Checkout created: { id: '789', url: 'https://checkout.lemonsqueezy.com/checkout/xyz', preview: true, test_mode: false }Per-command output examples
# Stores
lsq stores:list
┌─────────┬───────┬──────────┬─────────┬──────────────────┬──────────┐
│ (index) │ id │ name │ slug │ domain │ currency │
├─────────┼───────┼──────────┼─────────┼──────────────────┼──────────┤
│ 0 │ '123' │ 'My Dev' │ 'mydev' │ 'mydev.lemonsq…' │ 'USD' │
└─────────┴───────┴──────────┴─────────┴──────────────────┴──────────┘
# Products
lsq products:list --store 123
┌─────────┬───────┬───────┬────────────────┬─────────┬─────────────┐
│ (index) │ id │ store │ name │ status │ price │
├─────────┼───────┼───────┼────────────────┼─────────┼─────────────┤
│ 0 │ '45' │ 123 │ 'Starter Plan' │ 'draft' │ '$9.00' │
└─────────┴───────┴───────┴────────────────┴─────────┴─────────────┘
# Variants / Prices
lsq variants:list --product 45
lsq prices:list --variant 67
# Orders
lsq orders:list --store 123 --page 1 --size 5
┌─────────┬─────────┬────────┬────────┬──────────┬─────────────────────┬──────────────────────┐
│ (index) │ id │ store │ status │ currency │ total │ created │
├─────────┼─────────┼────────┼────────┼──────────┼─────────────────────┼──────────────────────┤
│ 0 │ '888' │ 123 │ 'paid' │ 'USD' │ '$19.00' │ '2024-10-01T12:00Z' │
└─────────┴─────────┴────────┴────────┴──────────┴─────────────────────┴──────────────────────┘
# Customers
lsq customers:list --store 123
┌─────────┬────────┬──────────────┬──────────────┬─────────────────────┬─────────┐
│ (index) │ id │ name │ email │ total_revenue │ mrr │
├─────────┼────────┼──────────────┼──────────────┼─────────────────────┼─────────┤
│ 0 │ '321' │ 'Jane Doe' │ '[email protected]' │ '$190.00' │ '$0.00' │
└─────────┴────────┴──────────────┴──────────────┴─────────────────────┴─────────┘
# Order items
lsq order-items:list --order 888
┌─────────┬────────┬────────┬─────────┬───────┬─────┐
│ (index) │ id │ order │ product │ price │ qty │
├─────────┼────────┼────────┼─────────┼───────┼─────┤
│ 0 │ '9' │ 888 │ 45 │ 1900 │ 1 │
└─────────┴────────┴────────┴─────────┴───────┴─────┘
# Files / Checkouts
lsq files:list --variant 67
lsq checkouts:list --store 123 --variant 67
# Discounts
lsq discounts:list --store 123
lsq discounts:create --store 123 --name Launch --code LAUNCH10 --amount 10 --type percent
Discount created: { id: '901', code: 'LAUNCH10' }
lsq discounts:redemptions --discount 901
# Webhooks
lsq webhooks:list --store 123
lsq webhooks:create --store 123 --url https://example.com/webhook --events order_created,order_refunded
Webhook created: { id: '777', url: 'https://example.com/webhook' }
lsq webhooks:delete --id 777
# Subscriptions
lsq subscriptions:list --store 123
lsq subscription:cancel --id 555
lsq subscription:invoices --subscription 555
# License keys
lsq license-keys:list --variant 67
lsq license-keys:instances --license 222
lsq license-keys:update --id 222 --status active --activation-limit 5
License key updated: { id: '222', status: 'active', activation_limit: 5 }
# License API
lsq license:activate --key XXXX-YYYY --instance my-device
lsq license:validate --key XXXX-YYYY --instance-id abc
lsq license:deactivate --key XXXX-YYYY --instance-id abc
# Usage records
lsq usage:list --subscription 555
lsq usage:create --subscriptionItem 444 --quantity 10 --event api_calls
Usage recorded: { id: '999', quantity: 10 }
# Get raw resources
lsq get:product --id 45
{
"data": { "id": "45", "attributes": { "name": "Starter Plan", "...": "..." } }
}
lsq get:order --id 888
# Invoice / refund
lsq order:invoice --id 888
Invoice URL: https://checkout.lemonsqueezy.com/invoice/abc
lsq order:refund --id 888 --amount 500
Refund issued: { id: 'refund_1', status: 'processed' }Full list and flags: see docs/lsq-mini-cli.md or run lsq --help.
Project structure
scripts/
├── lsq.mjs # Entry point and command dispatcher
└── lib/
├── config.mjs # Configuration management (load/save, env vars)
├── utils.mjs # Shared utilities (parseArgs, printTable, etc.)
├── registry.mjs # Command registry and help text
└── handlers/ # Command handlers organized by domain
├── config.mjs
├── resources.mjs # stores, products, orders, customers, etc.
├── checkout.mjs
├── discounts.mjs
├── license.mjs # license + license-keys
├── webhooks.mjs
├── subscriptions.mjs
├── orders.mjs # invoice, refund
├── usage.mjs
└── get.mjsContributing
- Fork the repo and create a feature branch.
- Add new commands under
scripts/lib/handlers/(one file per domain). - Register them in
scripts/lib/registry.mjsso the dispatcher knows about them. - Update
docs/lsq-mini-cli.mdwith any new command/flags. - Test locally:
npm run lsq -- <command>(orlsq <command>if installed globally). - Open a PR.
Uninstall / clean-up
npm uninstall -g lsq-mini-cli # if installed globally
rm ~/.lsq-mini-cli.json # remove saved config (optional)License
MIT
