Skip to content

Interaction

cyhole.solscan.v2.Solscan

Solscan(api_key: str | None = None)

Bases: Interaction

Class used to connect only Solscan V2 API, one of them most popular Solana chain explorer. To have access Solscan Pro API is required to have a valid API key.

Check API Documentation for all the details on the available endpoints.

Solscan API is currently divided into two versions:

  • v1 - the first and classic version of the Pro API.
  • v2 - a new and improved version of the Pro API, with more endpoints and features. This version is under development and may have some changes.

Info

This Interaction is dedicated to the Solscan Pro API v2.0. Use cyhole.solscan.SolscanV1 or cyhole.solscan.v1.Solscan for the Solscan Pro API v1.0. If the API key is not provided during the object creation, then it is automatically retrieved from environment variable SOLSCAN_API_V2_KEY.

Parameters:

Name Type Description Default
api_key str | None

specifies the API key for Solscan Pro API v2.

None

Example

Source code in src/cyhole/solscan/v2/interaction.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def __init__(self, api_key: str | None = None) -> None:

    # set API
    self.api_key = api_key if api_key is not None else os.environ.get("SOLSCAN_API_V2_KEY")
    if self.api_key is None:
        raise MissingAPIKeyError("no API key is provided during object's creation.")

    # headers setup
    headers = {
        "token": self.api_key
    }
    super().__init__(headers)
    self.headers: dict[str, str]

    # clients
    self.client = SolscanClient(self, headers = self.headers)
    self.async_client = SolscanAsyncClient(self, headers = self.headers)

    # API urls
    self.base_url = "https://pro-api.solscan.io/v2.0/"

    # private attributes
    self._name = "Solscan V2 API"
    self._description = "Interact with Solscan API V2"
    return

_get_account_transfers

_get_account_transfers(
    sync: Literal[True],
    account: str,
    params: GetAccountTransferParam = GetAccountTransferParam(),
) -> GetAccountTransferResponse
_get_account_transfers(
    sync: Literal[False],
    account: str,
    params: GetAccountTransferParam = GetAccountTransferParam(),
) -> Coroutine[None, None, GetAccountTransferResponse]
_get_account_transfers(
    sync: bool,
    account: str,
    params: GetAccountTransferParam = GetAccountTransferParam(),
) -> (
    GetAccountTransferResponse
    | Coroutine[None, None, GetAccountTransferResponse]
)

This function refers to the GET Account Transfer of V2 API endpoint, and it is used to get transfers of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountTransferParam

The parameters to be used in the request. More details in the object definition.

GetAccountTransferParam()

Returns:

Type Description
GetAccountTransferResponse | Coroutine[None, None, GetAccountTransferResponse]

List of transfers of the account.

Source code in src/cyhole/solscan/v2/interaction.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def _get_account_transfers(self, sync: bool, account: str, params: GetAccountTransferParam = GetAccountTransferParam()) -> GetAccountTransferResponse | Coroutine[None, None, GetAccountTransferResponse]:
    """
        This function refers to the GET **[Account Transfer](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-transfer)** of **V2** API endpoint, 
        and it is used to get transfers of an account.

        Parameters:
            account: The account address.
            params: The parameters to be used in the request.
                More details in the object definition.

        Returns:
            List of transfers of the account.
    """
    # set params
    url = self.base_url + "account/transfer"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )
    api_params["address"] = account

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountTransferResponse,
        params = api_params
    )

_get_account_token_nft_account

_get_account_token_nft_account(
    sync: Literal[True],
    account: str,
    account_type: str,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
    hide_zero: bool = True,
) -> GetAccountTokenNFTAccountResponse
_get_account_token_nft_account(
    sync: Literal[False],
    account: str,
    account_type: str,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
    hide_zero: bool = True,
) -> Coroutine[
    None, None, GetAccountTokenNFTAccountResponse
]
_get_account_token_nft_account(
    sync: bool,
    account: str,
    account_type: str,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
    hide_zero: bool = True,
) -> (
    GetAccountTokenNFTAccountResponse
    | Coroutine[
        None, None, GetAccountTokenNFTAccountResponse
    ]
)

This function refers to the GET Account Token/NFT Account of V2 API endpoint, and it is used to get the NFT/Tokens' accounts of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
account_type str

The account type (NFT/Token). The supported types are available on SolscanAccountType.

required
page int

The page number.

1
page_size int

The number of accounts per page. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value
hide_zero bool

Hide zero balances accounts.

True

Returns:

Type Description
GetAccountTokenNFTAccountResponse | Coroutine[None, None, GetAccountTokenNFTAccountResponse]

List of NFT/Tokens accountS.

Source code in src/cyhole/solscan/v2/interaction.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
def _get_account_token_nft_account(
    self,
    sync: bool,
    account: str,
    account_type: str,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
    hide_zero: bool = True
) -> GetAccountTokenNFTAccountResponse | Coroutine[None, None, GetAccountTokenNFTAccountResponse]:
    """
        This function refers to the GET **[Account Token/NFT Account](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-token-nft-account)** of **V2** API endpoint, 
        and it is used to get the NFT/Tokens' accounts of an account.

        Parameters:
            account: The account address.
            account_type: The account type (NFT/Token).
                The supported types are available on [`SolscanAccountType`][cyhole.solscan.v2.param.SolscanAccountType].
            page: The page number.
            page_size: The number of accounts per page.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].
            hide_zero: Hide zero balances accounts.

        Returns:
            List of NFT/Tokens accountS.
    """
    # check param consistency
    SolscanAccountType.check(account_type)
    SolscanPageSizeType.check(page_size)

    # set params
    url = self.base_url + "account/token-accounts"
    api_params = {
        "address": account,
        "type": account_type,
        "page": page,
        "page_size": page_size,
        "hide_zero": "true" if hide_zero else "false"
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountTokenNFTAccountResponse,
        params = api_params
    )

_get_account_defi_activities

_get_account_defi_activities(
    sync: Literal[True],
    account: str,
    params: GetAccountDefiActivitiesParam = GetAccountDefiActivitiesParam(),
) -> GetAccountDefiActivitiesResponse
_get_account_defi_activities(
    sync: Literal[False],
    account: str,
    params: GetAccountDefiActivitiesParam = GetAccountDefiActivitiesParam(),
) -> Coroutine[
    None, None, GetAccountDefiActivitiesResponse
]
_get_account_defi_activities(
    sync: bool,
    account: str,
    params: GetAccountDefiActivitiesParam = GetAccountDefiActivitiesParam(),
) -> (
    GetAccountDefiActivitiesResponse
    | Coroutine[
        None, None, GetAccountDefiActivitiesResponse
    ]
)

