@ktmcp-cli/nowpayments 1.0.0 → 1.0.2
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/AGENT.md +20 -493
- package/README.md +37 -347
- package/bin/nowpayments.js +6 -85
- package/package.json +22 -21
- package/src/api.js +94 -0
- package/src/config.js +34 -0
- package/src/index.js +306 -0
- package/.env.example +0 -17
- package/INSTALL.md +0 -392
- package/OPENCLAW.md +0 -628
- package/PROJECT_SUMMARY.md +0 -305
- package/banner.png +0 -0
- package/examples/basic-payment.js +0 -66
- package/examples/invoice-flow.js +0 -78
- package/examples/monitor-payment.js +0 -94
- package/logo.png +0 -0
- package/openapi.json +0 -2791
- package/src/commands/auth.js +0 -65
- package/src/commands/currencies.js +0 -95
- package/src/commands/estimate.js +0 -85
- package/src/commands/invoice.js +0 -188
- package/src/commands/payment.js +0 -241
- package/src/commands/payout.js +0 -184
- package/src/commands/status.js +0 -28
- package/src/lib/api.js +0 -133
- package/src/lib/auth.js +0 -70
- package/src/lib/config.js +0 -110
- package/test.sh +0 -250
package/README.md
CHANGED
|
@@ -1,375 +1,65 @@
|
|
|
1
|
+
> "Six months ago, everyone was talking about MCPs. And I was like, screw MCPs. Every MCP would be better as a CLI."
|
|
2
|
+
>
|
|
3
|
+
> — [Peter Steinberger](https://twitter.com/steipete), Founder of OpenClaw
|
|
4
|
+
> [Watch on YouTube (~2:39:00)](https://www.youtube.com/@lexfridman) | [Lex Fridman Podcast #491](https://lexfridman.com/peter-steinberger/)
|
|
5
|
+
|
|
1
6
|
# NOWPayments CLI
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
<img src="banner.png" alt="KTMCP Banner" width="100%">
|
|
5
|
-
</p>
|
|
8
|
+
Production-ready CLI for [NOWPayments](https://nowpayments.io) API. Accept cryptocurrency payments, manage invoices, and handle subscriptions from your terminal.
|
|
6
9
|
|
|
10
|
+
## Features
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
- **Payments** — Create and track crypto payments
|
|
13
|
+
- **Invoices** — Generate payment invoices
|
|
14
|
+
- **Currencies** — List supported cryptocurrencies and get estimates
|
|
15
|
+
- **Subscriptions** — Manage recurring payments
|
|
16
|
+
- **JSON output** — All commands support `--json`
|
|
9
17
|
|
|
10
18
|
## Why CLI > MCP
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
- No MCP server dependency or compatibility issues
|
|
17
|
-
- Standard stdin/stdout interface that all tools understand
|
|
18
|
-
|
|
19
|
-
### 2. Human-First Design
|
|
20
|
-
- Direct terminal usage for developers and operators
|
|
21
|
-
- Rich formatted output with colors and tables
|
|
22
|
-
- Interactive workflows when needed
|
|
23
|
-
- Scriptable for automation
|
|
24
|
-
|
|
25
|
-
### 3. Reliability & Performance
|
|
26
|
-
- No additional server process to manage
|
|
27
|
-
- Direct API calls with minimal overhead
|
|
28
|
-
- Proper error handling and exit codes
|
|
29
|
-
- No WebSocket/transport layer complexity
|
|
30
|
-
|
|
31
|
-
### 4. Development Velocity
|
|
32
|
-
- Easier to test (just run commands)
|
|
33
|
-
- Simpler debugging (standard logs)
|
|
34
|
-
- Faster iteration (no server restarts)
|
|
35
|
-
- Better CI/CD integration
|
|
36
|
-
|
|
37
|
-
### 5. Production Ready
|
|
38
|
-
- Works in Docker containers
|
|
39
|
-
- Cron job compatible
|
|
40
|
-
- Shell script integration
|
|
41
|
-
- No daemon management
|
|
42
|
-
|
|
43
|
-
**Bottom Line:** CLIs are battle-tested, universal interfaces. MCP adds complexity for integration scenarios where a simple CLI + agent pattern works better.
|
|
44
|
-
|
|
45
|
-
## Features
|
|
46
|
-
|
|
47
|
-
- Full NOWPayments API coverage
|
|
48
|
-
- Rich terminal output with colors and formatting
|
|
49
|
-
- JSON output mode for scripting
|
|
50
|
-
- Persistent API key management
|
|
51
|
-
- Sandbox environment support
|
|
52
|
-
- Comprehensive error handling
|
|
53
|
-
- Production-ready reliability
|
|
20
|
+
- **Simpler** — Just a binary you call directly
|
|
21
|
+
- **Composable** — Pipe to `jq`, `grep`, other tools
|
|
22
|
+
- **Scriptable** — Use in shell scripts, CI/CD
|
|
23
|
+
- **AI-friendly** — Easy for AI agents to use
|
|
54
24
|
|
|
55
25
|
## Installation
|
|
56
26
|
|
|
57
27
|
```bash
|
|
58
|
-
npm install -g @ktmcp-cli/
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Or install locally:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
cd ktmcp-nowpayments-cli
|
|
65
|
-
npm install
|
|
66
|
-
npm link
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Quick Start
|
|
70
|
-
|
|
71
|
-
### 1. Get Your API Key
|
|
72
|
-
|
|
73
|
-
Sign up at [NOWPayments.io](https://nowpayments.io) and generate an API key.
|
|
74
|
-
|
|
75
|
-
### 2. Configure Authentication
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
# Save API key to config (recommended)
|
|
79
|
-
nowpayments auth set YOUR_API_KEY
|
|
80
|
-
|
|
81
|
-
# Or use environment variable
|
|
82
|
-
export NOWPAYMENTS_API_KEY=your_api_key
|
|
83
|
-
|
|
84
|
-
# Or pass with each command
|
|
85
|
-
nowpayments --api-key YOUR_API_KEY status
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 3. Verify Connection
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
nowpayments status
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Usage
|
|
95
|
-
|
|
96
|
-
### Authentication Management
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Set API key
|
|
100
|
-
nowpayments auth set YOUR_API_KEY
|
|
101
|
-
|
|
102
|
-
# Show current key (masked)
|
|
103
|
-
nowpayments auth show
|
|
104
|
-
|
|
105
|
-
# Clear API key
|
|
106
|
-
nowpayments auth clear
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Check API Status
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
nowpayments status
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Currency Operations
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
# List all available cryptocurrencies
|
|
119
|
-
nowpayments currencies list
|
|
120
|
-
|
|
121
|
-
# Show only available payment currencies
|
|
122
|
-
nowpayments currencies list --available
|
|
123
|
-
|
|
124
|
-
# Get currency information
|
|
125
|
-
nowpayments currencies info BTC
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Price Estimates
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
# Estimate cryptocurrency amount for fiat price
|
|
132
|
-
nowpayments estimate convert --from USD --to BTC --amount 100
|
|
133
|
-
|
|
134
|
-
# Get minimum payment amount
|
|
135
|
-
nowpayments estimate min --from USD --to BTC
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Payment Management
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
# Create a new payment
|
|
142
|
-
nowpayments payment create \
|
|
143
|
-
--price 99.99 \
|
|
144
|
-
--currency USD \
|
|
145
|
-
--pay-currency BTC \
|
|
146
|
-
--order-id "ORDER-123" \
|
|
147
|
-
--order-description "Premium subscription"
|
|
148
|
-
|
|
149
|
-
# Get payment details
|
|
150
|
-
nowpayments payment get <payment_id>
|
|
151
|
-
|
|
152
|
-
# List all payments
|
|
153
|
-
nowpayments payment list --limit 20
|
|
154
|
-
|
|
155
|
-
# Filter payments by date
|
|
156
|
-
nowpayments payment list \
|
|
157
|
-
--date-from 2024-01-01 \
|
|
158
|
-
--date-to 2024-12-31
|
|
159
|
-
|
|
160
|
-
# Update payment estimate (before expiration)
|
|
161
|
-
nowpayments payment update-estimate <payment_id>
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Invoice Management
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
# Create an invoice
|
|
168
|
-
nowpayments invoice create \
|
|
169
|
-
--price 49.99 \
|
|
170
|
-
--currency USD \
|
|
171
|
-
--order-id "INV-456" \
|
|
172
|
-
--success-url "https://example.com/success" \
|
|
173
|
-
--cancel-url "https://example.com/cancel"
|
|
174
|
-
|
|
175
|
-
# Get invoice details
|
|
176
|
-
nowpayments invoice get <invoice_id>
|
|
177
|
-
|
|
178
|
-
# List invoices
|
|
179
|
-
nowpayments invoice list --limit 10
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Payout Operations
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
# Create a payout
|
|
186
|
-
nowpayments payout create \
|
|
187
|
-
--amount 0.01 \
|
|
188
|
-
--currency BTC \
|
|
189
|
-
--address "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
|
|
190
|
-
|
|
191
|
-
# Verify payout with 2FA
|
|
192
|
-
nowpayments payout verify <payout_id> <verification_code>
|
|
193
|
-
|
|
194
|
-
# Get payout details
|
|
195
|
-
nowpayments payout get <payout_id>
|
|
196
|
-
|
|
197
|
-
# List payouts
|
|
198
|
-
nowpayments payout list
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Global Options
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# Use sandbox environment
|
|
205
|
-
nowpayments --sandbox status
|
|
206
|
-
|
|
207
|
-
# Output raw JSON (for scripting)
|
|
208
|
-
nowpayments --json payment list
|
|
209
|
-
|
|
210
|
-
# Enable debug logging
|
|
211
|
-
nowpayments --debug payment create --price 100 --currency USD --pay-currency BTC
|
|
212
|
-
|
|
213
|
-
# Combine options
|
|
214
|
-
nowpayments --sandbox --json currencies list
|
|
28
|
+
npm install -g @ktmcp-cli/nowpaymentsio
|
|
215
29
|
```
|
|
216
30
|
|
|
217
|
-
##
|
|
31
|
+
## Setup
|
|
218
32
|
|
|
219
|
-
|
|
33
|
+
Get API key from [NOWPayments Dashboard](https://nowpayments.io).
|
|
220
34
|
|
|
221
35
|
```bash
|
|
222
|
-
|
|
223
|
-
payment_data=$(nowpayments --json payment get abc123)
|
|
224
|
-
status=$(echo "$payment_data" | jq -r '.payment_status')
|
|
225
|
-
|
|
226
|
-
if [ "$status" = "finished" ]; then
|
|
227
|
-
echo "Payment completed!"
|
|
228
|
-
fi
|
|
36
|
+
nowpaymentsio config set --api-key YOUR_API_KEY
|
|
229
37
|
```
|
|
230
38
|
|
|
231
|
-
|
|
39
|
+
## Commands
|
|
232
40
|
|
|
233
41
|
```bash
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
# Load automatically
|
|
238
|
-
nowpayments status
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Automation Example
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
#!/bin/bash
|
|
245
|
-
# Create payment and monitor status
|
|
246
|
-
|
|
247
|
-
# Create payment
|
|
248
|
-
payment=$(nowpayments --json payment create \
|
|
249
|
-
--price 100 \
|
|
250
|
-
--currency USD \
|
|
251
|
-
--pay-currency BTC)
|
|
252
|
-
|
|
253
|
-
payment_id=$(echo "$payment" | jq -r '.payment_id')
|
|
254
|
-
pay_address=$(echo "$payment" | jq -r '.pay_address')
|
|
255
|
-
|
|
256
|
-
echo "Payment created: $payment_id"
|
|
257
|
-
echo "Send to: $pay_address"
|
|
258
|
-
|
|
259
|
-
# Monitor status
|
|
260
|
-
while true; do
|
|
261
|
-
status=$(nowpayments --json payment get "$payment_id" | jq -r '.payment_status')
|
|
262
|
-
echo "Status: $status"
|
|
263
|
-
|
|
264
|
-
if [ "$status" = "finished" ]; then
|
|
265
|
-
echo "Payment completed!"
|
|
266
|
-
break
|
|
267
|
-
fi
|
|
268
|
-
|
|
269
|
-
sleep 30
|
|
270
|
-
done
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Payment Flow
|
|
274
|
-
|
|
275
|
-
1. **Create Estimate**: Check conversion rates and fees
|
|
276
|
-
```bash
|
|
277
|
-
nowpayments estimate convert --from USD --to BTC --amount 100
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
2. **Create Payment**: Generate payment address
|
|
281
|
-
```bash
|
|
282
|
-
nowpayments payment create --price 100 --currency USD --pay-currency BTC
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
3. **Customer Sends Crypto**: Customer sends exact amount to provided address
|
|
286
|
-
|
|
287
|
-
4. **Monitor Status**: Poll payment status or use IPN callbacks
|
|
288
|
-
```bash
|
|
289
|
-
nowpayments payment get <payment_id>
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
5. **Payment Confirmed**: Status changes to "finished"
|
|
293
|
-
|
|
294
|
-
## Payment Statuses
|
|
42
|
+
# Status
|
|
43
|
+
nowpaymentsio status get
|
|
295
44
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
- `sending` - Sending to your wallet
|
|
300
|
-
- `partially_paid` - Underpaid
|
|
301
|
-
- `finished` - Complete
|
|
302
|
-
- `failed` - Transaction failed
|
|
303
|
-
- `refunded` - Payment refunded
|
|
304
|
-
- `expired` - Payment window expired
|
|
45
|
+
# Currencies
|
|
46
|
+
nowpaymentsio currencies list
|
|
47
|
+
nowpaymentsio currencies estimate --amount 100 --from USD --to BTC
|
|
305
48
|
|
|
306
|
-
|
|
49
|
+
# Payments
|
|
50
|
+
nowpaymentsio payments list
|
|
51
|
+
nowpaymentsio payments get <payment-id>
|
|
52
|
+
nowpaymentsio payments create --amount 100 --from USD --to BTC
|
|
307
53
|
|
|
308
|
-
|
|
54
|
+
# Invoices
|
|
55
|
+
nowpaymentsio invoices list
|
|
56
|
+
nowpaymentsio invoices create --amount 50 --currency USD
|
|
309
57
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
```bash
|
|
314
|
-
# Check exit code
|
|
315
|
-
nowpayments payment get invalid_id
|
|
316
|
-
echo $? # Returns 1 on error
|
|
58
|
+
# Subscriptions
|
|
59
|
+
nowpaymentsio subscriptions plans
|
|
60
|
+
nowpaymentsio subscriptions list
|
|
317
61
|
```
|
|
318
62
|
|
|
319
|
-
## Configuration
|
|
320
|
-
|
|
321
|
-
Configuration is stored in `~/.nowpayments/config.json`:
|
|
322
|
-
|
|
323
|
-
```json
|
|
324
|
-
{
|
|
325
|
-
"apiKey": "your_api_key",
|
|
326
|
-
"sandbox": false,
|
|
327
|
-
"defaultCurrency": "USD",
|
|
328
|
-
"defaultPayCurrency": "BTC"
|
|
329
|
-
}
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
## API Documentation
|
|
333
|
-
|
|
334
|
-
For detailed API documentation, see:
|
|
335
|
-
- [NOWPayments API Docs](https://documenter.getpostman.com/view/7907941/S1a32n38)
|
|
336
|
-
- [OpenAPI Specification](./openapi.json)
|
|
337
|
-
|
|
338
|
-
## AI Agent Usage
|
|
339
|
-
|
|
340
|
-
See [AGENT.md](./AGENT.md) for patterns and examples for AI assistants using this CLI.
|
|
341
|
-
|
|
342
|
-
## OpenClaw Integration
|
|
343
|
-
|
|
344
|
-
See [OPENCLAW.md](./OPENCLAW.md) for integration with the OpenClaw agent framework.
|
|
345
|
-
|
|
346
|
-
## Examples
|
|
347
|
-
|
|
348
|
-
See [examples/](./examples/) directory for complete usage examples:
|
|
349
|
-
- Basic payment flow
|
|
350
|
-
- Invoice generation
|
|
351
|
-
- Payout automation
|
|
352
|
-
- Status monitoring
|
|
353
|
-
|
|
354
|
-
## Requirements
|
|
355
|
-
|
|
356
|
-
- Node.js >= 16.0.0
|
|
357
|
-
- NOWPayments API key
|
|
358
|
-
|
|
359
63
|
## License
|
|
360
64
|
|
|
361
|
-
MIT
|
|
362
|
-
|
|
363
|
-
## Support
|
|
364
|
-
|
|
365
|
-
- GitHub Issues: Report bugs and request features
|
|
366
|
-
- NOWPayments Support: https://nowpayments.io/help
|
|
367
|
-
- API Status: https://status.nowpayments.io
|
|
368
|
-
|
|
369
|
-
## Contributing
|
|
370
|
-
|
|
371
|
-
Contributions welcome! Please submit pull requests or open issues.
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
Built with Commander.js for the KTMCP project.
|
|
65
|
+
MIT — Part of [KTMCP CLI](https://killthemcp.com)
|
package/bin/nowpayments.js
CHANGED
|
@@ -1,89 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* A production-ready command-line interface for the NOWPayments cryptocurrency
|
|
7
|
-
* payment processing API.
|
|
8
|
-
*
|
|
9
|
-
* @see https://documenter.getpostman.com/view/7907941/S1a32n38
|
|
10
|
-
*/
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
11
5
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const fs = require('fs');
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
16
8
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const program = new Command();
|
|
21
|
-
|
|
22
|
-
// Import commands
|
|
23
|
-
const statusCommand = require('../src/commands/status');
|
|
24
|
-
const currenciesCommand = require('../src/commands/currencies');
|
|
25
|
-
const estimateCommand = require('../src/commands/estimate');
|
|
26
|
-
const paymentCommand = require('../src/commands/payment');
|
|
27
|
-
const invoiceCommand = require('../src/commands/invoice');
|
|
28
|
-
const payoutCommand = require('../src/commands/payout');
|
|
29
|
-
const authCommand = require('../src/commands/auth');
|
|
30
|
-
|
|
31
|
-
// CLI metadata
|
|
32
|
-
program
|
|
33
|
-
.name('nowpayments')
|
|
34
|
-
.description('NOWPayments API CLI - Cryptocurrency payment processing from the command line')
|
|
35
|
-
.version('1.0.0')
|
|
36
|
-
.option('-k, --api-key <key>', 'NOWPayments API key (or set NOWPAYMENTS_API_KEY env var)')
|
|
37
|
-
.option('--sandbox', 'Use sandbox environment (sandbox.nowpayments.io)')
|
|
38
|
-
.option('--json', 'Output raw JSON responses')
|
|
39
|
-
.option('--debug', 'Enable debug logging')
|
|
40
|
-
.hook('preAction', (thisCommand, actionCommand) => {
|
|
41
|
-
// Make global options available to all commands
|
|
42
|
-
const opts = thisCommand.opts();
|
|
43
|
-
program._apiKey = opts.apiKey || process.env.NOWPAYMENTS_API_KEY;
|
|
44
|
-
program._sandbox = opts.sandbox || false;
|
|
45
|
-
program._json = opts.json || false;
|
|
46
|
-
program._debug = opts.debug || false;
|
|
47
|
-
|
|
48
|
-
if (program._debug) {
|
|
49
|
-
console.log(chalk.gray(`[DEBUG] Command: ${actionCommand.name()}`));
|
|
50
|
-
console.log(chalk.gray(`[DEBUG] Sandbox: ${program._sandbox}`));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Register commands
|
|
55
|
-
program.addCommand(authCommand);
|
|
56
|
-
program.addCommand(statusCommand);
|
|
57
|
-
program.addCommand(currenciesCommand);
|
|
58
|
-
program.addCommand(estimateCommand);
|
|
59
|
-
program.addCommand(paymentCommand);
|
|
60
|
-
program.addCommand(invoiceCommand);
|
|
61
|
-
program.addCommand(payoutCommand);
|
|
62
|
-
|
|
63
|
-
// Display helpful message when no command is provided
|
|
64
|
-
program.on('--help', () => {
|
|
65
|
-
console.log('');
|
|
66
|
-
console.log('Examples:');
|
|
67
|
-
console.log(' $ nowpayments status');
|
|
68
|
-
console.log(' $ nowpayments currencies --available');
|
|
69
|
-
console.log(' $ nowpayments estimate --from USD --to BTC --amount 100');
|
|
70
|
-
console.log(' $ nowpayments payment create --price 99.99 --currency USD --pay-currency BTC');
|
|
71
|
-
console.log(' $ nowpayments payment get <payment_id>');
|
|
72
|
-
console.log('');
|
|
73
|
-
console.log('Authentication:');
|
|
74
|
-
console.log(' Set NOWPAYMENTS_API_KEY in .env file or use --api-key flag');
|
|
75
|
-
console.log(' $ nowpayments auth set YOUR_API_KEY');
|
|
76
|
-
console.log('');
|
|
77
|
-
console.log('Documentation:');
|
|
78
|
-
console.log(' README.md - General usage and examples');
|
|
79
|
-
console.log(' AGENT.md - AI agent integration patterns');
|
|
80
|
-
console.log(' OPENCLAW.md - OpenClaw integration guide');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Parse and execute
|
|
84
|
-
program.parse(process.argv);
|
|
85
|
-
|
|
86
|
-
// Show help if no command provided
|
|
87
|
-
if (!process.argv.slice(2).length) {
|
|
88
|
-
program.outputHelp();
|
|
89
|
-
}
|
|
9
|
+
// Import and run the main CLI
|
|
10
|
+
import(join(__dirname, '..', 'src', 'index.js'));
|
package/package.json
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktmcp-cli/nowpayments",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Production-ready CLI for NOWPayments cryptocurrency
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Production-ready CLI for NOWPayments API - cryptocurrency payments, invoices, subscriptions",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "src/index.js",
|
|
6
7
|
"bin": {
|
|
7
|
-
"nowpayments": "
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"start": "node bin/nowpayments.js",
|
|
11
|
-
"test": "node --test",
|
|
12
|
-
"lint": "eslint ."
|
|
8
|
+
"nowpayments": "bin/nowpayments.js"
|
|
13
9
|
},
|
|
14
10
|
"keywords": [
|
|
15
11
|
"nowpayments",
|
|
16
12
|
"cryptocurrency",
|
|
17
|
-
"payment",
|
|
18
|
-
"cli",
|
|
19
13
|
"crypto",
|
|
14
|
+
"payments",
|
|
20
15
|
"bitcoin",
|
|
21
16
|
"ethereum",
|
|
22
|
-
"
|
|
17
|
+
"cli",
|
|
18
|
+
"api",
|
|
19
|
+
"ktmcp"
|
|
23
20
|
],
|
|
24
21
|
"author": "KTMCP",
|
|
25
22
|
"license": "MIT",
|
|
26
|
-
"engines": {
|
|
27
|
-
"node": ">=16.0.0"
|
|
28
|
-
},
|
|
29
23
|
"dependencies": {
|
|
30
24
|
"commander": "^12.0.0",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
25
|
+
"axios": "^1.6.7",
|
|
26
|
+
"chalk": "^5.3.0",
|
|
27
|
+
"ora": "^8.0.1",
|
|
28
|
+
"conf": "^12.0.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.0.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/ktmcp-cli/nowpayments.git"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
37
|
+
"homepage": "https://killthemcp.com/nowpayments-cli",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/ktmcp-cli/nowpayments/issues"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/src/api.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getConfig } from './config.js';
|
|
3
|
+
|
|
4
|
+
const NOWPAYMENTS_BASE_URL = 'https://api.nowpayments.io/v1';
|
|
5
|
+
|
|
6
|
+
async function apiRequest(method, endpoint, data = null, params = null) {
|
|
7
|
+
const apiKey = getConfig('apiKey');
|
|
8
|
+
|
|
9
|
+
if (!apiKey) {
|
|
10
|
+
throw new Error('API key not configured. Run: nowpaymentsio config set --api-key <key>');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const config = {
|
|
14
|
+
method,
|
|
15
|
+
url: `${NOWPAYMENTS_BASE_URL}${endpoint}`,
|
|
16
|
+
headers: {
|
|
17
|
+
'x-api-key': apiKey,
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
if (params) config.params = params;
|
|
23
|
+
if (data) config.data = data;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const response = await axios(config);
|
|
27
|
+
return response.data;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error.response) {
|
|
30
|
+
const status = error.response.status;
|
|
31
|
+
const data = error.response.data;
|
|
32
|
+
if (status === 401) {
|
|
33
|
+
throw new Error('Authentication failed. Check your API key.');
|
|
34
|
+
} else if (status === 404) {
|
|
35
|
+
throw new Error('Resource not found.');
|
|
36
|
+
} else if (status === 429) {
|
|
37
|
+
throw new Error('Rate limit exceeded.');
|
|
38
|
+
} else {
|
|
39
|
+
const message = data?.message || JSON.stringify(data);
|
|
40
|
+
throw new Error(`API Error (${status}): ${message}`);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getStatus() {
|
|
49
|
+
return await apiRequest('GET', '/status');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getCurrencies() {
|
|
53
|
+
return await apiRequest('GET', '/currencies');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function getEstimate(params) {
|
|
57
|
+
return await apiRequest('GET', '/estimate', null, params);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function getMinAmount(params) {
|
|
61
|
+
return await apiRequest('GET', '/min-amount', null, params);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function listPayments(params = {}) {
|
|
65
|
+
return await apiRequest('GET', '/payment/', null, params);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getPayment(paymentId) {
|
|
69
|
+
return await apiRequest('GET', `/payment/${paymentId}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function createPayment(data) {
|
|
73
|
+
return await apiRequest('POST', '/payment', data);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function createInvoice(data) {
|
|
77
|
+
return await apiRequest('POST', '/invoice', data);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function listInvoices(params = {}) {
|
|
81
|
+
return await apiRequest('GET', '/invoice', null, params);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function listPlans(params = {}) {
|
|
85
|
+
return await apiRequest('GET', '/subscriptions/plans', null, params);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function getPlan(planId) {
|
|
89
|
+
return await apiRequest('GET', `/subscriptions/plans/${planId}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function listSubscriptions(params = {}) {
|
|
93
|
+
return await apiRequest('GET', '/subscriptions', null, params);
|
|
94
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
|
|
3
|
+
const config = new Conf({
|
|
4
|
+
projectName: 'nowpaymentsio-cli',
|
|
5
|
+
schema: {
|
|
6
|
+
apiKey: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
default: ''
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export function getConfig(key) {
|
|
14
|
+
return config.get(key);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function setConfig(key, value) {
|
|
18
|
+
config.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getAllConfig() {
|
|
22
|
+
return config.store;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function clearConfig() {
|
|
26
|
+
config.clear();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function isConfigured() {
|
|
30
|
+
const apiKey = config.get('apiKey');
|
|
31
|
+
return !!apiKey;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default config;
|