@miketromba/polar-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/polar.js +89 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Tromba
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/banner.jpg" alt="@miketromba/polar-cli" width="100%" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
Unofficial CLI for the <a href="https://polar.sh">Polar</a> platform. Full API parity with the <a href="https://github.com/polarsource/polar-js">@polar-sh/sdk</a>, optimized for developers and AI agents.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
Install the CLI, then give your AI assistant the skill to use it:
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm install -g @miketromba/polar-cli
|
|
15
|
+
npx skills add miketromba/polar-cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That's it. Your AI assistant now knows how to manage your Polar products, customers, subscriptions, checkouts, and more — just ask it naturally.
|
|
19
|
+
|
|
20
|
+
### Other package managers
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# yarn
|
|
24
|
+
yarn global add @miketromba/polar-cli
|
|
25
|
+
|
|
26
|
+
# pnpm
|
|
27
|
+
pnpm add -g @miketromba/polar-cli
|
|
28
|
+
|
|
29
|
+
# bun
|
|
30
|
+
bun install -g @miketromba/polar-cli
|
|
31
|
+
|
|
32
|
+
# or run without installing
|
|
33
|
+
npx @miketromba/polar-cli products list
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Works with Node.js 18+.
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Authenticate
|
|
42
|
+
polar auth login --token polar_pat_...
|
|
43
|
+
|
|
44
|
+
# List your products
|
|
45
|
+
polar products list
|
|
46
|
+
|
|
47
|
+
# Get a specific customer
|
|
48
|
+
polar customers get cust_abc123
|
|
49
|
+
|
|
50
|
+
# Count active subscriptions
|
|
51
|
+
polar subscriptions list --active -o count
|
|
52
|
+
|
|
53
|
+
# Create a checkout
|
|
54
|
+
polar checkouts create --products prod_123 --success-url https://example.com/thanks
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## AI-Agent Optimized Output
|
|
58
|
+
|
|
59
|
+
The CLI auto-detects whether it's being piped and adjusts output accordingly:
|
|
60
|
+
|
|
61
|
+
- **TTY (interactive)** — table format with colors
|
|
62
|
+
- **Piped / non-TTY** — compact `key=value` format, minimal tokens
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Human sees a table
|
|
66
|
+
polar products list
|
|
67
|
+
|
|
68
|
+
# AI agent (piped) sees compact output
|
|
69
|
+
polar products list | cat
|
|
70
|
+
# products 1-5/42 page=1
|
|
71
|
+
# [1] id=prod_123 name="Pro Plan" isRecurring=true prices=1
|
|
72
|
+
# [2] id=prod_456 name="Starter" isRecurring=true prices=1
|
|
73
|
+
# next: polar products list --page 2 --limit 5
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Output Formats
|
|
77
|
+
|
|
78
|
+
| Flag | Format | Best For |
|
|
79
|
+
|------|--------|----------|
|
|
80
|
+
| `-o compact` | `key=value` one-liners | AI agents (default when piped) |
|
|
81
|
+
| `-o table` | Aligned columns | Humans (default in terminal) |
|
|
82
|
+
| `-o json` | Minified JSON | Programmatic consumption |
|
|
83
|
+
| `-o jsonl` | JSON Lines | Streaming / `jq` |
|
|
84
|
+
| `-o csv` | CSV with headers | Export / spreadsheets |
|
|
85
|
+
| `-o tsv` | Tab-separated | Unix tools (`cut`, `awk`) |
|
|
86
|
+
| `-o id` | IDs only, one per line | Piping to other commands |
|
|
87
|
+
| `-o count` | Single integer | "How many?" queries |
|
|
88
|
+
|
|
89
|
+
### Field Selection
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Only show specific fields
|
|
93
|
+
polar customers list --fields id,email,name
|
|
94
|
+
|
|
95
|
+
# Full detail on a single entity
|
|
96
|
+
polar products get prod_123 --detail
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Commands
|
|
100
|
+
|
|
101
|
+
### Core
|
|
102
|
+
|
|
103
|
+
| Command | Description |
|
|
104
|
+
|---------|-------------|
|
|
105
|
+
| `polar products` | Manage products (list, create, update, archive) |
|
|
106
|
+
| `polar subscriptions` | Manage subscriptions (list, get, create, revoke) |
|
|
107
|
+
| `polar orders` | Manage orders (list, get, invoices, export) |
|
|
108
|
+
| `polar customers` | Manage customers (list, create, update, delete) |
|
|
109
|
+
| `polar checkouts` | Manage checkout sessions |
|
|
110
|
+
| `polar checkout-links` | Manage reusable checkout links |
|
|
111
|
+
|
|
112
|
+
### Monetization
|
|
113
|
+
|
|
114
|
+
| Command | Description |
|
|
115
|
+
|---------|-------------|
|
|
116
|
+
| `polar benefits` | Manage benefits (custom, Discord, GitHub, downloads, license keys) |
|
|
117
|
+
| `polar benefit-grants` | View benefit grant history |
|
|
118
|
+
| `polar license-keys` | Manage and validate license keys |
|
|
119
|
+
| `polar discounts` | Manage discount codes and promotions |
|
|
120
|
+
| `polar refunds` | Manage refunds |
|
|
121
|
+
| `polar disputes` | View payment disputes |
|
|
122
|
+
| `polar payments` | View payment history |
|
|
123
|
+
|
|
124
|
+
### Usage-Based Billing
|
|
125
|
+
|
|
126
|
+
| Command | Description |
|
|
127
|
+
|---------|-------------|
|
|
128
|
+
| `polar meters` | Manage usage meters |
|
|
129
|
+
| `polar customer-meters` | View customer meter usage |
|
|
130
|
+
| `polar events` | Manage and ingest custom events |
|
|
131
|
+
| `polar event-types` | Manage event type definitions |
|
|
132
|
+
| `polar metrics` | Query analytics metrics |
|
|
133
|
+
|
|
134
|
+
### Organization
|
|
135
|
+
|
|
136
|
+
| Command | Description |
|
|
137
|
+
|---------|-------------|
|
|
138
|
+
| `polar orgs` | Manage organizations |
|
|
139
|
+
| `polar members` | Manage organization members |
|
|
140
|
+
| `polar org-tokens` | Manage organization access tokens |
|
|
141
|
+
| `polar webhooks` | Manage webhook endpoints and deliveries |
|
|
142
|
+
| `polar custom-fields` | Manage custom checkout/order fields |
|
|
143
|
+
| `polar files` | Manage file uploads |
|
|
144
|
+
|
|
145
|
+
### Identity
|
|
146
|
+
|
|
147
|
+
| Command | Description |
|
|
148
|
+
|---------|-------------|
|
|
149
|
+
| `polar oauth2` | OAuth2 authorization and token management |
|
|
150
|
+
| `polar oauth2-clients` | Manage OAuth2 clients |
|
|
151
|
+
| `polar customer-sessions` | Create customer portal sessions |
|
|
152
|
+
| `polar member-sessions` | Create member sessions |
|
|
153
|
+
| `polar customer-seats` | Manage subscription seats |
|
|
154
|
+
|
|
155
|
+
### Customer Portal
|
|
156
|
+
|
|
157
|
+
All under `polar portal`:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
polar portal subscriptions list
|
|
161
|
+
polar portal orders get ord_123
|
|
162
|
+
polar portal license-keys validate --key LK-...
|
|
163
|
+
polar portal benefit-grants list
|
|
164
|
+
polar portal wallets list
|
|
165
|
+
# ...and more
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Set default organization
|
|
172
|
+
polar config set organizationId org_abc123
|
|
173
|
+
|
|
174
|
+
# Use sandbox environment
|
|
175
|
+
polar config set server sandbox
|
|
176
|
+
|
|
177
|
+
# View all config
|
|
178
|
+
polar config list
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Environment Variables
|
|
182
|
+
|
|
183
|
+
| Variable | Purpose |
|
|
184
|
+
|----------|---------|
|
|
185
|
+
| `POLAR_ACCESS_TOKEN` | Access token (overrides stored credential) |
|
|
186
|
+
| `POLAR_ORGANIZATION_ID` | Default organization ID |
|
|
187
|
+
| `POLAR_SERVER` | `production` or `sandbox` |
|
|
188
|
+
| `POLAR_OUTPUT` | Default output format |
|
|
189
|
+
|
|
190
|
+
## Global Flags
|
|
191
|
+
|
|
192
|
+
| Flag | Short | Description |
|
|
193
|
+
|------|-------|-------------|
|
|
194
|
+
| `--output <format>` | `-o` | Output format |
|
|
195
|
+
| `--fields <list>` | `-f` | Comma-separated field selection |
|
|
196
|
+
| `--detail` | `-d` | Full detail view |
|
|
197
|
+
| `--server <name>` | `-s` | Server: production or sandbox |
|
|
198
|
+
| `--org <id>` | | Organization ID override |
|
|
199
|
+
| `--yes` | `-y` | Skip confirmation prompts |
|
|
200
|
+
| `--quiet` | `-q` | Data only, no hints |
|
|
201
|
+
| `--limit <n>` | `-l` | Items per page (list commands) |
|
|
202
|
+
| `--page <n>` | `-p` | Page number (list commands) |
|
|
203
|
+
| `--first <n>` | | Shorthand for `--limit N --page 1` |
|
|
204
|
+
|
|
205
|
+
## Development
|
|
206
|
+
|
|
207
|
+
Requires [Bun](https://bun.sh) for development (end users only need Node.js 18+).
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Install dependencies
|
|
211
|
+
bun install
|
|
212
|
+
|
|
213
|
+
# Run the CLI locally (via Bun, no build step)
|
|
214
|
+
bun run polar -- products list
|
|
215
|
+
|
|
216
|
+
# Run tests (200 tests, ~3s)
|
|
217
|
+
bun test
|
|
218
|
+
|
|
219
|
+
# Run tests in watch mode
|
|
220
|
+
bun test --watch
|
|
221
|
+
|
|
222
|
+
# Lint
|
|
223
|
+
bun run lint
|
|
224
|
+
|
|
225
|
+
# Type check
|
|
226
|
+
bun run typecheck
|
|
227
|
+
|
|
228
|
+
# Build for distribution (outputs dist/polar.js)
|
|
229
|
+
bun run build
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT
|