This function refers to the GET Account DeFi Activities of V2 API endpoint, and it is used to get the DeFi activities of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountDefiActivitiesParam

The parameters to be used in the request.

GetAccountDefiActivitiesParam()

Returns:

Type Description
GetAccountDefiActivitiesResponse | Coroutine[None, None, GetAccountDefiActivitiesResponse]

List of DeFi activities.

Source code in src/cyhole/solscan/v2/interaction.py
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
def _get_account_defi_activities(self, sync: bool, account: str, params: GetAccountDefiActivitiesParam = GetAccountDefiActivitiesParam()) -> GetAccountDefiActivitiesResponse | Coroutine[None, None, GetAccountDefiActivitiesResponse]:
    """
        This function refers to the GET **[Account DeFi Activities](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-defi-activities)** of **V2** API endpoint, 
        and it is used to get the DeFi activities of an account.

        Parameters:
            account: The account address.
            params: The parameters to be used in the request.

        Returns:
            List of DeFi activities.
    """
    # set params
    url = self.base_url + "account/defi/activities"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )
    api_params["address"] = account

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountDefiActivitiesResponse,
        params = api_params
    )

_get_account_balance_change_activities

_get_account_balance_change_activities(
    sync: Literal[True],
    account: str,
    params: GetAccountBalanceChangeActivitiesParam = GetAccountBalanceChangeActivitiesParam(),
) -> GetAccountBalanceChangeActivitiesResponse
_get_account_balance_change_activities(
    sync: Literal[False],
    account: str,
    params: GetAccountBalanceChangeActivitiesParam = GetAccountBalanceChangeActivitiesParam(),
) -> Coroutine[
    None, None, GetAccountBalanceChangeActivitiesResponse
]
_get_account_balance_change_activities(
    sync: bool,
    account: str,
    params: GetAccountBalanceChangeActivitiesParam = GetAccountBalanceChangeActivitiesParam(),
) -> (
    GetAccountBalanceChangeActivitiesResponse
    | Coroutine[
        None,
        None,
        GetAccountBalanceChangeActivitiesResponse,
    ]
)

This function refers to the GET Account Balance Change Activities of V2 API endpoint, and it is used to get the balance change activities of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountBalanceChangeActivitiesParam

The parameters to be used in the request.

GetAccountBalanceChangeActivitiesParam()

Returns:

Type Description
GetAccountBalanceChangeActivitiesResponse | Coroutine[None, None, GetAccountBalanceChangeActivitiesResponse]

List of balance change activities.

Source code in src/cyhole/solscan/v2/interaction.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
def _get_account_balance_change_activities(self, sync: bool, account: str, params: GetAccountBalanceChangeActivitiesParam = GetAccountBalanceChangeActivitiesParam()) -> GetAccountBalanceChangeActivitiesResponse | Coroutine[None, None, GetAccountBalanceChangeActivitiesResponse]:
    """
        This function refers to the GET **[Account Balance Change Activities](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-balance_change)** of **V2** API endpoint, 
        and it is used to get the balance change activities of an account.

        Parameters:
            account: The account address.
            params: The parameters to be used in the request.

        Returns:
            List of balance change activities.
    """
    # set params
    url = self.base_url + "account/balance_change"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )
    api_params["address"] = account

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountBalanceChangeActivitiesResponse,
        params = api_params
    )

_get_account_transactions

