nansen-cli 1.9.3 → 1.10.1
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/CHANGELOG.md +42 -0
- package/README.md +41 -281
- package/package.json +8 -2
- package/src/api.js +13 -12
- package/src/cli.js +161 -375
- package/src/schema.json +1516 -0
- package/src/trading.js +16 -25
- package/src/transfer.js +10 -14
- package/src/wallet.js +2 -2
- package/src/walletconnect-exec.js +1 -1
- package/src/x402-svm.js +3 -3
- package/src/x402.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#133](https://github.com/nansen-ai/nansen-cli/pull/133) [`4cbeb65`](https://github.com/nansen-ai/nansen-cli/commit/4cbeb6510c286660f611117d2d8b0508f2340e31) Thanks [@0xlaveen](https://github.com/0xlaveen)! - fix: correct profiler pagination parameter from `recordsPerPage` to `per_page`; remove unsupported pagination from pnl-summary; add --limit to labels, historical-balances, counterparties schema
|
|
8
|
+
|
|
9
|
+
- [#164](https://github.com/nansen-ai/nansen-cli/pull/164) [`ec6ab78`](https://github.com/nansen-ai/nansen-cli/commit/ec6ab78d604a177c3459833091531de3fc07add1) Thanks [@DMagowan](https://github.com/DMagowan)! - fix: correct `--date` option marked as `required: true` when it is optional
|
|
10
|
+
|
|
11
|
+
The schema incorrectly marked `--date` as `required: true` for three commands:
|
|
12
|
+
|
|
13
|
+
- `research token flows`
|
|
14
|
+
- `research token who-bought-sold`
|
|
15
|
+
- `research profiler transactions`
|
|
16
|
+
|
|
17
|
+
All three use `parseDateOption` with a `days` fallback, so `--date` is optional — omitting it defaults to a rolling window based on `--days`. An agent following the schema strictly would unnecessarily refuse to run these commands without a date.
|
|
18
|
+
|
|
19
|
+
- [#162](https://github.com/nansen-ai/nansen-cli/pull/162) [`4dbe181`](https://github.com/nansen-ai/nansen-cli/commit/4dbe181d3b4973881bcb7fb445cf6559819006b6) Thanks [@DMagowan](https://github.com/DMagowan)! - fix: surface wallet prerequisite in `trade quote` help text and schema
|
|
20
|
+
|
|
21
|
+
`nansen trade quote` requires a configured wallet (the trading API builds a transaction specific to the sender address), but this was not communicated until the command failed. Adds a PREREQUISITE section to the usage text and a `prerequisites` field to the schema so agents can discover this requirement before running the command.
|
|
22
|
+
|
|
23
|
+
- [#165](https://github.com/nansen-ai/nansen-cli/pull/165) [`92f37ea`](https://github.com/nansen-ai/nansen-cli/commit/92f37eaa8655ae1a39b9200aafaf4771a0859229) Thanks [@0xlaveen](https://github.com/0xlaveen)! - Fix trading docs and config to reflect actual supported chains (Base and Solana only)
|
|
24
|
+
|
|
25
|
+
## 1.10.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#125](https://github.com/nansen-ai/nansen-cli/pull/125) [`5a5a80a`](https://github.com/nansen-ai/nansen-cli/commit/5a5a80af9c2c5b93efcc707925b004f077e13c36) Thanks [@0xlaveen](https://github.com/0xlaveen)! - Add modular skills/ directory with 7 agent-optimised SKILL.md files (nansen-token, nansen-smart-money, nansen-profiler, nansen-trade, nansen-wallet, nansen-perp, nansen-search) following the linear-cli pattern. Each skill has scoped frontmatter, agent routing descriptions, bash examples, and exit codes. Add skills nudge to `nansen --help` output.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#122](https://github.com/nansen-ai/nansen-cli/pull/122) [`9a1ada8`](https://github.com/nansen-ai/nansen-cli/commit/9a1ada8543cd6fdbcc10d2d5004fe2e2e1a88928) Thanks [@TimNooren](https://github.com/TimNooren)! - `nansen research <unknown>` and `nansen trade <unknown>` now exit with code 1 and return `{"success":false,...}` instead of silently exiting 0.
|
|
34
|
+
|
|
35
|
+
- [#138](https://github.com/nansen-ai/nansen-cli/pull/138) [`c61881f`](https://github.com/nansen-ai/nansen-cli/commit/c61881f5455b9fff7fb97841652a72af58ab8e0b) Thanks [@TimNooren](https://github.com/TimNooren)! - Fix `nansen login --help` to show usage instead of erroring. Previously, `--help` was silently ignored on TTY (showing the interactive prompt) and caused an error on non-TTY. Also fixes the post-login suggested command to use the non-deprecated `nansen research token screener` path.
|
|
36
|
+
|
|
37
|
+
- [#129](https://github.com/nansen-ai/nansen-cli/pull/129) [`eeabf89`](https://github.com/nansen-ai/nansen-cli/commit/eeabf8988dafc7fb1964fd2eef629f03c6a4420a) Thanks [@araa47](https://github.com/araa47)! - Fix `token ohlcv` sending unsupported pagination/limit params that caused 422 errors
|
|
38
|
+
|
|
39
|
+
- [#139](https://github.com/nansen-ai/nansen-cli/pull/139) [`e86dc68`](https://github.com/nansen-ai/nansen-cli/commit/e86dc6869f524d3dc59da4c7c04cb1ace1b7246b) Thanks [@TimNooren](https://github.com/TimNooren)! - Fix API key prompt masking: each keystroke was showing the real character followed by `*` (e.g. `f*o*o*`) because the readline interface was active alongside raw mode, causing double output. Moving readline creation into the non-hidden branch eliminates the double-echo and also fixes backspace incorrectly clearing the prompt label.
|
|
40
|
+
|
|
41
|
+
- [#129](https://github.com/nansen-ai/nansen-cli/pull/129) [`eeabf89`](https://github.com/nansen-ai/nansen-cli/commit/eeabf8988dafc7fb1964fd2eef629f03c6a4420a) Thanks [@araa47](https://github.com/araa47)! - Fix `trade quote` crash when no wallet exists — now shows actionable error instead of uncaught exception
|
|
42
|
+
|
|
43
|
+
- [#126](https://github.com/nansen-ai/nansen-cli/pull/126) [`f3b87e7`](https://github.com/nansen-ai/nansen-cli/commit/f3b87e7491d03d052d5d72fcc991de0c33caf51f) Thanks [@araa47](https://github.com/araa47)! - Remove root SKILL.md so `npx skills add nansen-ai/nansen-cli` correctly discovers all 7 skills in `skills/` instead of treating the repo as a single skill.
|
|
44
|
+
|
|
3
45
|
## 1.9.3
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,226 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/nansen-cli)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/nansen-ai/nansen-cli/actions/workflows/ci.yml)
|
|
6
5
|
|
|
7
|
-
> **Built by agents, for agents.**
|
|
8
|
-
|
|
9
|
-
Command-line interface for the [Nansen API](https://docs.nansen.ai) with structured JSON output, designed for AI agents and automation.
|
|
6
|
+
> **Built by agents, for agents.** Command-line interface for the [Nansen API](https://docs.nansen.ai) with structured JSON output.
|
|
10
7
|
|
|
11
8
|
## Installation
|
|
12
9
|
|
|
13
10
|
```bash
|
|
14
|
-
# Install globally via npm
|
|
15
11
|
npm install -g nansen-cli
|
|
16
|
-
|
|
17
|
-
# Or run directly with npx
|
|
18
|
-
npx nansen-cli help
|
|
19
|
-
|
|
20
|
-
# Or clone and install locally
|
|
21
|
-
git clone https://github.com/nansen-ai/nansen-cli.git
|
|
22
|
-
cd nansen-cli
|
|
23
|
-
npm install
|
|
24
|
-
npm link
|
|
12
|
+
npx skills add nansen-ai/nansen-cli # load agent skill files
|
|
25
13
|
```
|
|
26
14
|
|
|
27
|
-
##
|
|
28
|
-
|
|
29
|
-
### For AI Agents (Recommended)
|
|
30
|
-
|
|
31
|
-
Use the [AI Agent Setup](https://app.nansen.ai/auth/agent-setup) flow:
|
|
32
|
-
|
|
33
|
-
1. Your agent will ask you to visit: **[app.nansen.ai/auth/agent-setup](https://app.nansen.ai/auth/agent-setup)**
|
|
34
|
-
2. Sign in with your Nansen account
|
|
35
|
-
3. Copy the message shown
|
|
36
|
-
4. Paste it back to your agent
|
|
37
|
-
|
|
38
|
-
Your agent saves the key and handles everything else automatically.
|
|
39
|
-
|
|
40
|
-
### Manual Setup
|
|
41
|
-
|
|
42
|
-
**Option 1: Interactive login**
|
|
43
|
-
```bash
|
|
44
|
-
nansen login
|
|
45
|
-
# Enter your API key when prompted
|
|
46
|
-
# ✓ Saved to ~/.nansen/config.json
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**Option 2: Environment variable (best for agents)**
|
|
50
|
-
```bash
|
|
51
|
-
export NANSEN_API_KEY=your-api-key
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**Option 3: Direct config file**
|
|
55
|
-
```bash
|
|
56
|
-
mkdir -p ~/.nansen && echo '{"apiKey":"<key>","baseUrl":"https://api.nansen.ai"}' > ~/.nansen/config.json && chmod 600 ~/.nansen/config.json
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Get your API key at [app.nansen.ai/api](https://app.nansen.ai/api).
|
|
60
|
-
|
|
61
|
-
### Auth Priority
|
|
62
|
-
|
|
63
|
-
1. `NANSEN_API_KEY` env var (highest)
|
|
64
|
-
2. `~/.nansen/config.json` file
|
|
65
|
-
3. Interactive prompt
|
|
66
|
-
|
|
67
|
-
### Verify It Works
|
|
15
|
+
## Auth
|
|
68
16
|
|
|
69
17
|
```bash
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# Verify API access:
|
|
74
|
-
nansen research token screener --chain solana --limit 1
|
|
18
|
+
nansen login # interactive — saves to ~/.nansen/config.json
|
|
19
|
+
export NANSEN_API_KEY=... # or env var (highest priority)
|
|
75
20
|
```
|
|
76
21
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# Get trending tokens on Solana
|
|
81
|
-
nansen research token screener --chain solana --timeframe 24h --pretty
|
|
82
|
-
|
|
83
|
-
# Check Smart Money activity
|
|
84
|
-
nansen research smart-money netflow --chain solana --pretty
|
|
85
|
-
|
|
86
|
-
# Profile a wallet
|
|
87
|
-
nansen research profiler balance --address 0x28c6c06298d514db089934071355e5743bf21d60 --chain ethereum --pretty
|
|
88
|
-
|
|
89
|
-
# Search for tokens/entities
|
|
90
|
-
nansen research search "Vitalik Buterin" --pretty
|
|
91
|
-
```
|
|
22
|
+
Get your API key at [app.nansen.ai/api](https://app.nansen.ai/api). AI agents can use the [Agent Setup](https://app.nansen.ai/auth/agent-setup) flow instead.
|
|
92
23
|
|
|
93
24
|
## Commands
|
|
94
25
|
|
|
95
|
-
All analytics live under `nansen research`, trading under `nansen trade`, and wallet management under `nansen wallet`.
|
|
96
|
-
|
|
97
|
-
### `research` - Research & Analytics
|
|
98
|
-
|
|
99
26
|
```
|
|
100
27
|
nansen research <category> <subcommand> [options]
|
|
28
|
+
nansen trade <subcommand> [options]
|
|
29
|
+
nansen wallet <subcommand> [options]
|
|
30
|
+
nansen schema [command] [--pretty] # full command reference (no API key needed)
|
|
101
31
|
```
|
|
102
32
|
|
|
103
|
-
**
|
|
104
|
-
|
|
105
|
-
#### `research smart-money` - Smart Money Analytics
|
|
106
|
-
|
|
107
|
-
Track trading and holding activity of sophisticated market participants.
|
|
33
|
+
**Research categories:** `smart-money` (`sm`), `token` (`tgm`), `profiler` (`prof`), `portfolio` (`port`), `search`, `perp`, `points`
|
|
108
34
|
|
|
109
|
-
|
|
110
|
-
|------------|-------------|
|
|
111
|
-
| `netflow` | Net capital flows (inflows vs outflows) |
|
|
112
|
-
| `dex-trades` | Real-time DEX trading activity |
|
|
113
|
-
| `perp-trades` | Perpetual trading on Hyperliquid |
|
|
114
|
-
| `holdings` | Aggregated token balances |
|
|
115
|
-
| `dcas` | DCA strategies on Jupiter |
|
|
116
|
-
| `historical-holdings` | Historical holdings over time |
|
|
35
|
+
**Trade:** `quote`, `execute` — DEX swaps on Solana and Base.
|
|
117
36
|
|
|
118
|
-
**
|
|
37
|
+
**Wallet:** `create`, `list`, `show`, `export`, `default`, `delete`, `send` — local keypairs (EVM + Solana).
|
|
119
38
|
|
|
120
|
-
|
|
39
|
+
Run `nansen schema --pretty` for the full subcommand and field reference.
|
|
121
40
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
nansen research profiler balance --address vitalik.eth
|
|
126
|
-
nansen research profiler labels --address nansen.eth --chain ethereum
|
|
127
|
-
nansen research profiler transactions --address vitalik.eth --table
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
ENS names are automatically resolved to `0x` addresses via public APIs (with onchain RPC fallback). Works on all EVM chains. The resolved name and address are included as `_ens` metadata in JSON output.
|
|
131
|
-
|
|
132
|
-
| Subcommand | Description |
|
|
133
|
-
|------------|-------------|
|
|
134
|
-
| `balance` | Current token holdings |
|
|
135
|
-
| `labels` | Behavioral and entity labels |
|
|
136
|
-
| `transactions` | Transaction history |
|
|
137
|
-
| `pnl` | PnL and trade performance |
|
|
138
|
-
| `search` | Search for entities by name |
|
|
139
|
-
| `historical-balances` | Historical balances over time |
|
|
140
|
-
| `related-wallets` | Find wallets related to an address |
|
|
141
|
-
| `counterparties` | Top counterparties by volume |
|
|
142
|
-
| `pnl-summary` | Summarized PnL metrics |
|
|
143
|
-
| `perp-positions` | Current perpetual positions |
|
|
144
|
-
| `perp-trades` | Perpetual trading history |
|
|
145
|
-
|
|
146
|
-
#### `research token` - Token God Mode
|
|
147
|
-
|
|
148
|
-
| Subcommand | Description |
|
|
149
|
-
|------------|-------------|
|
|
150
|
-
| `screener` | Discover and filter tokens |
|
|
151
|
-
| `holders` | Token holder analysis |
|
|
152
|
-
| `flows` | Token flow metrics |
|
|
153
|
-
| `dex-trades` | DEX trading activity |
|
|
154
|
-
| `pnl` | PnL leaderboard |
|
|
155
|
-
| `who-bought-sold` | Recent buyers and sellers |
|
|
156
|
-
| `flow-intelligence` | Detailed flow intelligence by label |
|
|
157
|
-
| `transfers` | Token transfer history |
|
|
158
|
-
| `jup-dca` | Jupiter DCA orders for token |
|
|
159
|
-
| `ohlcv` | OHLCV candle data for a token |
|
|
160
|
-
| `perp-trades` | Perp trades by token symbol |
|
|
161
|
-
| `perp-positions` | Open perp positions by token symbol |
|
|
162
|
-
| `perp-pnl-leaderboard` | Perp PnL leaderboard by token |
|
|
163
|
-
|
|
164
|
-
#### `research search` / `research perp` / `research portfolio` / `research points`
|
|
165
|
-
|
|
166
|
-
See `nansen research help` or `nansen schema --pretty` for full details.
|
|
167
|
-
|
|
168
|
-
### `trade` - DEX Trading
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# Get a swap quote
|
|
172
|
-
nansen trade quote --from USDC --to SOL --amount 10 --chain solana
|
|
173
|
-
|
|
174
|
-
# Execute the swap
|
|
175
|
-
nansen trade execute --from USDC --to SOL --amount 10 --chain solana
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### `wallet` - Local Wallet Management
|
|
179
|
-
|
|
180
|
-
| Subcommand | Description |
|
|
181
|
-
|------------|-------------|
|
|
182
|
-
| `create` | Create a new wallet (EVM + Solana keypair) |
|
|
183
|
-
| `list` | List all wallets |
|
|
184
|
-
| `show` | Show wallet addresses |
|
|
185
|
-
| `export` | Export private keys |
|
|
186
|
-
| `default` | Set default wallet |
|
|
187
|
-
| `delete` | Delete a wallet |
|
|
188
|
-
| `send` | Send tokens (native or ERC-20/SPL) |
|
|
189
|
-
|
|
190
|
-
Wallets are passwordless by default (keys stored like SSH keys). Set `NANSEN_WALLET_PASSWORD` env var for encryption at rest.
|
|
191
|
-
|
|
192
|
-
### `schema` - Schema Discovery
|
|
193
|
-
|
|
194
|
-
No API key required. Machine-readable command reference for agent introspection.
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
nansen schema --pretty # All commands
|
|
198
|
-
nansen schema research --pretty # Research commands
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Deprecated Flat Commands
|
|
202
|
-
|
|
203
|
-
The old flat commands (`nansen smart-money`, `nansen token`, `nansen profiler`, `nansen search`, `nansen perp`, `nansen portfolio`, `nansen points`, `nansen quote`, `nansen execute`) still work but print a deprecation warning to stderr. Use the new `research` and `trade` namespaces instead.
|
|
204
|
-
|
|
205
|
-
## Options
|
|
41
|
+
## Key Options
|
|
206
42
|
|
|
207
43
|
| Option | Description |
|
|
208
44
|
|--------|-------------|
|
|
209
|
-
| `--pretty` | Format JSON output for readability |
|
|
210
|
-
| `--table` | Format output as human-readable table |
|
|
211
|
-
| `--fields <list>` | Comma-separated fields to include (reduces response size) |
|
|
212
|
-
| `--stream` | Output as NDJSON for incremental processing |
|
|
213
|
-
| `--cache` / `--no-cache` | Enable/disable response caching |
|
|
214
|
-
| `--cache-ttl <s>` | Cache TTL in seconds (default: 300) |
|
|
215
45
|
| `--chain <chain>` | Blockchain to query |
|
|
216
|
-
| `--
|
|
217
|
-
| `--
|
|
218
|
-
| `--
|
|
219
|
-
| `--sort <field:dir>` | Sort results
|
|
220
|
-
| `--
|
|
221
|
-
| `--
|
|
46
|
+
| `--limit <n>` | Result count |
|
|
47
|
+
| `--timeframe <tf>` | Time window: `5m` `1h` `6h` `24h` `7d` `30d` |
|
|
48
|
+
| `--fields <list>` | Comma-separated fields (reduces response size) |
|
|
49
|
+
| `--sort <field:dir>` | Sort results, e.g. `--sort value_usd:desc` |
|
|
50
|
+
| `--pretty` | Human-readable JSON |
|
|
51
|
+
| `--table` | Table format |
|
|
52
|
+
| `--stream` | NDJSON output for large results |
|
|
222
53
|
| `--labels <label>` | Smart Money label filter |
|
|
223
|
-
| `--smart-money` | Filter for Smart Money only |
|
|
224
|
-
| `--timeframe <tf>` | Time window (5m, 10m, 1h, 6h, 24h, 7d, 30d) |
|
|
54
|
+
| `--smart-money` | Filter for Smart Money addresses only |
|
|
225
55
|
|
|
226
56
|
## Supported Chains
|
|
227
57
|
|
|
@@ -229,121 +59,51 @@ The old flat commands (`nansen smart-money`, `nansen token`, `nansen profiler`,
|
|
|
229
59
|
|
|
230
60
|
> Run `nansen schema` to get the current chain list (source of truth).
|
|
231
61
|
|
|
232
|
-
## Agent
|
|
233
|
-
|
|
234
|
-
### Reduce Token Burn with `--fields`
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
# ❌ Returns everything (huge JSON, wastes agent context)
|
|
238
|
-
nansen research smart-money netflow --chain solana
|
|
239
|
-
|
|
240
|
-
# ✅ Only what you need
|
|
241
|
-
nansen research smart-money netflow --chain solana --fields token_symbol,net_flow_usd,chain --limit 10
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Use `--stream` for Large Results
|
|
62
|
+
## Agent Tips
|
|
245
63
|
|
|
64
|
+
**Reduce token burn with `--fields`:**
|
|
246
65
|
```bash
|
|
247
|
-
|
|
248
|
-
nansen research token dex-trades --chain solana --limit 100 --stream
|
|
66
|
+
nansen research smart-money netflow --chain solana --fields token_symbol,net_flow_usd --limit 10
|
|
249
67
|
```
|
|
250
68
|
|
|
251
|
-
|
|
69
|
+
**Use `--stream` for large results** — outputs NDJSON instead of buffering a giant array.
|
|
252
70
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
1. CLI detects 402 response with payment requirements
|
|
256
|
-
2. Signs a USDC payment ($0.05/call) using your wallet
|
|
257
|
-
3. Retries the request with the payment signature
|
|
258
|
-
4. Falls back from EVM to Solana if first network has insufficient funds
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
# Fund your wallet, then API calls auto-pay
|
|
262
|
-
nansen wallet create
|
|
263
|
-
# Send USDC to the displayed address
|
|
264
|
-
nansen research smart-money netflow --chain solana # auto-pays if no API key
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
## Pagination
|
|
268
|
-
|
|
269
|
-
Use `--limit N` to control result count. The CLI always fetches page 1 (there is no `--page` flag).
|
|
270
|
-
|
|
271
|
-
**Detecting the last page:** If results returned < your `--limit`, you've reached the end.
|
|
71
|
+
**ENS names** work anywhere `--address` is accepted: `--address vitalik.eth`
|
|
272
72
|
|
|
273
73
|
## Output Format
|
|
274
74
|
|
|
275
|
-
### Response envelope
|
|
276
|
-
|
|
277
75
|
```json
|
|
278
|
-
|
|
279
|
-
{ "success":
|
|
280
|
-
|
|
281
|
-
// Error
|
|
282
|
-
{ "success": false, "error": "message", "code": "ERROR_CODE", "status": 401, "details": {...} }
|
|
76
|
+
{ "success": true, "data": <api_response> }
|
|
77
|
+
{ "success": false, "error": "message", "code": "ERROR_CODE", "status": 401 }
|
|
283
78
|
```
|
|
284
79
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
The `data` field structure differs across endpoints:
|
|
288
|
-
|
|
289
|
-
| Shape | Example endpoints |
|
|
290
|
-
|-------|------------------|
|
|
291
|
-
| `data.data` (array) | token screener |
|
|
292
|
-
| `data.results` (array) | entity search |
|
|
293
|
-
| `data.data.results` (array) | most profiler endpoints |
|
|
294
|
-
| `data.netflows` | smart-money netflow |
|
|
295
|
-
| `data.trades` | smart-money dex-trades |
|
|
296
|
-
| `data.holdings` | smart-money holdings |
|
|
297
|
-
| `data.holders` | token holders |
|
|
298
|
-
|
|
299
|
-
`--table` and `--stream` handle this automatically. For raw JSON parsing:
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
nansen research smart-money netflow --chain solana | jq 'keys, .data | keys'
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### Error codes
|
|
80
|
+
**Critical error codes:**
|
|
306
81
|
|
|
307
82
|
| Code | Action |
|
|
308
83
|
|------|--------|
|
|
309
|
-
| `CREDITS_EXHAUSTED` | Stop all API calls immediately
|
|
310
|
-
| `
|
|
84
|
+
| `CREDITS_EXHAUSTED` | Stop all API calls immediately. Check [app.nansen.ai](https://app.nansen.ai). |
|
|
85
|
+
| `UNAUTHORIZED` | Wrong or missing key. Re-auth. |
|
|
86
|
+
| `RATE_LIMITED` | Auto-retried by CLI. |
|
|
311
87
|
| `UNSUPPORTED_FILTER` | Remove the filter and retry. |
|
|
312
|
-
| `UNAUTHORIZED` | Key is wrong or missing. Re-auth. |
|
|
313
|
-
| `INVALID_ADDRESS` | Check address format for the chain. |
|
|
314
88
|
|
|
315
89
|
## Troubleshooting
|
|
316
90
|
|
|
317
91
|
| Symptom | Fix |
|
|
318
92
|
|---------|-----|
|
|
319
|
-
| `command not found
|
|
320
|
-
| `UNAUTHORIZED` after login |
|
|
321
|
-
|
|
|
322
|
-
|
|
|
323
|
-
|
|
|
324
|
-
| `UNSUPPORTED_FILTER` on token holders | Not all tokens have smart money data. Remove `--smart-money`. |
|
|
325
|
-
| `CREDITS_EXHAUSTED` | Check your plan at [app.nansen.ai](https://app.nansen.ai). |
|
|
93
|
+
| `command not found` | `npm install -g nansen-cli` |
|
|
94
|
+
| `UNAUTHORIZED` after login | `cat ~/.nansen/config.json` or set `NANSEN_API_KEY` |
|
|
95
|
+
| Empty perp results | Use `--symbol BTC`, not `--token`. Perps are Hyperliquid-only. |
|
|
96
|
+
| `UNSUPPORTED_FILTER` on token holders | Remove `--smart-money` — not all tokens have that data. |
|
|
97
|
+
| Huge JSON response | Use `--fields` to select columns. |
|
|
326
98
|
|
|
327
99
|
## Development
|
|
328
100
|
|
|
329
101
|
```bash
|
|
330
|
-
npm test #
|
|
331
|
-
npm run test:
|
|
332
|
-
npm run test:live # Against live API (needs NANSEN_API_KEY)
|
|
102
|
+
npm test # mocked tests, no API key needed
|
|
103
|
+
npm run test:live # live API (needs NANSEN_API_KEY)
|
|
333
104
|
```
|
|
334
105
|
|
|
335
|
-
See [AGENTS.md](AGENTS.md) for
|
|
336
|
-
|
|
337
|
-
## API Coverage
|
|
338
|
-
|
|
339
|
-
| Category | Endpoints | Coverage |
|
|
340
|
-
|----------|-----------|----------|
|
|
341
|
-
| Smart Money | 6 | 100% |
|
|
342
|
-
| Profiler | 11 | 100% |
|
|
343
|
-
| Token God Mode | 12 | 100% |
|
|
344
|
-
| Portfolio | 1 | 100% |
|
|
345
|
-
| Search | 1 | 100% |
|
|
346
|
-
| **Total** | **31** | **100%** |
|
|
106
|
+
See [AGENTS.md](AGENTS.md) for architecture and contributor guidance.
|
|
347
107
|
|
|
348
108
|
## License
|
|
349
109
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nansen-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Command-line interface for Nansen API - designed for AI agents",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"src/*.js",
|
|
12
|
+
"src/*.json",
|
|
12
13
|
"CHANGELOG.md"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
@@ -19,6 +20,8 @@
|
|
|
19
20
|
"test:coverage": "vitest run --coverage",
|
|
20
21
|
"test:live": "NANSEN_LIVE_TEST=1 vitest run",
|
|
21
22
|
"test:trade": "vitest run --config vitest.e2e.config.js",
|
|
23
|
+
"lint": "eslint .",
|
|
24
|
+
"lint:fix": "eslint . --fix",
|
|
22
25
|
"changeset": "changeset",
|
|
23
26
|
"changeset:version": "changeset version",
|
|
24
27
|
"changeset:publish": "changeset publish"
|
|
@@ -52,7 +55,10 @@
|
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@changesets/changelog-github": "^0.5.1",
|
|
54
57
|
"@changesets/cli": "^2.29.4",
|
|
58
|
+
"@eslint/js": "^10.0.1",
|
|
55
59
|
"@vitest/coverage-v8": "^4.0.18",
|
|
60
|
+
"eslint": "^10.0.2",
|
|
61
|
+
"globals": "^17.4.0",
|
|
56
62
|
"vitest": "^4.0.18"
|
|
57
63
|
}
|
|
58
|
-
}
|
|
64
|
+
}
|
package/src/api.js
CHANGED
|
@@ -194,9 +194,9 @@ export function getCachedResponse(endpoint, body, ttlSeconds = DEFAULT_CACHE_TTL
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
return { ...cached.data, _meta: { ...cached.data._meta, fromCache: true, cacheAge: Math.round(age) } };
|
|
197
|
-
} catch (
|
|
197
|
+
} catch (_e) {
|
|
198
198
|
// Invalid cache file, delete it
|
|
199
|
-
try { fs.unlinkSync(cacheFile); } catch {}
|
|
199
|
+
try { fs.unlinkSync(cacheFile); } catch { /* ignore */ }
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
@@ -305,7 +305,7 @@ function loadConfig() {
|
|
|
305
305
|
|
|
306
306
|
// ~/.nansen/config.json (from `nansen login`)
|
|
307
307
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
308
|
-
try { config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); } catch (
|
|
308
|
+
try { config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); } catch (_e) { /* ignore */ }
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
// Local config.json (for development)
|
|
@@ -476,7 +476,7 @@ export class NansenAPI {
|
|
|
476
476
|
let data;
|
|
477
477
|
try {
|
|
478
478
|
data = await response.json();
|
|
479
|
-
} catch (
|
|
479
|
+
} catch (_err) {
|
|
480
480
|
// Non-JSON response (rare, usually server errors)
|
|
481
481
|
const error = new NansenError(
|
|
482
482
|
`Invalid response from API (status ${response.status})`,
|
|
@@ -646,11 +646,12 @@ export class NansenAPI {
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
async smartMoneyPerpTrades(params = {}) {
|
|
649
|
-
const { filters = {}, orderBy, pagination } = params;
|
|
649
|
+
const { filters = {}, orderBy, pagination, onlyNewPositions } = params;
|
|
650
650
|
return this.request('/api/v1/smart-money/perp-trades', {
|
|
651
651
|
filters,
|
|
652
652
|
order_by: orderBy,
|
|
653
|
-
pagination
|
|
653
|
+
pagination,
|
|
654
|
+
only_new_positions: onlyNewPositions
|
|
654
655
|
});
|
|
655
656
|
}
|
|
656
657
|
|
|
@@ -703,7 +704,7 @@ export class NansenAPI {
|
|
|
703
704
|
}
|
|
704
705
|
|
|
705
706
|
async addressLabels(params = {}) {
|
|
706
|
-
const { address, chain = 'ethereum', pagination = { page: 1,
|
|
707
|
+
const { address, chain = 'ethereum', pagination = { page: 1, per_page: 100 } } = params;
|
|
707
708
|
if (address) {
|
|
708
709
|
const validation = validateAddress(address, chain);
|
|
709
710
|
if (!validation.valid) throw new NansenError(validation.error, validation.code);
|
|
@@ -814,7 +815,9 @@ export class NansenAPI {
|
|
|
814
815
|
}
|
|
815
816
|
|
|
816
817
|
async addressPnlSummary(params = {}) {
|
|
817
|
-
|
|
818
|
+
// Note: pnl-summary endpoint is non-paginated (returns aggregate stats, not a list).
|
|
819
|
+
// Pagination param intentionally omitted from this request.
|
|
820
|
+
const { address, chain = 'ethereum', orderBy, days = 30 } = params;
|
|
818
821
|
if (address) {
|
|
819
822
|
const validation = validateAddress(address, chain);
|
|
820
823
|
if (!validation.valid) throw new NansenError(validation.error, validation.code);
|
|
@@ -823,8 +826,7 @@ export class NansenAPI {
|
|
|
823
826
|
address,
|
|
824
827
|
chain,
|
|
825
828
|
date: buildDateRange(days),
|
|
826
|
-
order_by: orderBy
|
|
827
|
-
pagination
|
|
829
|
+
order_by: orderBy
|
|
828
830
|
});
|
|
829
831
|
}
|
|
830
832
|
|
|
@@ -1039,7 +1041,7 @@ export class NansenAPI {
|
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
1043
|
async tokenOhlcv(params = {}) {
|
|
1042
|
-
const { tokenAddress, chain = 'solana', timeframe
|
|
1044
|
+
const { tokenAddress, chain = 'solana', timeframe } = params;
|
|
1043
1045
|
if (tokenAddress) {
|
|
1044
1046
|
const validation = validateTokenAddress(tokenAddress, chain);
|
|
1045
1047
|
if (!validation.valid) throw new NansenError(validation.error, validation.code);
|
|
@@ -1048,7 +1050,6 @@ export class NansenAPI {
|
|
|
1048
1050
|
token_address: tokenAddress,
|
|
1049
1051
|
chain,
|
|
1050
1052
|
timeframe,
|
|
1051
|
-
pagination
|
|
1052
1053
|
});
|
|
1053
1054
|
}
|
|
1054
1055
|
|