@ktmcp-cli/nowpayments 1.0.1 → 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/README.md CHANGED
@@ -1,374 +1,65 @@
1
- ![Banner](https://raw.githubusercontent.com/ktmcp-cli/nowpayments/main/banner.svg)
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/)
2
5
 
3
6
  # NOWPayments CLI
4
7
 
5
- A production-ready command-line interface for the [NOWPayments](https://nowpayments.io) cryptocurrency payment processing API. Built with Commander.js for robust API integration and automation.
6
-
7
- > **⚠️ Unofficial CLI** - This tool is not officially sponsored, endorsed, or maintained by NOWPayments. It is an independent project built on the public NOWPayments API. Official site: https://nowpayments.io | API docs: https://documenter.getpostman.com/view/7907941/S1a32n38
8
-
9
- ## Why CLI > MCP
10
-
11
- While Model Context Protocol (MCP) servers provide AI integration, a dedicated CLI offers superior advantages:
12
-
13
- ### 1. Universal Tool Integration
14
- - Works with **any** AI assistant (Claude, ChatGPT, local models)
15
- - No MCP server dependency or compatibility issues
16
- - Standard stdin/stdout interface that all tools understand
17
-
18
- ### 2. Human-First Design
19
- - Direct terminal usage for developers and operators
20
- - Rich formatted output with colors and tables
21
- - Interactive workflows when needed
22
- - Scriptable for automation
23
-
24
- ### 3. Reliability & Performance
25
- - No additional server process to manage
26
- - Direct API calls with minimal overhead
27
- - Proper error handling and exit codes
28
- - No WebSocket/transport layer complexity
29
-
30
- ### 4. Development Velocity
31
- - Easier to test (just run commands)
32
- - Simpler debugging (standard logs)
33
- - Faster iteration (no server restarts)
34
- - Better CI/CD integration
35
-
36
- ### 5. Production Ready
37
- - Works in Docker containers
38
- - Cron job compatible
39
- - Shell script integration
40
- - No daemon management
41
-
42
- **Bottom Line:** CLIs are battle-tested, universal interfaces. MCP adds complexity for integration scenarios where a simple CLI + agent pattern works better.
8
+ Production-ready CLI for [NOWPayments](https://nowpayments.io) API. Accept cryptocurrency payments, manage invoices, and handle subscriptions from your terminal.
43
9
 
44
10
  ## Features
45
11
 
46
- - Full NOWPayments API coverage
47
- - Rich terminal output with colors and formatting
48
- - JSON output mode for scripting
49
- - Persistent API key management
50
- - Sandbox environment support
51
- - Comprehensive error handling
52
- - Production-ready reliability
53
-
54
- ## Installation
55
-
56
- ```bash
57
- npm install -g @ktmcp-cli/nowpayments
58
- ```
59
-
60
- Or install locally:
61
-
62
- ```bash
63
- cd ktmcp-nowpayments-cli
64
- npm install
65
- npm link
66
- ```
67
-
68
- ## Quick Start
69
-
70
- ### 1. Get Your API Key
71
-
72
- Sign up at [NOWPayments.io](https://nowpayments.io) and generate an API key.
73
-
74
- ### 2. Configure Authentication
75
-
76
- ```bash
77
- # Save API key to config (recommended)
78
- nowpayments auth set YOUR_API_KEY
79
-
80
- # Or use environment variable
81
- export NOWPAYMENTS_API_KEY=your_api_key
82
-
83
- # Or pass with each command
84
- nowpayments --api-key YOUR_API_KEY status
85
- ```
86
-
87
- ### 3. Verify Connection
88
-
89
- ```bash
90
- nowpayments status
91
- ```
92
-
93
- ## Usage
94
-
95
- ### Authentication Management
96
-
97
- ```bash
98
- # Set API key
99
- nowpayments auth set YOUR_API_KEY
100
-
101
- # Show current key (masked)
102
- nowpayments auth show
103
-
104
- # Clear API key
105
- nowpayments auth clear
106
- ```
107
-
108
- ### Check API Status
109
-
110
- ```bash
111
- nowpayments status
112
- ```
113
-
114
- ### Currency Operations
115
-
116
- ```bash
117
- # List all available cryptocurrencies
118
- nowpayments currencies list
119
-
120
- # Show only available payment currencies
121
- nowpayments currencies list --available
122
-
123
- # Get currency information
124
- nowpayments currencies info BTC
125
- ```
126
-
127
- ### Price Estimates
128
-
129
- ```bash
130
- # Estimate cryptocurrency amount for fiat price
131
- nowpayments estimate convert --from USD --to BTC --amount 100
132
-
133
- # Get minimum payment amount
134
- nowpayments estimate min --from USD --to BTC
135
- ```
136
-
137
- ### Payment Management
138
-
139
- ```bash
140
- # Create a new payment
141
- nowpayments payment create \
142
- --price 99.99 \
143
- --currency USD \
144
- --pay-currency BTC \
145
- --order-id "ORDER-123" \
146
- --order-description "Premium subscription"
147
-
148
- # Get payment details
149
- nowpayments payment get <payment_id>
150
-
151
- # List all payments
152
- nowpayments payment list --limit 20
153
-
154
- # Filter payments by date
155
- nowpayments payment list \
156
- --date-from 2024-01-01 \
157
- --date-to 2024-12-31
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`
158
17
 
159
- # Update payment estimate (before expiration)
160
- nowpayments payment update-estimate <payment_id>
161
- ```
162
-
163
- ### Invoice Management
164
-
165
- ```bash
166
- # Create an invoice
167
- nowpayments invoice create \
168
- --price 49.99 \
169
- --currency USD \
170
- --order-id "INV-456" \
171
- --success-url "https://example.com/success" \
172
- --cancel-url "https://example.com/cancel"
173
-
174
- # Get invoice details
175
- nowpayments invoice get <invoice_id>
176
-
177
- # List invoices
178
- nowpayments invoice list --limit 10
179
- ```
180
-
181
- ### Payout Operations
182
-
183
- ```bash
184
- # Create a payout
185
- nowpayments payout create \
186
- --amount 0.01 \
187
- --currency BTC \
188
- --address "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
189
-
190
- # Verify payout with 2FA
191
- nowpayments payout verify <payout_id> <verification_code>
192
-
193
- # Get payout details
194
- nowpayments payout get <payout_id>
18
+ ## Why CLI > MCP
195
19
 
196
- # List payouts
197
- nowpayments payout list
198
- ```
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
199
24
 
200
- ### Global Options
25
+ ## Installation
201
26
 
202
27
  ```bash
203
- # Use sandbox environment
204
- nowpayments --sandbox status
205
-
206
- # Output raw JSON (for scripting)
207
- nowpayments --json payment list
208
-
209
- # Enable debug logging
210
- nowpayments --debug payment create --price 100 --currency USD --pay-currency BTC
211
-
212
- # Combine options
213
- nowpayments --sandbox --json currencies list
28
+ npm install -g @ktmcp-cli/nowpaymentsio
214
29
  ```
215
30
 
216
- ## Advanced Usage
31
+ ## Setup
217
32
 
218
- ### Scripting with JSON Output
33
+ Get API key from [NOWPayments Dashboard](https://nowpayments.io).
219
34
 
220
35
  ```bash
221
- # Get payment status in JSON
222
- payment_data=$(nowpayments --json payment get abc123)
223
- status=$(echo "$payment_data" | jq -r '.payment_status')
224
-
225
- if [ "$status" = "finished" ]; then
226
- echo "Payment completed!"
227
- fi
36
+ nowpaymentsio config set --api-key YOUR_API_KEY
228
37
  ```
229
38
 
230
- ### Environment Variables
39
+ ## Commands
231
40
 
232
41
  ```bash
233
- # Set in .env file
234
- NOWPAYMENTS_API_KEY=your_api_key
235
-
236
- # Load automatically
237
- nowpayments status
238
- ```
239
-
240
- ### Automation Example
241
-
242
- ```bash
243
- #!/bin/bash
244
- # Create payment and monitor status
245
-
246
- # Create payment
247
- payment=$(nowpayments --json payment create \
248
- --price 100 \
249
- --currency USD \
250
- --pay-currency BTC)
251
-
252
- payment_id=$(echo "$payment" | jq -r '.payment_id')
253
- pay_address=$(echo "$payment" | jq -r '.pay_address')
254
-
255
- echo "Payment created: $payment_id"
256
- echo "Send to: $pay_address"
257
-
258
- # Monitor status
259
- while true; do
260
- status=$(nowpayments --json payment get "$payment_id" | jq -r '.payment_status')
261
- echo "Status: $status"
262
-
263
- if [ "$status" = "finished" ]; then
264
- echo "Payment completed!"
265
- break
266
- fi
267
-
268
- sleep 30
269
- done
270
- ```
271
-
272
- ## Payment Flow
273
-
274
- 1. **Create Estimate**: Check conversion rates and fees
275
- ```bash
276
- nowpayments estimate convert --from USD --to BTC --amount 100
277
- ```
278
-
279
- 2. **Create Payment**: Generate payment address
280
- ```bash
281
- nowpayments payment create --price 100 --currency USD --pay-currency BTC
282
- ```
283
-
284
- 3. **Customer Sends Crypto**: Customer sends exact amount to provided address
285
-
286
- 4. **Monitor Status**: Poll payment status or use IPN callbacks
287
- ```bash
288
- nowpayments payment get <payment_id>
289
- ```
290
-
291
- 5. **Payment Confirmed**: Status changes to "finished"
292
-
293
- ## Payment Statuses
42
+ # Status
43
+ nowpaymentsio status get
294
44
 
295
- - `waiting` - Waiting for customer payment
296
- - `confirming` - Payment received, confirming on blockchain
297
- - `confirmed` - Payment confirmed
298
- - `sending` - Sending to your wallet
299
- - `partially_paid` - Underpaid
300
- - `finished` - Complete
301
- - `failed` - Transaction failed
302
- - `refunded` - Payment refunded
303
- - `expired` - Payment window expired
45
+ # Currencies
46
+ nowpaymentsio currencies list
47
+ nowpaymentsio currencies estimate --amount 100 --from USD --to BTC
304
48
 
305
- ## Error Handling
49
+ # Payments
50
+ nowpaymentsio payments list
51
+ nowpaymentsio payments get <payment-id>
52
+ nowpaymentsio payments create --amount 100 --from USD --to BTC
306
53
 
307
- The CLI provides detailed error messages and proper exit codes:
54
+ # Invoices
55
+ nowpaymentsio invoices list
56
+ nowpaymentsio invoices create --amount 50 --currency USD
308
57
 
309
- - Exit code 0: Success
310
- - Exit code 1: Error (API error, validation error, etc.)
311
-
312
- ```bash
313
- # Check exit code
314
- nowpayments payment get invalid_id
315
- echo $? # Returns 1 on error
58
+ # Subscriptions
59
+ nowpaymentsio subscriptions plans
60
+ nowpaymentsio subscriptions list
316
61
  ```
317
62
 
318
- ## Configuration
319
-
320
- Configuration is stored in `~/.nowpayments/config.json`:
321
-
322
- ```json
323
- {
324
- "apiKey": "your_api_key",
325
- "sandbox": false,
326
- "defaultCurrency": "USD",
327
- "defaultPayCurrency": "BTC"
328
- }
329
- ```
330
-
331
- ## API Documentation
332
-
333
- For detailed API documentation, see:
334
- - [NOWPayments API Docs](https://documenter.getpostman.com/view/7907941/S1a32n38)
335
- - [OpenAPI Specification](./openapi.json)
336
-
337
- ## AI Agent Usage
338
-
339
- See [AGENT.md](./AGENT.md) for patterns and examples for AI assistants using this CLI.
340
-
341
- ## OpenClaw Integration
342
-
343
- See [OPENCLAW.md](./OPENCLAW.md) for integration with the OpenClaw agent framework.
344
-
345
- ## Examples
346
-
347
- See [examples/](./examples/) directory for complete usage examples:
348
- - Basic payment flow
349
- - Invoice generation
350
- - Payout automation
351
- - Status monitoring
352
-
353
- ## Requirements
354
-
355
- - Node.js >= 16.0.0
356
- - NOWPayments API key
357
-
358
63
  ## License
359
64
 
360
- MIT
361
-
362
- ## Support
363
-
364
- - GitHub Issues: Report bugs and request features
365
- - NOWPayments Support: https://nowpayments.io/help
366
- - API Status: https://status.nowpayments.io
367
-
368
- ## Contributing
369
-
370
- Contributions welcome! Please submit pull requests or open issues.
371
-
372
- ---
373
-
374
- Built with Commander.js for the KTMCP project.
65
+ MIT — Part of [KTMCP CLI](https://killthemcp.com)
@@ -1,92 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { showWelcomeMessage } = require('../src/lib/welcome');
4
- showWelcomeMessage('nowpayments');
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
5
 
6
- /**
7
- * NOWPayments CLI Entry Point
8
- *
9
- * A production-ready command-line interface for the NOWPayments cryptocurrency
10
- * payment processing API.
11
- *
12
- * @see https://documenter.getpostman.com/view/7907941/S1a32n38
13
- */
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
14
8
 
15
- const { Command } = require('commander');
16
- const chalk = require('chalk');
17
- const path = require('path');
18
- const fs = require('fs');
19
-
20
- // Load environment variables
21
- require('dotenv').config();
22
-
23
- const program = new Command();
24
-
25
- // Import commands
26
- const statusCommand = require('../src/commands/status');
27
- const currenciesCommand = require('../src/commands/currencies');
28
- const estimateCommand = require('../src/commands/estimate');
29
- const paymentCommand = require('../src/commands/payment');
30
- const invoiceCommand = require('../src/commands/invoice');
31
- const payoutCommand = require('../src/commands/payout');
32
- const authCommand = require('../src/commands/auth');
33
-
34
- // CLI metadata
35
- program
36
- .name('nowpayments')
37
- .description('NOWPayments API CLI - Cryptocurrency payment processing from the command line')
38
- .version('1.0.0')
39
- .option('-k, --api-key <key>', 'NOWPayments API key (or set NOWPAYMENTS_API_KEY env var)')
40
- .option('--sandbox', 'Use sandbox environment (sandbox.nowpayments.io)')
41
- .option('--json', 'Output raw JSON responses')
42
- .option('--debug', 'Enable debug logging')
43
- .hook('preAction', (thisCommand, actionCommand) => {
44
- // Make global options available to all commands
45
- const opts = thisCommand.opts();
46
- program._apiKey = opts.apiKey || process.env.NOWPAYMENTS_API_KEY;
47
- program._sandbox = opts.sandbox || false;
48
- program._json = opts.json || false;
49
- program._debug = opts.debug || false;
50
-
51
- if (program._debug) {
52
- console.log(chalk.gray(`[DEBUG] Command: ${actionCommand.name()}`));
53
- console.log(chalk.gray(`[DEBUG] Sandbox: ${program._sandbox}`));
54
- }
55
- });
56
-
57
- // Register commands
58
- program.addCommand(authCommand);
59
- program.addCommand(statusCommand);
60
- program.addCommand(currenciesCommand);
61
- program.addCommand(estimateCommand);
62
- program.addCommand(paymentCommand);
63
- program.addCommand(invoiceCommand);
64
- program.addCommand(payoutCommand);
65
-
66
- // Display helpful message when no command is provided
67
- program.on('--help', () => {
68
- console.log('');
69
- console.log('Examples:');
70
- console.log(' $ nowpayments status');
71
- console.log(' $ nowpayments currencies --available');
72
- console.log(' $ nowpayments estimate --from USD --to BTC --amount 100');
73
- console.log(' $ nowpayments payment create --price 99.99 --currency USD --pay-currency BTC');
74
- console.log(' $ nowpayments payment get <payment_id>');
75
- console.log('');
76
- console.log('Authentication:');
77
- console.log(' Set NOWPAYMENTS_API_KEY in .env file or use --api-key flag');
78
- console.log(' $ nowpayments auth set YOUR_API_KEY');
79
- console.log('');
80
- console.log('Documentation:');
81
- console.log(' README.md - General usage and examples');
82
- console.log(' AGENT.md - AI agent integration patterns');
83
- console.log(' OPENCLAW.md - OpenClaw integration guide');
84
- });
85
-
86
- // Parse and execute
87
- program.parse(process.argv);
88
-
89
- // Show help if no command provided
90
- if (!process.argv.slice(2).length) {
91
- program.outputHelp();
92
- }
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.1",
4
- "description": "Production-ready CLI for NOWPayments cryptocurrency payment processing API",
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": "./bin/nowpayments.js"
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
- "commander"
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
- "chalk": "^4.1.2",
32
- "ora": "^5.4.1",
33
- "dotenv": "^16.4.1",
34
- "node-fetch": "^2.7.0",
35
- "cli-table3": "^0.6.3"
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
- "devDependencies": {
38
- "eslint": "^8.56.0"
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;