nansen-cli 1.0.1 → 1.0.3
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 +9 -4
- package/package.json +1 -1
- package/src/index.js +21 -4
package/README.md
CHANGED
|
@@ -125,13 +125,15 @@ Deep analytics for any token.
|
|
|
125
125
|
| Option | Description |
|
|
126
126
|
|--------|-------------|
|
|
127
127
|
| `--pretty` | Format JSON output for readability |
|
|
128
|
+
| `--table` | Format output as human-readable table |
|
|
128
129
|
| `--chain <chain>` | Blockchain to query |
|
|
129
130
|
| `--chains <json>` | Multiple chains as JSON array |
|
|
130
131
|
| `--limit <n>` | Number of results |
|
|
131
132
|
| `--days <n>` | Date range in days (default: 30) |
|
|
133
|
+
| `--sort <field:dir>` | Sort results (e.g., `--sort value_usd:desc`) |
|
|
132
134
|
| `--symbol <sym>` | Token symbol for perp endpoints (e.g., BTC, ETH) |
|
|
133
135
|
| `--filters <json>` | Filter criteria as JSON |
|
|
134
|
-
| `--order-by <json>` | Sort order as JSON array |
|
|
136
|
+
| `--order-by <json>` | Sort order as JSON array (advanced) |
|
|
135
137
|
| `--labels <label>` | Smart Money label filter |
|
|
136
138
|
| `--smart-money` | Filter for Smart Money only |
|
|
137
139
|
| `--timeframe <tf>` | Time window (5m, 10m, 1h, 6h, 24h, 7d, 30d) |
|
|
@@ -171,8 +173,11 @@ The CLI is designed for AI agents and automation:
|
|
|
171
173
|
## Examples
|
|
172
174
|
|
|
173
175
|
```bash
|
|
176
|
+
# Get trending tokens as a table, sorted by volume
|
|
177
|
+
nansen token screener --chain solana --sort buy_volume:desc --table
|
|
178
|
+
|
|
174
179
|
# Get Smart Money DEX trades from Funds only
|
|
175
|
-
nansen smart-money dex-trades --chain ethereum --labels Fund
|
|
180
|
+
nansen smart-money dex-trades --chain ethereum --labels Fund --table
|
|
176
181
|
|
|
177
182
|
# Get token holders with Smart Money filter
|
|
178
183
|
nansen token holders --token So11111111111111111111111111111111111111112 --chain solana --smart-money
|
|
@@ -183,8 +188,8 @@ nansen smart-money historical-holdings --chain solana --days 7
|
|
|
183
188
|
# Get BTC perpetual positions on Hyperliquid
|
|
184
189
|
nansen token perp-positions --symbol BTC --pretty
|
|
185
190
|
|
|
186
|
-
# Get top PnL traders for a token
|
|
187
|
-
nansen token pnl --token JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN --chain solana --days 30
|
|
191
|
+
# Get top PnL traders for a token, sorted by realized PnL
|
|
192
|
+
nansen token pnl --token JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN --chain solana --days 30 --sort pnl_usd:desc --table
|
|
188
193
|
```
|
|
189
194
|
|
|
190
195
|
## Development
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -156,6 +156,22 @@ function errorOutput(error, pretty = false, table = false) {
|
|
|
156
156
|
process.exit(1);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// Parse simple sort syntax: "field:direction" or "field" (defaults to DESC)
|
|
160
|
+
function parseSort(sortOption, orderByOption) {
|
|
161
|
+
// If --order-by is provided, use it (full JSON control)
|
|
162
|
+
if (orderByOption) return orderByOption;
|
|
163
|
+
|
|
164
|
+
// If no --sort, return undefined
|
|
165
|
+
if (!sortOption) return undefined;
|
|
166
|
+
|
|
167
|
+
// Parse --sort field:direction or --sort field
|
|
168
|
+
const parts = sortOption.split(':');
|
|
169
|
+
const field = parts[0];
|
|
170
|
+
const direction = (parts[1] || 'desc').toUpperCase();
|
|
171
|
+
|
|
172
|
+
return [{ field, direction }];
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
// Help text
|
|
160
176
|
const HELP = `
|
|
161
177
|
Nansen CLI - Command-line interface for Nansen API
|
|
@@ -180,7 +196,8 @@ GLOBAL OPTIONS:
|
|
|
180
196
|
--chains Multiple chains as JSON array
|
|
181
197
|
--limit Number of results (shorthand for pagination)
|
|
182
198
|
--filters JSON object with filters
|
|
183
|
-
--
|
|
199
|
+
--sort Sort by field (e.g., --sort value_usd:desc)
|
|
200
|
+
--order-by JSON array with sort order (advanced)
|
|
184
201
|
--days Date range in days (default: 30 for most endpoints)
|
|
185
202
|
--symbol Token symbol (for perp endpoints)
|
|
186
203
|
|
|
@@ -316,7 +333,7 @@ const commands = {
|
|
|
316
333
|
const chain = options.chain || 'solana';
|
|
317
334
|
const chains = options.chains || [chain];
|
|
318
335
|
const filters = options.filters || {};
|
|
319
|
-
const orderBy = options['order-by'];
|
|
336
|
+
const orderBy = parseSort(options.sort, options['order-by']);
|
|
320
337
|
const pagination = options.limit ? { page: 1, per_page: options.limit } : undefined;
|
|
321
338
|
|
|
322
339
|
// Add smart money label filter if specified
|
|
@@ -355,7 +372,7 @@ const commands = {
|
|
|
355
372
|
const entityName = options.entity || options['entity-name'];
|
|
356
373
|
const chain = options.chain || 'ethereum';
|
|
357
374
|
const filters = options.filters || {};
|
|
358
|
-
const orderBy = options['order-by'];
|
|
375
|
+
const orderBy = parseSort(options.sort, options['order-by']);
|
|
359
376
|
const pagination = options.limit ? { page: 1, recordsPerPage: options.limit } : undefined;
|
|
360
377
|
const days = options.days ? parseInt(options.days) : 30;
|
|
361
378
|
|
|
@@ -393,7 +410,7 @@ const commands = {
|
|
|
393
410
|
const chains = options.chains || [chain];
|
|
394
411
|
const timeframe = options.timeframe || '24h';
|
|
395
412
|
const filters = options.filters || {};
|
|
396
|
-
const orderBy = options['order-by'];
|
|
413
|
+
const orderBy = parseSort(options.sort, options['order-by']);
|
|
397
414
|
const pagination = options.limit ? { page: 1, per_page: options.limit } : undefined;
|
|
398
415
|
const days = options.days ? parseInt(options.days) : 30;
|
|
399
416
|
|