Sorting

Overview

Most Nansen API endpoints support sorting results using the order_by parameter. This allows you to control the order of returned data.

Sort Order Schema

{
  "order_by": [
    {
      "field": "field_name",
      "direction": "DESC"
    }
  ]
}

Parameters

Parameter
Type
Description

field

string

The field to sort by

direction

string

ASC (ascending) or DESC (descending)

Directions

Direction
Description
Example

ASC

Ascending (smallest first)

1, 2, 3, ... or A, B, C

DESC

Descending (largest first)

100, 99, 98, ... or Z, Y, X

Examples

Single Field Sort

Sort by USD value, highest first:

Multiple Field Sort

Sort by volume first, then by price:

Full Request Example

Common Sort Fields by Endpoint

Smart Money Holdings

Field
Description

value_usd

Total USD value of holdings

balance_24h_percent_change

24-hour balance change percentage

holders_count

Number of smart money holders

share_of_holdings_percent

Share of total token supply held

market_cap_usd

Token market capitalization

token_age_days

Days since token creation

Smart Money Netflow

Field
Description

net_flow_1h_usd

1-hour net flow in USD

net_flow_24h_usd

24-hour net flow in USD

net_flow_7d_usd

7-day net flow in USD

net_flow_30d_usd

30-day net flow in USD

trader_count

Number of smart money traders

market_cap_usd

Token market capitalization

Smart Money DEX Trades

Field
Description

timestamp

Trade timestamp

value_usd

Trade value in USD

amount

Token amount traded

Token Screener

Field
Description

market_cap_usd

Market capitalization

volume_24h_usd

24-hour trading volume

price_change_24h_percent

24-hour price change

holder_count

Total holder count

smart_money_holder_count

Smart money holder count

liquidity_usd

Total liquidity

TGM Holders

Field
Description

balance_usd

Current balance in USD

balance_change_24h_usd

24-hour balance change

first_transfer_timestamp

First transfer date

last_transfer_timestamp

Last transfer date

TGM PnL Leaderboard

Field
Description

realized_pnl_usd

Realized profit/loss

unrealized_pnl_usd

Unrealized profit/loss

total_pnl_usd

Total profit/loss

roi_percent

Return on investment

Best Practices

1. Always Sort When Paginating

Ensure consistent ordering across pages:

2. Use Secondary Sort for Ties

Add a secondary sort field to break ties:

3. Sort by Timestamp for Recent Data

For trade/transaction data, sort by timestamp:

4. Consider Default Sorts

Many endpoints have sensible default sorts. Check the endpoint documentation for defaults.

Error Handling

Invalid Sort Field

Invalid Direction

Python Helper

Last updated

Was this helpful?