Skip to content

Add --buy-or-sell option to token who-bought-sold command#347

Merged
kome12 merged 3 commits intomainfrom
fix/who-bought-sold-buy-or-sell-v2
Mar 27, 2026
Merged

Add --buy-or-sell option to token who-bought-sold command#347
kome12 merged 3 commits intomainfrom
fix/who-bought-sold-buy-or-sell-v2

Conversation

@kome12
Copy link
Copy Markdown
Contributor

@kome12 kome12 commented Mar 26, 2026

Summary

The /api/v1/tgm/who-bought-sold endpoint accepts a buy_or_sell parameter (BUY | SELL), but the CLI never sent it — meaning sell-side data was completely inaccessible.

Changes

  • src/schema.json — added buy-or-sell option with enum ["BUY", "SELL"], default "BUY"
  • src/cli.js — reads --buy-or-sell option and passes it through
  • src/api.js — includes buy_or_sell in the request body (default 'BUY')
  • src/__tests__/api.test.js + cli.internal.test.js — tests for default and explicit SELL

Usage

# Buyers (default, unchanged behaviour)
nansen token who-bought-sold --token 0x... --chain ethereum

# Sellers
nansen token who-bought-sold --token 0x... --chain ethereum --buy-or-sell SELL

Allows filtering by BUY or SELL side (defaults to BUY). Passes
buy_or_sell in the request body to /api/v1/tgm/who-bought-sold.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kome12 kome12 self-assigned this Mar 26, 2026
Comment thread src/cli.js Outdated
'who-bought-sold': () => {
const date = parseDateOption(options.date, days);
return apiInstance.tokenWhoBoughtSold({ tokenAddress, chain, filters, orderBy, pagination, days, date });
const buyOrSell = options['buy-or-sell'] || 'BUY';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 Should we uppercase the user input so we also accept buy/sell?

TimNooren
TimNooren previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor Author

@kome12 kome12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — applied so buy/sell (lowercase) now work too.

@kome12
Copy link
Copy Markdown
Contributor Author

kome12 commented Mar 27, 2026

Good call — applied .toUpperCase() so buy/sell (lowercase) also works now.

@kome12 kome12 merged commit 0945a7a into main Mar 27, 2026
7 checks passed
@kome12 kome12 deleted the fix/who-bought-sold-buy-or-sell-v2 branch March 27, 2026 06:10
@github-actions github-actions bot mentioned this pull request Mar 27, 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.

2 participants