diff --git a/src/nansen/resources/points.py b/src/nansen/resources/points.py index b4cc817..1ca83a4 100644 --- a/src/nansen/resources/points.py +++ b/src/nansen/resources/points.py @@ -10,6 +10,8 @@ class Points(SyncAPIResource): + """Points resource for the Nansen points leaderboard (no auth required).""" + def leaderboard( self, *, @@ -19,6 +21,9 @@ def leaderboard( This endpoint uses GET, requires no authentication, and hits a different base URL (app.nansen.ai). + + Args: + tier: Filter by tier name. """ params = {} if not isinstance(tier, _NotGiven): @@ -36,12 +41,21 @@ def leaderboard( class AsyncPoints(AsyncAPIResource): + """Points resource for the Nansen points leaderboard (no auth required, async).""" + async def leaderboard( self, *, tier: str | NotGiven = NOT_GIVEN, ) -> APIResponse[list[PointsLeaderboardEntry]]: - """Fetch the points leaderboard (async).""" + """Fetch the points leaderboard. + + This endpoint uses GET, requires no authentication, + and hits a different base URL (app.nansen.ai). + + Args: + tier: Filter by tier name. + """ params = {} if not isinstance(tier, _NotGiven): params["tier"] = tier diff --git a/src/nansen/resources/portfolio.py b/src/nansen/resources/portfolio.py index c07b6a1..4239ac5 100644 --- a/src/nansen/resources/portfolio.py +++ b/src/nansen/resources/portfolio.py @@ -6,11 +6,18 @@ class Portfolio(SyncAPIResource): + """Portfolio resource for wallet-level analytics.""" + def defi_holdings( self, *, wallet_address: str, ) -> APIResponse[DefiHoldingsResponse]: + """Get DeFi holdings for a wallet address. + + Args: + wallet_address: The wallet address to look up. + """ return self._post( "/portfolio/defi-holdings", body={"wallet_address": wallet_address}, @@ -19,11 +26,18 @@ def defi_holdings( class AsyncPortfolio(AsyncAPIResource): + """Portfolio resource for wallet-level analytics (async).""" + async def defi_holdings( self, *, wallet_address: str, ) -> APIResponse[DefiHoldingsResponse]: + """Get DeFi holdings for a wallet address. + + Args: + wallet_address: The wallet address to look up. + """ return await self._post( "/portfolio/defi-holdings", body={"wallet_address": wallet_address}, diff --git a/src/nansen/resources/profiler/address.py b/src/nansen/resources/profiler/address.py index 3848e4b..ad1c5bf 100644 --- a/src/nansen/resources/profiler/address.py +++ b/src/nansen/resources/profiler/address.py @@ -17,6 +17,8 @@ class Address(SyncAPIResource): + """Address sub-resource for wallet-level profiler endpoints.""" + def current_balance( self, *, @@ -28,6 +30,17 @@ def current_balance( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[ProfilerBalanceItem]: + """Get current token balances for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + hide_spam_token: If ``True``, exclude tokens flagged as spam. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/current-balance", body={ @@ -53,6 +66,17 @@ def historical_balances( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[HistoricalBalanceItem]: + """Get historical token balances for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/historical-balances", body={ @@ -78,6 +102,17 @@ def transactions( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TransactionItem]: + """Get transaction history for an address. + + Args: + address: Wallet address to look up. + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + hide_spam_token: If ``True``, exclude transactions involving spam tokens. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/transactions", body={ @@ -105,6 +140,19 @@ def counterparties( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[CounterpartyItem]: + """Get counterparty data for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + source_input: Source input type for the query. + group_by: Field to group counterparties by. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/counterparties", body={ @@ -129,6 +177,14 @@ def related_wallets( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[RelatedWalletItem]: + """Get wallets related to an address. + + Args: + address: Wallet address to look up. + chain: Chain identifier (e.g. ``"ethereum"``). + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/related-wallets", body={ @@ -149,10 +205,17 @@ def labels( label: str | NotGiven = NOT_GIVEN, pagination: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> APIResponse[list[AddressLabelItem]]: - """Fetch address labels (beta endpoint). + """Get labels for an address (beta endpoint). - Note: This endpoint uses ``/api/beta/`` and has a different + This endpoint uses the ``/api/beta/`` base path and has a different request structure than standard v1 endpoints. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity: Filter by entity name. + label: Filter by label name. + pagination: Pagination options (``page``, ``per_page``). """ parameters: dict[str, Any] = {"chain": chain, "address": address} @@ -182,6 +245,8 @@ def labels( class AsyncAddress(AsyncAPIResource): + """Address sub-resource for wallet-level profiler endpoints (async).""" + async def current_balance( self, *, @@ -193,6 +258,17 @@ async def current_balance( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[ProfilerBalanceItem]: + """Get current token balances for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + hide_spam_token: If ``True``, exclude tokens flagged as spam. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/current-balance", body={ @@ -218,6 +294,17 @@ async def historical_balances( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[HistoricalBalanceItem]: + """Get historical token balances for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/historical-balances", body={ @@ -243,6 +330,17 @@ async def transactions( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TransactionItem]: + """Get transaction history for an address. + + Args: + address: Wallet address to look up. + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + hide_spam_token: If ``True``, exclude transactions involving spam tokens. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/transactions", body={ @@ -270,6 +368,19 @@ async def counterparties( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[CounterpartyItem]: + """Get counterparty data for an address or entity. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + source_input: Source input type for the query. + group_by: Field to group counterparties by. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/counterparties", body={ @@ -294,6 +405,14 @@ async def related_wallets( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[RelatedWalletItem]: + """Get wallets related to an address. + + Args: + address: Wallet address to look up. + chain: Chain identifier (e.g. ``"ethereum"``). + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/related-wallets", body={ @@ -314,6 +433,18 @@ async def labels( label: str | NotGiven = NOT_GIVEN, pagination: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> APIResponse[list[AddressLabelItem]]: + """Get labels for an address (beta endpoint). + + This endpoint uses the ``/api/beta/`` base path and has a different + request structure than standard v1 endpoints. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity: Filter by entity name. + label: Filter by label name. + pagination: Pagination options (``page``, ``per_page``). + """ parameters: dict[str, Any] = {"chain": chain, "address": address} if not isinstance(entity, NotGiven): diff --git a/src/nansen/resources/profiler/profiler.py b/src/nansen/resources/profiler/profiler.py index 7093fa1..97680e4 100644 --- a/src/nansen/resources/profiler/profiler.py +++ b/src/nansen/resources/profiler/profiler.py @@ -19,8 +19,11 @@ class Profiler(SyncAPIResource): + """Profiler resource for address and entity-level analytics.""" + @cached_property def address(self) -> Address: + """Sub-resource for address-specific endpoints.""" return Address(self._client) def pnl_summary( @@ -31,6 +34,16 @@ def pnl_summary( address: str | NotGiven = NOT_GIVEN, entity_name: str | NotGiven = NOT_GIVEN, ) -> APIResponse[PnlSummaryResponse]: + """Get PnL summary for an address or entity. + + Provide either ``address`` or ``entity_name`` to identify the target. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + """ return self._post( "/profiler/address/pnl-summary", body={ @@ -53,6 +66,19 @@ def pnl( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[PnlItem]: + """Get detailed PnL data for an address or entity. + + Provide either ``address`` or ``entity_name`` to identify the target. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/address/pnl", body={ @@ -74,6 +100,13 @@ def perp_positions( filters: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> APIResponse[PerpPositionsResponse]: + """Get perpetual futures positions for an address. + + Args: + address: Wallet address to look up. + filters: Field-level filters to narrow results. + order_by: List of ordering directives. + """ return self._post( "/profiler/perp-positions", body={ @@ -93,6 +126,15 @@ def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[ProfilerPerpTradeItem]: + """Get perpetual futures trade history for an address. + + Args: + address: Wallet address to look up. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/profiler/perp-trades", body={ @@ -110,6 +152,11 @@ def entity_search( *, search_query: str, ) -> APIResponse[list[EntitySearchItem]]: + """Search for entities by name. + + Args: + search_query: Search term to match against entity names. + """ from pydantic import TypeAdapter @@ -133,6 +180,14 @@ def perp_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[PerpLeaderboardItem]: + """Get the perpetual futures leaderboard. + + Args: + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/perp-leaderboard", body={ @@ -146,8 +201,11 @@ def perp_leaderboard( class AsyncProfiler(AsyncAPIResource): + """Profiler resource for address and entity-level analytics (async).""" + @cached_property def address(self) -> AsyncAddress: + """Sub-resource for address-specific endpoints.""" return AsyncAddress(self._client) async def pnl_summary( @@ -158,6 +216,16 @@ async def pnl_summary( address: str | NotGiven = NOT_GIVEN, entity_name: str | NotGiven = NOT_GIVEN, ) -> APIResponse[PnlSummaryResponse]: + """Get PnL summary for an address or entity. + + Provide either ``address`` or ``entity_name`` to identify the target. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + date: Date range with ``"from"`` and ``"to"`` keys. + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + """ return await self._post( "/profiler/address/pnl-summary", body={ @@ -180,6 +248,19 @@ async def pnl( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[PnlItem]: + """Get detailed PnL data for an address or entity. + + Provide either ``address`` or ``entity_name`` to identify the target. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + address: Wallet address to look up. + entity_name: Entity name to look up (alternative to ``address``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/address/pnl", body={ @@ -201,6 +282,13 @@ async def perp_positions( filters: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> APIResponse[PerpPositionsResponse]: + """Get perpetual futures positions for an address. + + Args: + address: Wallet address to look up. + filters: Field-level filters to narrow results. + order_by: List of ordering directives. + """ return await self._post( "/profiler/perp-positions", body={ @@ -220,6 +308,15 @@ async def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[ProfilerPerpTradeItem]: + """Get perpetual futures trade history for an address. + + Args: + address: Wallet address to look up. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/profiler/perp-trades", body={ @@ -237,6 +334,11 @@ async def entity_search( *, search_query: str, ) -> APIResponse[list[EntitySearchItem]]: + """Search for entities by name. + + Args: + search_query: Search term to match against entity names. + """ from pydantic import TypeAdapter @@ -260,6 +362,14 @@ async def perp_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[PerpLeaderboardItem]: + """Get the perpetual futures leaderboard. + + Args: + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/perp-leaderboard", body={ diff --git a/src/nansen/resources/smart_money.py b/src/nansen/resources/smart_money.py index 450afb0..26f8853 100644 --- a/src/nansen/resources/smart_money.py +++ b/src/nansen/resources/smart_money.py @@ -16,6 +16,8 @@ class SmartMoney(SyncAPIResource): + """Smart Money resource for tracking labeled smart money wallets.""" + def netflow( self, *, @@ -24,6 +26,14 @@ def netflow( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyNetflowItem]: + """Get smart money netflow data across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/netflow", body={ @@ -43,6 +53,14 @@ def dex_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyDexTradeItem]: + """Get smart money DEX trades across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/dex-trades", body={ @@ -62,6 +80,14 @@ def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyPerpTradeItem]: + """Get smart money perpetual futures trades. + + Args: + filters: Field-level filters to narrow results. + only_new_positions: If ``True``, only return trades that open new positions. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/perp-trades", body={ @@ -80,6 +106,13 @@ def dcas( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyDcaItem]: + """Get smart money DCA orders. + + Args: + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/dcas", body={ @@ -98,6 +131,14 @@ def holdings( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyHoldingItem]: + """Get current smart money holdings across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/holdings", body={ @@ -118,6 +159,15 @@ def historical_holdings( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[SmartMoneyHistoricalHoldingItem]: + """Get historical smart money holdings across chains. + + Args: + date_range: Date range with ``"from"`` and ``"to"`` keys. + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/smart-money/historical-holdings", body={ @@ -132,6 +182,8 @@ def historical_holdings( class AsyncSmartMoney(AsyncAPIResource): + """Smart Money resource for tracking labeled smart money wallets (async).""" + async def netflow( self, *, @@ -140,6 +192,14 @@ async def netflow( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyNetflowItem]: + """Get smart money netflow data across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/netflow", body={ @@ -159,6 +219,14 @@ async def dex_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyDexTradeItem]: + """Get smart money DEX trades across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/dex-trades", body={ @@ -178,6 +246,14 @@ async def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyPerpTradeItem]: + """Get smart money perpetual futures trades. + + Args: + filters: Field-level filters to narrow results. + only_new_positions: If ``True``, only return trades that open new positions. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/perp-trades", body={ @@ -196,6 +272,13 @@ async def dcas( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyDcaItem]: + """Get smart money DCA orders. + + Args: + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/dcas", body={ @@ -214,6 +297,14 @@ async def holdings( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyHoldingItem]: + """Get current smart money holdings across chains. + + Args: + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/holdings", body={ @@ -234,6 +325,15 @@ async def historical_holdings( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[SmartMoneyHistoricalHoldingItem]: + """Get historical smart money holdings across chains. + + Args: + date_range: Date range with ``"from"`` and ``"to"`` keys. + chains: List of chain identifiers (e.g. ``["ethereum"]``). + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/smart-money/historical-holdings", body={ diff --git a/src/nansen/resources/tgm.py b/src/nansen/resources/tgm.py index 24169c6..f7e32a4 100644 --- a/src/nansen/resources/tgm.py +++ b/src/nansen/resources/tgm.py @@ -25,6 +25,8 @@ class TGM(SyncAPIResource): + """Token God Mode resource for token-level analytics.""" + def token_screener( self, *, @@ -35,6 +37,17 @@ def token_screener( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TokenScreenerItem]: + """Screen tokens across one or more chains. + + Args: + chains: List of chain identifiers to screen (e.g. ``["ethereum"]``). + timeframe: Timeframe for the screener data (e.g. ``"24h"``). + date: Date range filter with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives + (e.g. ``[{"field": "volume", "direction": "desc"}]``). + """ return self._post_page( "/token-screener", body={ @@ -55,6 +68,13 @@ def token_information( token_address: str, timeframe: str, ) -> APIResponse[TokenInformationResponse]: + """Get detailed information for a specific token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + timeframe: Timeframe for the data (e.g. ``"24h"``). + """ return self._post( "/tgm/token-information", body={ @@ -73,6 +93,16 @@ def flow_intel( timeframe: str | NotGiven = NOT_GIVEN, filters: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> SyncPage[FlowIntelItem]: + """Get flow intelligence data for a token. + + Shows smart money and notable wallet flows into and out of a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + timeframe: Timeframe for the data (e.g. ``"24h"``). + filters: Field-level filters to narrow results. + """ return self._post_page( "/tgm/flow-intelligence", body={ @@ -95,6 +125,17 @@ def holders( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[HolderItem]: + """Get holder data for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + label_type: Filter holders by label type. + aggregate_by_entity: If ``True``, aggregate holdings by entity. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/holders", body={ @@ -120,6 +161,17 @@ def flows( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[FlowItem]: + """Get token flow data within a date range. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + label: Filter flows by wallet label. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/flows", body={ @@ -145,6 +197,17 @@ def who_bought_sold( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[WhoBoughtSoldItem]: + """Get buy/sell activity for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + buy_or_sell: Filter by ``"buy"`` or ``"sell"`` side. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/who-bought-sold", body={ @@ -170,6 +233,17 @@ def dex_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TgmDexTradeItem]: + """Get DEX trade history for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + only_smart_money: If ``True``, only return trades from smart money wallets. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/dex-trades", body={ @@ -194,6 +268,16 @@ def transfers( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TransferItem]: + """Get transfer history for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/transfers", body={ @@ -214,6 +298,13 @@ def dcas( filters: dict[str, Any] | NotGiven = NOT_GIVEN, pagination: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> SyncPage[TgmDcaItem]: + """Get Jupiter DCA orders for a token (Solana only). + + Args: + token_address: Token mint address. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + """ return self._post_page( "/tgm/jup-dca", body={ @@ -234,6 +325,16 @@ def pnl_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[PnlLeaderboardItem]: + """Get the PnL leaderboard for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/pnl-leaderboard", body={ @@ -255,6 +356,14 @@ def perp_screener( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[PerpScreenerItem]: + """Screen perpetual futures contracts. + + Args: + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/perp-screener", body={ @@ -275,6 +384,15 @@ def perp_pnl_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[PerpPnlLeaderboardItem]: + """Get the perpetual futures PnL leaderboard for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/perp-pnl-leaderboard", body={ @@ -296,6 +414,15 @@ def perp_positions( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TgmPerpPositionItem]: + """Get open perpetual futures positions for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + label_type: Filter positions by wallet label type. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/perp-positions", body={ @@ -317,6 +444,15 @@ def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> SyncPage[TgmPerpTradeItem]: + """Get perpetual futures trade history for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return self._post_page( "/tgm/perp-trades", body={ @@ -331,6 +467,8 @@ def perp_trades( class AsyncTGM(AsyncAPIResource): + """Token God Mode resource for token-level analytics (async).""" + async def token_screener( self, *, @@ -341,6 +479,17 @@ async def token_screener( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TokenScreenerItem]: + """Screen tokens across one or more chains. + + Args: + chains: List of chain identifiers to screen (e.g. ``["ethereum"]``). + timeframe: Timeframe for the screener data (e.g. ``"24h"``). + date: Date range filter with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives + (e.g. ``[{"field": "volume", "direction": "desc"}]``). + """ return await self._post_page( "/token-screener", body={ @@ -361,6 +510,13 @@ async def token_information( token_address: str, timeframe: str, ) -> APIResponse[TokenInformationResponse]: + """Get detailed information for a specific token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + timeframe: Timeframe for the data (e.g. ``"24h"``). + """ return await self._post( "/tgm/token-information", body={ @@ -379,6 +535,16 @@ async def flow_intel( timeframe: str | NotGiven = NOT_GIVEN, filters: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> AsyncPage[FlowIntelItem]: + """Get flow intelligence data for a token. + + Shows smart money and notable wallet flows into and out of a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + timeframe: Timeframe for the data (e.g. ``"24h"``). + filters: Field-level filters to narrow results. + """ return await self._post_page( "/tgm/flow-intelligence", body={ @@ -401,6 +567,17 @@ async def holders( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[HolderItem]: + """Get holder data for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + label_type: Filter holders by label type. + aggregate_by_entity: If ``True``, aggregate holdings by entity. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/holders", body={ @@ -426,6 +603,17 @@ async def flows( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[FlowItem]: + """Get token flow data within a date range. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + label: Filter flows by wallet label. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/flows", body={ @@ -451,6 +639,17 @@ async def who_bought_sold( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[WhoBoughtSoldItem]: + """Get buy/sell activity for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + buy_or_sell: Filter by ``"buy"`` or ``"sell"`` side. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/who-bought-sold", body={ @@ -476,6 +675,17 @@ async def dex_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TgmDexTradeItem]: + """Get DEX trade history for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + only_smart_money: If ``True``, only return trades from smart money wallets. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/dex-trades", body={ @@ -500,6 +710,16 @@ async def transfers( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TransferItem]: + """Get transfer history for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/transfers", body={ @@ -520,6 +740,13 @@ async def dcas( filters: dict[str, Any] | NotGiven = NOT_GIVEN, pagination: dict[str, Any] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TgmDcaItem]: + """Get Jupiter DCA orders for a token (Solana only). + + Args: + token_address: Token mint address. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + """ return await self._post_page( "/tgm/jup-dca", body={ @@ -540,6 +767,16 @@ async def pnl_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[PnlLeaderboardItem]: + """Get the PnL leaderboard for a token. + + Args: + chain: Chain identifier (e.g. ``"ethereum"``). + token_address: Contract address of the token. + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/pnl-leaderboard", body={ @@ -561,6 +798,14 @@ async def perp_screener( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[PerpScreenerItem]: + """Screen perpetual futures contracts. + + Args: + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/perp-screener", body={ @@ -581,6 +826,15 @@ async def perp_pnl_leaderboard( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[PerpPnlLeaderboardItem]: + """Get the perpetual futures PnL leaderboard for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/perp-pnl-leaderboard", body={ @@ -602,6 +856,15 @@ async def perp_positions( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TgmPerpPositionItem]: + """Get open perpetual futures positions for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + label_type: Filter positions by wallet label type. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/perp-positions", body={ @@ -623,6 +886,15 @@ async def perp_trades( pagination: dict[str, Any] | NotGiven = NOT_GIVEN, order_by: list[dict[str, str]] | NotGiven = NOT_GIVEN, ) -> AsyncPage[TgmPerpTradeItem]: + """Get perpetual futures trade history for a token. + + Args: + token_symbol: Token ticker symbol (e.g. ``"BTC"``). + date: Date range with ``"from"`` and ``"to"`` keys. + filters: Field-level filters to narrow results. + pagination: Pagination options (``page``, ``per_page``). + order_by: List of ordering directives. + """ return await self._post_page( "/tgm/perp-trades", body={