_get_account_transactions(
    sync: Literal[True],
    account: str,
    before_transaction: str | None = None,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> GetAccountTransactionsResponse
_get_account_transactions(
    sync: Literal[False],
    account: str,
    before_transaction: str | None = None,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> Coroutine[None, None, GetAccountTransactionsResponse]
_get_account_transactions(
    sync: bool,
    account: str,
    before_transaction: str | None = None,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> (
    GetAccountTransactionsResponse
    | Coroutine[None, None, GetAccountTransactionsResponse]
)

This function refers to the GET Account Transactions of V2 API endpoint, and it is used to get the latest transactions of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
before_transaction str | None

The signature of the latest transaction of previous page.

None
limit int

The number of transactions to be returned. The supported types are available on SolscanReturnLimitType.

SolscanReturnLimitType.LIMIT_10.value

Returns:

Type Description
GetAccountTransactionsResponse | Coroutine[None, None, GetAccountTransactionsResponse]

List of transactions of the account.

Source code in src/cyhole/solscan/v2/interaction.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
def _get_account_transactions(self, sync: bool, account: str, before_transaction: str | None = None, limit: int = SolscanReturnLimitType.LIMIT_10.value) -> GetAccountTransactionsResponse | Coroutine[None, None, GetAccountTransactionsResponse]:
    """
        This function refers to the GET **[Account Transactions](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-transactions)** of **V2** API endpoint, 
        and it is used to get the latest transactions of an account.

        Parameters:
            account: The account address.
            before_transaction: The signature of the latest transaction of previous page.
            limit: The number of transactions to be returned.
                The supported types are available on [`SolscanReturnLimitType`][cyhole.solscan.v2.param.SolscanReturnLimitType].

        Returns:
            List of transactions of the account.
    """
    # check param consistency
    SolscanReturnLimitType.check(limit)

    # set params
    url = self.base_url + "account/transactions"
    api_params = {
        "address": account,
        "before": before_transaction,
        "limit": limit
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountTransactionsResponse,
        params = api_params
    )

_get_account_stake

_get_account_stake(
    sync: Literal[True],
    account: str,
    page: int = 1,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> GetAccountStakeResponse
_get_account_stake(
    sync: Literal[False],
    account: str,
    page: int = 1,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> Coroutine[None, None, GetAccountStakeResponse]
_get_account_stake(
    sync: bool,
    account: str,
    page: int = 1,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
) -> (
    GetAccountStakeResponse
    | Coroutine[None, None, GetAccountStakeResponse]
)

This function refers to the GET Account Stake of V2 API endpoint, and it is used to get the staking activities of an account.

Parameters:

Name Type Description Default
account str

The account address.

required
page int

The page number.

1
limit int

The number of staking activities to be returned. The supported types are available on SolscanReturnLimitType.

SolscanReturnLimitType.LIMIT_10.value

Returns:

Type Description
GetAccountStakeResponse | Coroutine[None, None, GetAccountStakeResponse]

List of staking activities of the account.

Source code in src/cyhole/solscan/v2/interaction.py
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
def _get_account_stake(self, sync: bool, account: str, page: int = 1, limit: int = SolscanReturnLimitType.LIMIT_10.value) -> GetAccountStakeResponse | Coroutine[None, None, GetAccountStakeResponse]:
    """
        This function refers to the GET **[Account Stake](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-stake)** of **V2** API endpoint, 
        and it is used to get the staking activities of an account.

        Parameters:
            account: The account address.
            page: The page number.
            limit: The number of staking activities to be returned.
                The supported types are available on [`SolscanReturnLimitType`][cyhole.solscan.v2.param.SolscanReturnLimitType].

        Returns:
            List of staking activities of the account.
    """
    # check param consistency
    SolscanReturnLimitType.check(limit)

    # set params
    url = self.base_url + "account/stake"
    api_params = {
        "address": account,
        "page": page,
        "page_size": limit
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountStakeResponse,
        params = api_params
    )

_get_account_detail

_get_account_detail(
    sync: Literal[True], account: str
) -> GetAccountDetailResponse
_get_account_detail(
    sync: Literal[False], account: str
) -> Coroutine[None, None, GetAccountDetailResponse]
_get_account_detail(
    sync: bool, account: str
) -> (
    GetAccountDetailResponse
    | Coroutine[None, None, GetAccountDetailResponse]
)

This function refers to the GET Account Detail of V2 API endpoint, and it is used to get the detail of an account.

Parameters:

Name Type Description Default
account str

The account address.

required

Returns:

Type Description
GetAccountDetailResponse | Coroutine[None, None, GetAccountDetailResponse]

Detail of the account.

Source code in src/cyhole/solscan/v2/interaction.py
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
def _get_account_detail(self, sync: bool, account: str) -> GetAccountDetailResponse | Coroutine[None, None, GetAccountDetailResponse]:
    """
        This function refers to the GET **[Account Detail](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-detail)** of **V2** API endpoint, 
        and it is used to get the detail of an account.

        Parameters:
            account: The account address.

        Returns:
            Detail of the account.
    """
    # set params
    url = self.base_url + "account/detail"
    api_params = {
        "address": account
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetAccountDetailResponse,
        params = api_params
    )

_get_account_rewards_export

_get_account_rewards_export(
    sync: Literal[True],
    account: str,
    dt_from: datetime,
    dt_to: datetime,
) -> GetAccountRewardsExportResponse
_get_account_rewards_export(
    sync: Literal[False],
    account: str,
    dt_from: datetime,
    dt_to: datetime,
) -> Coroutine[None, None, GetAccountRewardsExportResponse]
_get_account_rewards_export(
    sync: bool,
    account: str,
    dt_from: datetime,
    dt_to: datetime,
) -> (
    GetAccountRewardsExportResponse
    | Coroutine[None, None, GetAccountRewardsExportResponse]
)

This function refers to the GET Account Rewards Export of V2 API endpoint, and it is used to get export rewards of an account in CSV format.

Info

The limit of the export rewards is 5000 for request. Moreover, it is possible to execute the request only 1 time for every minute.

Parameters:

Name Type Description Default
account str

The account address.

required
dt_from datetime

The start time.

required
dt_to datetime

The end time.

required

Returns:

Type Description
GetAccountRewardsExportResponse | Coroutine[None, None, GetAccountRewardsExportResponse]

List of export rewards of the account.

Source code in src/cyhole/solscan/v2/interaction.py
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
def _get_account_rewards_export(self, sync: bool, account: str, dt_from: datetime, dt_to: datetime) -> GetAccountRewardsExportResponse | Coroutine[None, None, GetAccountRewardsExportResponse]:
    """
        This function refers to the GET **[Account Rewards Export](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-account-reward-export)** of **V2** API endpoint, 
        and it is used to get export rewards of an account in CSV format.

        !!! info
            The limit of the export rewards is 5000 for request. 
            Moreover, it is possible to execute the request **only** 1 time for every minute.

        Parameters:
            account: The account address.
            dt_from: The start time.
            dt_to: The end time.

        Returns:
            List of export rewards of the account.
    """

    # set params
    url = self.base_url + "account/reward/export"
    api_params = {
        "address": account,
        "time_from": int(dt_from.timestamp()),
        "time_to": int(dt_to.timestamp())
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url, params = api_params)
        return GetAccountRewardsExportResponse(csv = content_raw.text)
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url, params = api_params)
            return GetAccountRewardsExportResponse(csv = content_raw.text)
        return async_request()

_get_token_transfer

_get_token_transfer(
    sync: Literal[True],
    token: str,
    params: GetTokenTransferParam = GetTokenTransferParam(),
) -> GetTokenTransferResponse
_get_token_transfer(
    sync: Literal[False],
    token: str,
    params: GetTokenTransferParam = GetTokenTransferParam(),
) -> Coroutine[None, None, GetTokenTransferResponse]
_get_token_transfer(
    sync: bool,
    token: str,
    params: GetTokenTransferParam = GetTokenTransferParam(),
) -> (
    GetTokenTransferResponse
    | Coroutine[None, None, GetTokenTransferResponse]
)

This function refers to the GET Token Transfer of V2 API endpoint, and it is used to get transfers of a token.

Parameters:

Name Type Description Default
token str

The token address.

required
params GetTokenTransferParam

The parameters to be used in the request. More details in the object definition.

GetTokenTransferParam()

Returns:

Type Description
GetTokenTransferResponse | Coroutine[None, None, GetTokenTransferResponse]

List of transfers of the token.

Source code in src/cyhole/solscan/v2/interaction.py
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
def _get_token_transfer(self, sync: bool, token: str, params: GetTokenTransferParam = GetTokenTransferParam()) -> GetTokenTransferResponse | Coroutine[None, None, GetTokenTransferResponse]:
    """
        This function refers to the GET **[Token Transfer](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-transfer)** of **V2** API endpoint, 
        and it is used to get transfers of a token.

        Parameters:
            token: The token address.
            params: The parameters to be used in the request.
                More details in the object definition.

        Returns:
            List of transfers of the token.
    """
    # set params
    url = self.base_url + "token/transfer"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )
    api_params["address"] = token

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenTransferResponse,
        params = api_params
    )

_get_token_defi_activities

_get_token_defi_activities(
    sync: Literal[True],
    token: str,
    params: GetTokenDefiActivitiesParam = GetTokenDefiActivitiesParam(),
) -> GetTokenDefiActivitiesResponse
_get_token_defi_activities(
    sync: Literal[False],
    token: str,
    params: GetTokenDefiActivitiesParam = GetTokenDefiActivitiesParam(),
) -> Coroutine[None, None, GetTokenDefiActivitiesResponse]
_get_token_defi_activities(
    sync: bool,
    token: str,
    params: GetTokenDefiActivitiesParam = GetTokenDefiActivitiesParam(),
) -> (
    GetTokenDefiActivitiesResponse
    | Coroutine[None, None, GetTokenDefiActivitiesResponse]
)

This function refers to the GET Token DeFi Activities of V2 API endpoint, and it is used to get the DeFi activities of a token.

Parameters:

Name Type Description Default
token str

The token address.

required
params GetTokenDefiActivitiesParam

The parameters to be used in the request. More details in the object definition.

GetTokenDefiActivitiesParam()

Returns:

Type Description
GetTokenDefiActivitiesResponse | Coroutine[None, None, GetTokenDefiActivitiesResponse]

List of DeFi activities of the token.

Source code in src/cyhole/solscan/v2/interaction.py
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
def _get_token_defi_activities(self, sync: bool, token: str, params: GetTokenDefiActivitiesParam = GetTokenDefiActivitiesParam()) -> GetTokenDefiActivitiesResponse | Coroutine[None, None, GetTokenDefiActivitiesResponse]:
    """
        This function refers to the GET **[Token DeFi Activities](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-defi-activities)** of **V2** API endpoint, 
        and it is used to get the DeFi activities of a token.

        Parameters:
            token: The token address.
            params: The parameters to be used in the request.
                More details in the object definition.

        Returns:
            List of DeFi activities of the token.
    """
    # set params
    url = self.base_url + "token/defi/activities"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )
    api_params["address"] = token

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenDefiActivitiesResponse,
        params = api_params
    )

