Skip to content

feat: add nansen research command for historical analytics#437

Merged
gulshngill merged 2 commits into
mainfrom
feat/ecint-6655-gym-subcommand
May 15, 2026
Merged

feat: add nansen research command for historical analytics#437
gulshngill merged 2 commits into
mainfrom
feat/ecint-6655-gym-subcommand

Conversation

@gulshngill
Copy link
Copy Markdown
Contributor

@gulshngill gulshngill commented May 15, 2026

Summary

Adds a new top-level nansen research command with 11 subcommands for accessing historical/point-in-time analytics data. Each subcommand resolves onchain labels at the requested historical date rather than current state — useful for backtesting and historical research.

New subcommands

nansen research historical-dex-trades
nansen research historical-pnl-leaderboard
nansen research historical-token-flow-summary
nansen research historical-token-quant-scores
nansen research historical-top-holders
nansen research historical-who-bought-sold
nansen research historical-smart-money-balances
nansen research historical-token-screener
nansen research historical-wallet-balances
nansen research historical-tx-lookup
nansen research historical-wallet-transactions

Changes

  • 11 new API client methods in src/api.js targeting /api/v1beta1/ endpoints
  • src/commands/research.js — new command module wired into the CLI
  • src/cli.jsresearch added to top-level commands
  • src/schema.json — schema entries for all 11 subcommands
  • src/__tests__/research.test.js — unit test suite covering URL, required fields, and request body shape

Fixes

Aligned request body shapes with the upstream /api/v1beta1/ contract. The previous payloads returned HTTP 422 on four families of endpoints:

  • Range-based subcommands (historical-dex-trades, historical-pnl-leaderboard, historical-token-flow-summary, historical-who-bought-sold) now send date_range: { from, to } instead of { from_date, to_date }. CLI flags remain --from-date / --to-date.
  • Snapshot subcommands (historical-top-holders, historical-token-quant-scores, historical-smart-money-balances, historical-wallet-balances, historical-wallet-transactions) now take a single --as-of-date <YYYY-MM-DD> and send { as_of_date }. The old --from-date / --to-date flags have been removed from these subcommands.
  • historical-token-screener now takes --timeframe-days <n> (required, integer) and optional --to-date <YYYY-MM-DD>, and sends { timeframe_days, to_date }. Replaces the previous date_range body.
  • historical-tx-lookup now sends the field as transaction_hash instead of tx_hash. CLI flag remains --tx-hash.

Schema, help text, and unit tests updated to match the new shapes.

Test plan

  • npm test passes
  • npm run lint passes
  • node src/index.js research prints help
  • node src/index.js schema research returns schema entries
  • Live smoke once v1beta1 endpoints are accessible

🤖 Generated with Claude Code

@gulshngill gulshngill force-pushed the feat/ecint-6655-gym-subcommand branch from be2cf5a to 3fedecc Compare May 15, 2026 11:34
@gulshngill gulshngill changed the title feat: add nansen gym subcommand for historical / backtesting endpoints feat: add historical subcommands to existing tgm/smart-money/profiler/token-screener May 15, 2026
@gulshngill gulshngill force-pushed the feat/ecint-6655-gym-subcommand branch from 3fedecc to 943aa5a Compare May 15, 2026 11:52
@gulshngill gulshngill changed the title feat: add historical subcommands to existing tgm/smart-money/profiler/token-screener feat: add nansen research command for historical analytics May 15, 2026
@gulshngill gulshngill force-pushed the feat/ecint-6655-gym-subcommand branch from 943aa5a to b10ab6b Compare May 15, 2026 12:07
@gulshngill gulshngill force-pushed the feat/ecint-6655-gym-subcommand branch from b10ab6b to 9a4866f Compare May 15, 2026 12:51
Adds a top-level `nansen research` command with 11 subcommands for
historical/point-in-time analytics via the v1beta1 API. Each subcommand
resolves onchain labels at the requested historical date rather than
current state — useful for backtesting and historical research.

Subcommands: dex-trades, pnl-leaderboard, token-flow-summary,
token-quant-scores, top-holders, who-bought-sold, smart-money-balances,
token-screener, wallet-balances, tx-lookup, wallet-transactions.

- src/api.js: 11 new researchXxx() methods.
- src/commands/research.js: new module with buildResearchCommands(deps).
- src/cli.js: wires the historical handler alongside existing category
  routing (smart-money/profiler/token/...).
- src/schema.json: schema entries for the 11 subcommands.
- src/__tests__/research.test.js: covers URL, body shape, required
  fields, and CLI dispatch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@gulshngill gulshngill force-pushed the feat/ecint-6655-gym-subcommand branch from 9a4866f to 5ec7bd3 Compare May 15, 2026 13:15
@gulshngill
Copy link
Copy Markdown
Contributor Author

gulshngill commented May 15, 2026

Smoke test results

Ran all 11 subcommands against the live API using a real API key.

11/11 passed ✅ (updated 2026-05-15)

Subcommand Result
historical-dex-trades ✅ Pass
historical-pnl-leaderboard ✅ Pass
historical-token-flow-summary ✅ Pass
historical-who-bought-sold ✅ Pass
historical-top-holders ✅ Pass
historical-token-quant-scores ✅ Pass
historical-smart-money-balances ✅ Pass
historical-wallet-balances ✅ Pass
historical-wallet-transactions ✅ Pass
historical-token-screener ✅ Pass (was failing due to API-side bug, now fixed)
historical-tx-lookup ✅ Pass (use --block-timestamp flag to skip slow hash lookup)

All 11 endpoints pass. All 1473 unit tests pass.

Expose the optional block_timestamp parameter on the
historical-tx-lookup subcommand. When provided, the API skips the
slow hash-resolution step (full-table scan, 60-170s) and returns
results immediately.

Updated schema.json to reflect the correct flags (transaction-hash,
as-of-date, block-timestamp) which were stale from an earlier
iteration.
@gulshngill gulshngill merged commit a9e2805 into main May 15, 2026
7 checks passed
@gulshngill gulshngill deleted the feat/ecint-6655-gym-subcommand branch May 15, 2026 17:01
@github-actions github-actions Bot mentioned this pull request May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant