feat: add nansen research command for historical analytics#437
Merged
Conversation
be2cf5a to
3fedecc
Compare
nansen gym subcommand for historical / backtesting endpoints3fedecc to
943aa5a
Compare
943aa5a to
b10ab6b
Compare
b10ab6b to
9a4866f
Compare
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>
9a4866f to
5ec7bd3
Compare
Contributor
Author
Smoke test resultsRan all 11 subcommands against the live API using a real API key. 11/11 passed ✅ (updated 2026-05-15)
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new top-level
nansen researchcommand 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
Changes
src/api.jstargeting/api/v1beta1/endpointssrc/commands/research.js— new command module wired into the CLIsrc/cli.js—researchadded to top-level commandssrc/schema.json— schema entries for all 11 subcommandssrc/__tests__/research.test.js— unit test suite covering URL, required fields, and request body shapeFixes
Aligned request body shapes with the upstream
/api/v1beta1/contract. The previous payloads returned HTTP 422 on four families of endpoints:historical-dex-trades,historical-pnl-leaderboard,historical-token-flow-summary,historical-who-bought-sold) now senddate_range: { from, to }instead of{ from_date, to_date }. CLI flags remain--from-date/--to-date.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-dateflags have been removed from these subcommands.historical-token-screenernow takes--timeframe-days <n>(required, integer) and optional--to-date <YYYY-MM-DD>, and sends{ timeframe_days, to_date }. Replaces the previousdate_rangebody.historical-tx-lookupnow sends the field astransaction_hashinstead oftx_hash. CLI flag remains--tx-hash.Schema, help text, and unit tests updated to match the new shapes.
Test plan
npm testpassesnpm run lintpassesnode src/index.js researchprints helpnode src/index.js schema researchreturns schema entries🤖 Generated with Claude Code