_get_token_markets

_get_token_markets(
    sync: Literal[True],
    tokens: str | list[str],
    program_address: str | list[str] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> GetTokenMarketsResponse
_get_token_markets(
    sync: Literal[False],
    tokens: str | list[str],
    program_address: str | list[str] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> Coroutine[None, None, GetTokenMarketsResponse]
_get_token_markets(
    sync: bool,
    tokens: str | list[str],
    program_address: str | list[str] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> (
    GetTokenMarketsResponse
    | Coroutine[None, None, GetTokenMarketsResponse]
)

This function refers to the GET Token Markets of V2 API endpoint, and it is used to get the markets data of a set of tokens.

Parameters:

Name Type Description Default
tokens str | list[str]

The token address or list of token addresses.

required
program_address str | list[str] | None

The program address or list of program addresses.

None
page int

The page number.

1
page_size int

The number of markets per page. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value

Returns:

Type Description
GetTokenMarketsResponse | Coroutine[None, None, GetTokenMarketsResponse]

List of markets of the token.

Source code in src/cyhole/solscan/v2/interaction.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
def _get_token_markets(
    self,
    sync: bool,
    tokens: str | list[str],
    program_address: str | list[str] | None  = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value
) -> GetTokenMarketsResponse | Coroutine[None, None, GetTokenMarketsResponse]:
    """
        This function refers to the GET **[Token Markets](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-markets)** of **V2** API endpoint, 
        and it is used to get the markets data of a set of tokens.

        Parameters:
            tokens: The token address or list of token addresses.
            program_address: The program address or list of program addresses.
            page: The page number.
            page_size: The number of markets per page.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].

        Returns:
            List of markets of the token.
    """
    # check param consistency
    SolscanPageSizeType.check(page_size)

    # set params
    url = self.base_url + "token/markets"
    api_params = {
        "token[]": tokens,
        "program[]": program_address,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenMarketsResponse,
        params = api_params
    )

_get_token_list

_get_token_list(
    sync: Literal[True],
    sort_by: str = SolscanSortType.MARKET_CAP.value,
    order_by: str = SolscanOrderType.DESCENDING.value,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> GetTokenListResponse
_get_token_list(
    sync: Literal[False],
    sort_by: str = SolscanSortType.MARKET_CAP.value,
    order_by: str = SolscanOrderType.DESCENDING.value,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> Coroutine[None, None, GetTokenListResponse]
_get_token_list(
    sync: bool,
    sort_by: str = SolscanSortType.MARKET_CAP.value,
    order_by: str = SolscanOrderType.DESCENDING.value,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> (
    GetTokenListResponse
    | Coroutine[None, None, GetTokenListResponse]
)

This function refers to the GET Token List of V2 API endpoint, and it is used to get the list of tokens.

Parameters:

Name Type Description Default
sort_by str

The sorting method. The supported types are available on SolscanSortType.

SolscanSortType.MARKET_CAP.value
order_by str

The ordering to get the response. The supported types are available on SolscanOrderType.

SolscanOrderType.DESCENDING.value
page int

The page number.

1
page_size int

The number of tokens per page. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value

Returns:

Type Description
GetTokenListResponse | Coroutine[None, None, GetTokenListResponse]

List of tokens.

Source code in src/cyhole/solscan/v2/interaction.py
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def _get_token_list(
    self,
    sync: bool,
    sort_by: str = SolscanSortType.MARKET_CAP.value,
    order_by: str = SolscanOrderType.DESCENDING.value,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value
) -> GetTokenListResponse | Coroutine[None, None, GetTokenListResponse]:
    """
        This function refers to the GET **[Token List](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-list)** of **V2** API endpoint, 
        and it is used to get the list of tokens.

        Parameters:
            sort_by: The sorting method.
                The supported types are available on [`SolscanSortType`][cyhole.solscan.v2.param.SolscanSortType].
            order_by: The ordering to get the response.
                The supported types are available on [`SolscanOrderType`][cyhole.solscan.v2.param.SolscanOrderType].
            page: The page number.
            page_size: The number of tokens per page.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].

        Returns:
            List of tokens.
    """
    # check param consistency
    SolscanSortType.check(sort_by)
    SolscanOrderType.check(order_by)
    SolscanPageSizeType.check(page_size)

    # set params
    url = self.base_url + "token/list"
    api_params = {
        "sort_by": sort_by,
        "sort_order": order_by,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenListResponse,
        params = api_params
    )
_get_token_trending(
    sync: Literal[True], limit: int = 10
) -> GetTokenTrendingResponse
_get_token_trending(
    sync: Literal[False], limit: int = 10
) -> Coroutine[None, None, GetTokenTrendingResponse]
_get_token_trending(
    sync: bool, limit: int = 10
) -> (
    GetTokenTrendingResponse
    | Coroutine[None, None, GetTokenTrendingResponse]
)

This function refers to the GET Token Trending of V2 API endpoint, and it is used to get the trending tokens on Solscan.

Parameters:

Name Type Description Default
limit int

The number of trending tokens to be returned.

10

Returns:

Type Description
GetTokenTrendingResponse | Coroutine[None, None, GetTokenTrendingResponse]

List of trending tokens.

Source code in src/cyhole/solscan/v2/interaction.py
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
def _get_token_trending(self, sync: bool, limit: int = 10) -> GetTokenTrendingResponse | Coroutine[None, None, GetTokenTrendingResponse]:
    """
        This function refers to the GET **[Token Trending](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-trending)** of **V2** API endpoint, 
        and it is used to get the trending tokens on Solscan.

        Parameters:
            limit: The number of trending tokens to be returned.

        Returns:
            List of trending tokens.
    """

    # set params
    url = self.base_url + "token/trending"
    api_params = {
        "limit": limit
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenTrendingResponse,
        params = api_params
    )

_get_token_price

_get_token_price(
    sync: Literal[True],
    token: str,
    time_range: (
        datetime | tuple[datetime, datetime]
    ) = datetime.now(),
) -> GetTokenPriceResponse
_get_token_price(
    sync: Literal[False],
    token: str,
    time_range: (
        datetime | tuple[datetime, datetime]
    ) = datetime.now(),
) -> Coroutine[None, None, GetTokenPriceResponse]
_get_token_price(
    sync: bool,
    token: str,
    time_range: (
        datetime | tuple[datetime, datetime]
    ) = datetime.now(),
) -> (
    GetTokenPriceResponse
    | Coroutine[None, None, GetTokenPriceResponse]
)

This function refers to the GET Token Price of V2 API endpoint, and it is used to get the price of a token.

Parameters:

Name Type Description Default
token str

The token address.

required
time_range datetime | tuple[datetime, datetime]

The time range. It can be a single datetime object or a tuple of two datetime objects.

datetime.now()

Returns:

Type Description
GetTokenPriceResponse | Coroutine[None, None, GetTokenPriceResponse]

Price of the token.

Source code in src/cyhole/solscan/v2/interaction.py
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
def _get_token_price(self, sync: bool, token: str, time_range: datetime | tuple[datetime, datetime] = datetime.now()) -> GetTokenPriceResponse | Coroutine[None, None, GetTokenPriceResponse]:
    """
        This function refers to the GET **[Token Price](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-price)** of **V2** API endpoint, 
        and it is used to get the price of a token.

        Parameters:
            token: The token address.
            time_range: The time range.
                It can be a single datetime object or a tuple of two datetime objects.

        Returns:
            Price of the token.
    """
    # check consistency and convert to string
    time_range_str: list[str]
    if isinstance(time_range, tuple):
        # check consistency
        if time_range[0] > time_range[1]:
            raise SolscanInvalidTimeRange("the start time is greater than the end time.")
        # convert to string
        time_range_str = [time_range[0].strftime("%Y%m%d"), time_range[1].strftime("%Y%m%d")]
    else:
        time_range_str = [time_range.strftime("%Y%m%d")]

    # set params
    url = self.base_url + "token/price"
    api_params = {
        "address": token,
        "time[]": time_range_str
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenPriceResponse,
        params = api_params
    )

_get_token_holders

_get_token_holders(
    sync: Literal[True],
    token: str,
    amount_range: tuple[int, int] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> GetTokenHoldersResponse
_get_token_holders(
    sync: Literal[False],
    token: str,
    amount_range: tuple[int, int] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> Coroutine[None, None, GetTokenHoldersResponse]
_get_token_holders(
    sync: bool,
    token: str,
    amount_range: tuple[int, int] | None = None,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> (
    GetTokenHoldersResponse
    | Coroutine[None, None, GetTokenHoldersResponse]
)

This function refers to the GET Token Holders of V2 API endpoint, and it is used to get the holders of a token.

Parameters:

Name Type Description Default
token str

The token address.

required
amount_range tuple[int, int] | None

The amount range. It can be a tuple of two integers (from, to).

None
page int

The page number.

1
page_size int

The number of holders per page. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value

Returns:

Type Description
GetTokenHoldersResponse | Coroutine[None, None, GetTokenHoldersResponse]

List of holders of the token.

Source code in src/cyhole/solscan/v2/interaction.py
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
def _get_token_holders(self, sync: bool, token: str, amount_range: tuple[int, int] | None = None, page: int = 1, page_size: int = SolscanPageSizeType.SIZE_10.value) -> GetTokenHoldersResponse | Coroutine[None, None, GetTokenHoldersResponse]:
    """
        This function refers to the GET **[Token Holders](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-holders)** of **V2** API endpoint, 
        and it is used to get the holders of a token.

        Parameters:
            token: The token address.
            amount_range: The amount range.
                It can be a tuple of two integers (from, to).
            page: The page number.
            page_size: The number of holders per page.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].

        Returns:
            List of holders of the token.
    """
    from_amount = None
    to_amount = None

    # check param consistency
    SolscanPageSizeType.check(page_size)

    if amount_range:
        if amount_range[0] > amount_range[1]:
            raise SolscanInvalidAmountRange("The start amount is greater than the end amount.")

        from_amount = str(amount_range[0])
        to_amount = str(amount_range[1])

    # set params
    url = self.base_url + "token/holders"
    api_params = {
        "address": token,
        "from_amount": from_amount,
        "to_amount": to_amount,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenHoldersResponse,
        params = api_params
    )

_get_token_meta

_get_token_meta(
    sync: Literal[True], token: str
) -> GetTokenMetaResponse
_get_token_meta(
    sync: Literal[False], token: str
) -> Coroutine[None, None, GetTokenMetaResponse]
_get_token_meta(
    sync: bool, token: str
) -> (
    GetTokenMetaResponse
    | Coroutine[None, None, GetTokenMetaResponse]
)

This function refers to the GET Token Meta of V2 API endpoint, and it is used to get the metadata of a token.

Parameters:

Name Type Description Default
token str

The token address.

required

Returns:

Type Description
GetTokenMetaResponse | Coroutine[None, None, GetTokenMetaResponse]

Metadata of the token.

Source code in src/cyhole/solscan/v2/interaction.py
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
def _get_token_meta(self, sync: bool, token: str) -> GetTokenMetaResponse | Coroutine[None, None, GetTokenMetaResponse]:
    """
        This function refers to the GET **[Token Meta](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-token-meta)** of **V2** API endpoint, 
        and it is used to get the metadata of a token.

        Parameters:
            token: The token address.

        Returns:
            Metadata of the token.
    """
    # set params
    url = self.base_url + "token/meta"
    api_params = {
        "address": token
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTokenMetaResponse,
        params = api_params
    )

_get_nft_news

_get_nft_news(
    sync: Literal[True],
    filter: str = "created_time",
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> GetNFTNewsResponse
_get_nft_news(
    sync: Literal[False],
    filter: str = "created_time",
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> Coroutine[None, None, GetNFTNewsResponse]
_get_nft_news(
    sync: bool,
    filter: str = "created_time",
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> (
    GetNFTNewsResponse
    | Coroutine[None, None, GetNFTNewsResponse]
)

This function refers to the GET NFT News of V2 API endpoint, and it is used to get the latest NFT news.

Parameters:

Name Type Description Default
filter str

The filter to be used.

'created_time'
page int

The page number.

1
page_size int

The number of NFT per page. The supported types are available on SolscanNFTPageSizeType.

SolscanNFTPageSizeType.SIZE_12.value

Returns:

Type Description
GetNFTNewsResponse | Coroutine[None, None, GetNFTNewsResponse]

List of NFT news.

Source code in src/cyhole/solscan/v2/interaction.py
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
def _get_nft_news(self, sync: bool, filter: str = "created_time", page: int = 1, page_size: int = SolscanNFTPageSizeType.SIZE_12.value) -> GetNFTNewsResponse | Coroutine[None, None, GetNFTNewsResponse]:
    """
        This function refers to the GET **[NFT News](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-nft-news)** of **V2** API endpoint, 
        and it is used to get the latest NFT news.

        Parameters:
            filter: The filter to be used.
            page: The page number.
            page_size: The number of NFT per page.
                The supported types are available on [`SolscanNFTPageSizeType`][cyhole.solscan.v2.param.SolscanNFTPageSizeType].

        Returns:
            List of NFT news.
    """
    # check param consistency
    SolscanNFTPageSizeType.check(page_size)

    # set params
    url = self.base_url + "nft/news"
    api_params = {
        "filter": filter,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetNFTNewsResponse,
        params = api_params
    )

_get_nft_activities

_get_nft_activities(
    sync: Literal[True],
    params: GetNFTActivitiesParam = GetNFTActivitiesParam(),
) -> GetNFTActivitiesResponse
_get_nft_activities(
    sync: Literal[False],
    params: GetNFTActivitiesParam = GetNFTActivitiesParam(),
) -> Coroutine[None, None, GetNFTActivitiesResponse]
_get_nft_activities(
    sync: bool,
    params: GetNFTActivitiesParam = GetNFTActivitiesParam(),
) -> (
    GetNFTActivitiesResponse
    | Coroutine[None, None, GetNFTActivitiesResponse]
)

This function refers to the GET NFT Activities of V2 API endpoint, and it is used to get the NFT activities.

Parameters:

Name Type Description Default
params GetNFTActivitiesParam

The parameters to be used in the request. More details in the object definition.

GetNFTActivitiesParam()

Returns:

Type Description
GetNFTActivitiesResponse | Coroutine[None, None, GetNFTActivitiesResponse]

List of NFT activities.

Source code in src/cyhole/solscan/v2/interaction.py
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
def _get_nft_activities(self, sync: bool, params: GetNFTActivitiesParam = GetNFTActivitiesParam()) -> GetNFTActivitiesResponse | Coroutine[None, None, GetNFTActivitiesResponse]:
    """
        This function refers to the GET **[NFT Activities](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-nft-activities)** of **V2** API endpoint, 
        and it is used to get the NFT activities.

        Parameters:
            params: The parameters to be used in the request.
                More details in the object definition.

        Returns:
            List of NFT activities.
    """
    # set params
    url = self.base_url + "nft/activities"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetNFTActivitiesResponse,
        params = api_params
    )

_get_nft_collection_lists

_get_nft_collection_lists(
    sync: Literal[True],
    params: GetNFTCollectionListsParam = GetNFTCollectionListsParam(),
) -> GetNFTCollectionListsResponse
_get_nft_collection_lists(
    sync: Literal[False],
    params: GetNFTCollectionListsParam = GetNFTCollectionListsParam(),
) -> Coroutine[None, None, GetNFTCollectionListsResponse]
_get_nft_collection_lists(
    sync: bool,
    params: GetNFTCollectionListsParam = GetNFTCollectionListsParam(),
) -> (
    GetNFTCollectionListsResponse
    | Coroutine[None, None, GetNFTCollectionListsResponse]
)

This function refers to the GET NFT Collection Lists of V2 API endpoint, and it is used to get the list of NFT collections.

Parameters:

Name Type Description Default
params GetNFTCollectionListsParam

The parameters to be used in the request. More details in the object definition.

GetNFTCollectionListsParam()

Returns:

Type Description
GetNFTCollectionListsResponse | Coroutine[None, None, GetNFTCollectionListsResponse]

List of NFT collections.

Source code in src/cyhole/solscan/v2/interaction.py
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
def _get_nft_collection_lists(self, sync: bool, params: GetNFTCollectionListsParam = GetNFTCollectionListsParam()) -> GetNFTCollectionListsResponse | Coroutine[None, None, GetNFTCollectionListsResponse]:
    """
        This function refers to the GET **[NFT Collection Lists](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-nft-collection-lists)** of **V2** API endpoint, 
        and it is used to get the list of NFT collections.

        Parameters:
            params: The parameters to be used in the request.
                More details in the object definition.

        Returns:
            List of NFT collections.
    """
    # set params
    url = self.base_url + "nft/collection/lists"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetNFTCollectionListsResponse,
        params = api_params
    )

_get_nft_collection_items

_get_nft_collection_items(
    sync: Literal[True],
    collection: str,
    sort_by: str = SolscanNFTItemSortType.LAST_TRADE.value,
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> GetNFTCollectionItemsResponse
_get_nft_collection_items(
    sync: Literal[False],
    collection: str,
    sort_by: str = SolscanNFTItemSortType.LAST_TRADE.value,
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> Coroutine[None, None, GetNFTCollectionItemsResponse]
_get_nft_collection_items(
    sync: bool,
    collection: str,
    sort_by: str = SolscanNFTItemSortType.LAST_TRADE.value,
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value,
) -> (
    GetNFTCollectionItemsResponse
    | Coroutine[None, None, GetNFTCollectionItemsResponse]
)

This function refers to the GET NFT Collection Items of V2 API endpoint, and it is used to get the items of a NFT collection.

Parameters:

Name Type Description Default
collection str

The collection address.

required
sort_by str

The sorting method. The supported types are available on SolscanNFTItemSortType.

SolscanNFTItemSortType.LAST_TRADE.value
page int

The page number.

1
page_size int

The number of items per page. The supported types are available on SolscanNFTPageSizeType.

SolscanNFTPageSizeType.SIZE_12.value

Returns:

Type Description
GetNFTCollectionItemsResponse | Coroutine[None, None, GetNFTCollectionItemsResponse]

List of NFT items of the collection.

Source code in src/cyhole/solscan/v2/interaction.py
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
def _get_nft_collection_items(
    self,
    sync: bool,
    collection: str,
    sort_by: str = SolscanNFTItemSortType.LAST_TRADE.value,
    page: int = 1,
    page_size: int = SolscanNFTPageSizeType.SIZE_12.value
) -> GetNFTCollectionItemsResponse | Coroutine[None, None, GetNFTCollectionItemsResponse]:
    """
        This function refers to the GET **[NFT Collection Items](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-nft-collection-items)** of **V2** API endpoint, 
        and it is used to get the items of a NFT collection.

        Parameters:
            collection: The collection address.
            sort_by: The sorting method.
                The supported types are available on [`SolscanNFTItemSortType`][cyhole.solscan.v2.param.SolscanNFTItemSortType].
            page: The page number.
            page_size: The number of items per page.
                The supported types are available on [`SolscanNFTPageSizeType`][cyhole.solscan.v2.param.SolscanNFTPageSizeType].

        Returns:
            List of NFT items of the collection.
    """
    # check param consistency
    SolscanNFTPageSizeType.check(page_size)
    SolscanNFTItemSortType.check(sort_by)

    # set params
    url = self.base_url + "nft/collection/items"
    api_params = {
        "collection": collection,
        "sort_by": sort_by,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetNFTCollectionItemsResponse,
        params = api_params
    )

_get_transaction_last

_get_transaction_last(
    sync: Literal[True],
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
    filter: str = SolscanTransactionFilterType.EXCEPT_VOTE.value,
) -> GetTransactionLastResponse
_get_transaction_last(
    sync: Literal[False],
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
    filter: str = SolscanTransactionFilterType.EXCEPT_VOTE.value,
) -> Coroutine[None, None, GetTransactionLastResponse]
_get_transaction_last(
    sync: bool,
    limit: int = SolscanReturnLimitType.LIMIT_10.value,
    filter: str = SolscanTransactionFilterType.EXCEPT_VOTE.value,
) -> (
    GetTransactionLastResponse
    | Coroutine[None, None, GetTransactionLastResponse]
)

This function refers to the GET Transaction Last of V2 API endpoint, and it is used to get the latest transactions.

Parameters:

Name Type Description Default
limit int

The number of transactions to be returned. The supported types are available on SolscanReturnLimitType.

SolscanReturnLimitType.LIMIT_10.value
filter str

The filter to be used. The supported types are available on SolscanTransactionFilterType.

SolscanTransactionFilterType.EXCEPT_VOTE.value

Returns:

Type Description
GetTransactionLastResponse | Coroutine[None, None, GetTransactionLastResponse]

List of latest transactions.

Source code in src/cyhole/solscan/v2/interaction.py
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
def _get_transaction_last(self, sync: bool, limit: int = SolscanReturnLimitType.LIMIT_10.value, filter: str = SolscanTransactionFilterType.EXCEPT_VOTE.value) -> GetTransactionLastResponse | Coroutine[None, None, GetTransactionLastResponse]:
    """
        This function refers to the GET **[Transaction Last](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-transaction-last)** of **V2** API endpoint, 
        and it is used to get the latest transactions.

        Parameters:
            limit: The number of transactions to be returned.
                The supported types are available on [`SolscanReturnLimitType`][cyhole.solscan.v2.param.SolscanReturnLimitType].
            filter: The filter to be used.
                The supported types are available on [`SolscanTransactionFilterType`][cyhole.solscan.v2.param.SolscanTransactionFilterType].

        Returns:
            List of latest transactions.
    """
    # check param consistency
    SolscanReturnLimitType.check(limit)
    SolscanTransactionFilterType.check(filter)

    # set params
    url = self.base_url + "transaction/last"
    api_params = {
        "limit": limit,
        "filter": filter
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTransactionLastResponse,
        params = api_params
    )

_get_transaction_actions

_get_transaction_actions(
    sync: Literal[True], transaction: str
) -> GetTransactionActionsResponse
_get_transaction_actions(
    sync: Literal[False], transaction: str
) -> Coroutine[None, None, GetTransactionActionsResponse]
_get_transaction_actions(
    sync: bool, transaction: str
) -> (
    GetTransactionActionsResponse
    | Coroutine[None, None, GetTransactionActionsResponse]
)

This function refers to the GET Transaction Actions of V2 API endpoint, and it is used to get the actions of a transaction.

Parameters:

Name Type Description Default
transaction str

The transaction signature.

required

Returns:

Type Description
GetTransactionActionsResponse | Coroutine[None, None, GetTransactionActionsResponse]

List of actions of the transaction.

Source code in src/cyhole/solscan/v2/interaction.py
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
def _get_transaction_actions(self, sync: bool, transaction: str) -> GetTransactionActionsResponse | Coroutine[None, None, GetTransactionActionsResponse]:
    """
        This function refers to the GET **[Transaction Actions](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-transaction-actions)** of **V2** API endpoint, 
        and it is used to get the actions of a transaction.

        Parameters:
            transaction: The transaction signature.

        Returns:
            List of actions of the transaction.
    """
    # set params
    url = self.base_url + "transaction/actions"
    api_params = {
        "tx": transaction
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetTransactionActionsResponse,
        params = api_params
    )

_get_block_last

_get_block_last(
    sync: Literal[True],
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> GetBlockLastResponse
_get_block_last(
    sync: Literal[False],
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> Coroutine[None, None, GetBlockLastResponse]
_get_block_last(
    sync: bool,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> (
    GetBlockLastResponse
    | Coroutine[None, None, GetBlockLastResponse]
)

This function refers to the GET Block Last of V2 API endpoint, and it is used to get the latest blocks.

Parameters:

Name Type Description Default
page_size int

The number of blocks to be returned. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value

Returns:

Type Description
GetBlockLastResponse | Coroutine[None, None, GetBlockLastResponse]

List of latest blocks.

Source code in src/cyhole/solscan/v2/interaction.py
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
def _get_block_last(self, sync: bool, page_size: int = SolscanPageSizeType.SIZE_10.value) -> GetBlockLastResponse | Coroutine[None, None, GetBlockLastResponse]:
    """
        This function refers to the GET **[Block Last](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-block-last)** of **V2** API endpoint, 
        and it is used to get the latest blocks.

        Parameters:
            page_size: The number of blocks to be returned.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].

        Returns:
            List of latest blocks.
    """
    # check param consistency
    SolscanPageSizeType.check(page_size)

    # set params
    url = self.base_url + "block/last"
    api_params = {
        "limit": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetBlockLastResponse,
        params = api_params
    )

_get_block_transactions

_get_block_transactions(
    sync: Literal[True],
    block: int,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> GetBlockTransactionsResponse
_get_block_transactions(
    sync: Literal[False],
    block: int,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> Coroutine[None, None, GetBlockTransactionsResponse]
_get_block_transactions(
    sync: bool,
    block: int,
    page: int = 1,
    page_size: int = SolscanPageSizeType.SIZE_10.value,
) -> (
    GetBlockTransactionsResponse
    | Coroutine[None, None, GetBlockTransactionsResponse]
)

This function refers to the GET Block Transactions of V2 API endpoint, and it is used to get the transactions of a block.

Parameters:

Name Type Description Default
block int

The block number.

required
page int

The page number.

1
page_size int

The number of transactions per page. The supported types are available on SolscanPageSizeType.

SolscanPageSizeType.SIZE_10.value

Returns:

Type Description
GetBlockTransactionsResponse | Coroutine[None, None, GetBlockTransactionsResponse]

List of transactions of the block.

Source code in src/cyhole/solscan/v2/interaction.py
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
def _get_block_transactions(self, sync: bool, block: int, page: int = 1, page_size: int = SolscanPageSizeType.SIZE_10.value) -> GetBlockTransactionsResponse | Coroutine[None, None, GetBlockTransactionsResponse]:
    """
        This function refers to the GET **[Block Transactions](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-block-transactions)** of **V2** API endpoint, 
        and it is used to get the transactions of a block.

        Parameters:
            block: The block number.
            page: The page number.
            page_size: The number of transactions per page.
                The supported types are available on [`SolscanPageSizeType`][cyhole.solscan.v2.param.SolscanPageSizeType].

        Returns:
            List of transactions of the block.
    """
    # check param consistency
    SolscanPageSizeType.check(page_size)

    # set params
    url = self.base_url + "block/transactions"
    api_params = {
        "block": block,
        "page": page,
        "page_size": page_size
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetBlockTransactionsResponse,
        params = api_params
    )

_get_block_detail

_get_block_detail(
    sync: Literal[True], block: int
) -> GetBlockDetailResponse
_get_block_detail(
    sync: Literal[False], block: int
) -> Coroutine[None, None, GetBlockDetailResponse]
_get_block_detail(
    sync: bool, block: int
) -> (
    GetBlockDetailResponse
    | Coroutine[None, None, GetBlockDetailResponse]
)

This function refers to the GET Block Detail of V2 API endpoint, and it is used to get the detail of a block.

Parameters:

Name Type Description Default
block int

The block number.

required

Returns:

Type Description
GetBlockDetailResponse | Coroutine[None, None, GetBlockDetailResponse]

Detail of the block.

Source code in src/cyhole/solscan/v2/interaction.py
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
def _get_block_detail(self, sync: bool, block: int) -> GetBlockDetailResponse | Coroutine[None, None, GetBlockDetailResponse]:
    """
        This function refers to the GET **[Block Detail](https://pro-api.solscan.io/pro-api-docs/v2.0/reference/v2-block-detail)** of **V2** API endpoint, 
        and it is used to get the detail of a block.

        Parameters:
            block: The block number.

        Returns:
            Detail of the block.
    """
    # set params
    url = self.base_url + "block/detail"
    api_params = {
        "block": block
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.GET.value,
        url = url,
        response_model = GetBlockDetailResponse,
        params = api_params
    )

_raise

_raise(exception: HTTPError) -> SolscanException

Internal function used to raise the manage the exceptions raised by the API.

Parameters:

Name Type Description Default
exception HTTPError

the HTTP error returned from Solscan API.

required

Raises:

Type Description
SolscanException

general exception raised when an unknown error is found.

Source code in src/cyhole/solscan/v2/interaction.py
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
def _raise(self, exception: HTTPError) -> SolscanException:
    """
        Internal function used to raise the manage 
        the exceptions raised by the API.

        Parameters:
            exception: the HTTP error returned from Solscan API.

        Raises:
            SolscanException: general exception raised when an unknown error is found.
    """
    try:
        error = SolscanHTTPError(**exception.response.json())
        return SolscanException(f"Code: {error.errors.code}, Message: {error.errors.message}")
    except Exception:
        return SolscanException(exception.response.content.decode())