Skip to content

Interaction

cyhole.solana_fm.SolanaFM

SolanaFM(api_key: str | None = None)

Bases: Interaction

Class used to connect SolanaFM API, popular site to interact and explore Solana blockchain. To have access SolanaFM API is not required an API key, but it is recommended to have one to increase the rate limit.

Check https://docs.solana.fm/ for all the details on the available endpoints.

Info

If the API key is not provided during the object creation, then it is tried to be retrieved also from ENV variable SOLANA_FM_API_KEY.

Parameters:

Name Type Description Default
api_key str | None

specify the API key to use for the connection.

None

Example

import asyncio
from cyhole.solana_fm import SolanaFM

account = "ACCOUNT_ID"
solana_fm = SolanaFM()

# Get account transactions
# synchronous
response = solana_fm.client.get_account_transactions(account)
print("Transactions Extracted:", len(response.result.data))

# asynchronous
async def main() -> None:
    async with solana_fm.async_client as client:
        response = await client.get_account_transactions(account)
        print("Transactions Extracted:", len(response.result.data))

asyncio.run(main())

Source code in src/cyhole/solana_fm/interaction.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def __init__(self, api_key: str | None = None) -> None:

    # set API
    self.api_key = api_key
    if api_key is None:
        self.api_key = os.environ.get("SOLANA_FM_API_KEY")

    # headers setup
    headers = None
    if self.api_key is not None:
        headers = {
            "ApiKey": self.api_key
        }
    super().__init__(headers)

    # clients
    self.client = SolanaFMClient(self, headers = headers)
    self.async_client = SolanaFMAsyncClient(self, headers = headers)

    # API urls
    self.base_v0_url = "https://api.solana.fm/v0/"
    self.base_v1_url = "https://api.solana.fm/v1/"

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

_get_account_transactions

_get_account_transactions(
    sync: Literal[True],
    account: str,
    params: GetAccountTransactionsParam = GetAccountTransactionsParam(),
) -> GetAccountTransactionsResponse
_get_account_transactions(
    sync: Literal[False],
    account: str,
    params: GetAccountTransactionsParam = GetAccountTransactionsParam(),
) -> Coroutine[None, None, GetAccountTransactionsResponse]
_get_account_transactions(
    sync: bool,
    account: str,
    params: GetAccountTransactionsParam = GetAccountTransactionsParam(),
) -> (
    GetAccountTransactionsResponse
    | Coroutine[None, None, GetAccountTransactionsResponse]
)

This function refers to the GET Account Transactions API endpoint, and it is used to get the list of transactions for a given account according to input parameters.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountTransactionsParam

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

GetAccountTransactionsParam()

Returns:

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

List of transactions.

Source code in src/cyhole/solana_fm/interaction.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
def _get_account_transactions(self, sync: bool, account: str, params: GetAccountTransactionsParam = GetAccountTransactionsParam()) -> GetAccountTransactionsResponse | Coroutine[None, None, GetAccountTransactionsResponse]:
    """
        This function refers to the GET **[Account Transactions](https://docs.solana.fm/reference/get_account_transactions)** API endpoint, 
        and it is used to get the list of transactions for a given account according to input parameters.

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

        Returns:
            List of transactions.
    """
    # set params
    url = self.base_v0_url + f"accounts/{account}/transactions"
    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 = GetAccountTransactionsResponse,
        params = api_params
    )

_get_account_transactions_fees

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

This function refers to the GET Account Transactions Fees API endpoint, and it is used to get the list of transactions fees for a given account according to input parameters.

Parameters:

Name Type Description Default
account str

The account address.

required
dt_from datetime | None

The start date to filter transactions.

None
dt_to datetime | None

The end date to filter transactions.

None

Returns:

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

List of transactions fees.

Source code in src/cyhole/solana_fm/interaction.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def _get_account_transactions_fees(self, sync: bool, account: str, dt_from: datetime | None = None, dt_to: datetime | None = None) -> GetAccountTransactionsFeesResponse | Coroutine[None, None, GetAccountTransactionsFeesResponse]:
    """
        This function refers to the GET **[Account Transactions Fees](https://docs.solana.fm/reference/get_account_tx_fees)** API endpoint,
        and it is used to get the list of transactions fees for a given account according to input parameters.

        Parameters:
            account: The account address.
            dt_from: The start date to filter transactions.
            dt_to: The end date to filter transactions.

        Returns:
            List of transactions fees.
    """
    # set params
    url = self.base_v0_url + f"accounts/{account}/fees"

    api_params = {}
    if dt_from is not None:
        api_params["from"] = dt_from.strftime("%Y-%m-%d")
    if dt_to is not None:
        api_params["to"] = dt_to.strftime("%Y-%m-%d")

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

_get_account_transfers

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

This function refers to the GET Account Transfers API endpoint, and it is used to get the list of transfers for a given account according to input parameters.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountTransfersParam

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

GetAccountTransfersParam()

Returns:

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

List of transfers.

Source code in src/cyhole/solana_fm/interaction.py
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
def _get_account_transfers(self, sync: bool, account: str, params: GetAccountTransfersParam = GetAccountTransfersParam()) -> GetAccountTransfersResponse | Coroutine[None, None, GetAccountTransfersResponse]:
    """
        This function refers to the GET **[Account Transfers](https://docs.solana.fm/reference/get_account_transfers_v1)** API endpoint, 
        and it is used to get the list of transfers for a given account according to input parameters.

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

        Returns:
            List of transfers.
    """
    # set params
    url = self.base_v0_url + f"accounts/{account}/transfers"
    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 = GetAccountTransfersResponse,
        params = api_params
    )

_get_account_transfers_csv_export

_get_account_transfers_csv_export(
    sync: Literal[True],
    account: str,
    params: GetAccountTransfersCsvExportParam = GetAccountTransfersCsvExportParam(),
) -> GetAccountTransfersCsvExportResponse
_get_account_transfers_csv_export(
    sync: Literal[False],
    account: str,
    params: GetAccountTransfersCsvExportParam = GetAccountTransfersCsvExportParam(),
) -> Coroutine[
    None, None, GetAccountTransfersCsvExportResponse
]
_get_account_transfers_csv_export(
    sync: bool,
    account: str,
    params: GetAccountTransfersCsvExportParam = GetAccountTransfersCsvExportParam(),
) -> (
    GetAccountTransfersCsvExportResponse
    | Coroutine[
        None, None, GetAccountTransfersCsvExportResponse
    ]
)

This function refers to the GET Account Transfers CSV Export API endpoint, and it is used to get the list of transfers for a given account according to input parameters in CSV format.

Parameters:

Name Type Description Default
account str

The account address.

required
params GetAccountTransfersCsvExportParam

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

GetAccountTransfersCsvExportParam()

Returns:

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

List of transfers in CSV format.

Source code in src/cyhole/solana_fm/interaction.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
def _get_account_transfers_csv_export(self, sync: bool, account: str, params: GetAccountTransfersCsvExportParam = GetAccountTransfersCsvExportParam()) -> GetAccountTransfersCsvExportResponse | Coroutine[None, None, GetAccountTransfersCsvExportResponse]:
    """
        This function refers to the GET **[Account Transfers CSV Export](https://docs.solana.fm/reference/download_csv_v1)** API endpoint,
        and it is used to get the list of transfers for a given account according to input parameters in CSV format.

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

        Returns:
            List of transfers in CSV format.
    """
    # set params
    url = self.base_v0_url + f"accounts/{account}/transfers/csv"
    api_params = params.model_dump(
        by_alias = True,
        exclude_defaults = True
    )

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

_get_blocks

_get_blocks(
    sync: Literal[True],
    from_block: int | None = None,
    page_size: int = 50,
    page_type: str = SolanaFMBlocksPaginationType.BLOCK_NUMBER.value,
    ascending: bool | None = None,
) -> GetBlocksResponse
_get_blocks(
    sync: Literal[False],
    from_block: int | None = None,
    page_size: int = 50,
    page_type: str = SolanaFMBlocksPaginationType.BLOCK_NUMBER.value,
    ascending: bool | None = None,
) -> Coroutine[None, None, GetBlocksResponse]
_get_blocks(
    sync: bool,
    from_block: int | None = None,
    page_size: int = 50,
    page_type: str = SolanaFMBlocksPaginationType.BLOCK_NUMBER.value,
    ascending: bool | None = None,
) -> (
    GetBlocksResponse
    | Coroutine[None, None, GetBlocksResponse]
)

This function refers to the GET Blocks API endpoint, and it is used to get the list of blocks according to input parameters.

Parameters:

Name Type Description Default
from_block int | None

The block number to start from. If not provided, the latest block is returned.

None
page_size int

The number of blocks to return.

50
page_type str

The type of page to return. The supported types are available on SolanaFMBlocksPaginationType.

SolanaFMBlocksPaginationType.BLOCK_NUMBER.value
ascending bool | None

The order of the blocks.

None

Returns:

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

List of blocks.

Source code in src/cyhole/solana_fm/interaction.py
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
def _get_blocks(
    self,
    sync: bool,
    from_block: int | None = None,
    page_size: int = 50,
    page_type: str = SolanaFMBlocksPaginationType.BLOCK_NUMBER.value,
    ascending: bool | None = None
) -> GetBlocksResponse | Coroutine[None, None, GetBlocksResponse]:
    """
        This function refers to the GET **[Blocks](https://docs.solana.fm/reference/get_blocks_by_pagination)** API endpoint,
        and it is used to get the list of blocks according to input parameters.

        Parameters:
            from_block: The block number to start from.
                If not provided, the latest block is returned.
            page_size: The number of blocks to return.
            page_type: The type of page to return.
                The supported types are available on [`SolanaFMBlocksPaginationType`][cyhole.solana_fm.param.SolanaFMBlocksPaginationType].
            ascending: The order of the blocks.

        Returns:
            List of blocks.
    """
    # check param consistency
    SolanaFMBlocksPaginationType.check(page_type)

    # set params
    url = self.base_v0_url + "blocks"

    api_params = {
        "from": from_block,
        "pageSize": page_size,
        "paginationType": page_type,
        "reverse": ascending
    }

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

_get_block

_get_block(
    sync: Literal[True], block_number: int
) -> GetBlockResponse
_get_block(
    sync: Literal[False], block_number: int
) -> Coroutine[None, None, GetBlockResponse]
_get_block(
    sync: bool, block_number: int
) -> (
    GetBlockResponse
    | Coroutine[None, None, GetBlockResponse]
)

This function refers to the GET Block API endpoint, and it is used to get the block details for a given block Number.

Parameters:

Name Type Description Default
block_number int

The block number.

required

Returns:

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

Block details.

Source code in src/cyhole/solana_fm/interaction.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
def _get_block(self, sync: bool, block_number: int) -> GetBlockResponse | Coroutine[None, None, GetBlockResponse]:
    """
        This function refers to the GET **[Block](https://docs.solana.fm/reference/get_block)** API endpoint,
        and it is used to get the block details for a given block Number.

        Parameters:
            block_number: The block number.

        Returns:
            Block details.
    """
    # set params
    url = self.base_v0_url + f"blocks/{block_number}"

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

_post_multiple_blocks

_post_multiple_blocks(
    sync: Literal[True],
    block_numbers: list[int],
    producer_details: bool = True,
) -> PostMultipleBlocksResponse
_post_multiple_blocks(
    sync: Literal[False],
    block_numbers: list[int],
    producer_details: bool = True,
) -> Coroutine[None, None, PostMultipleBlocksResponse]
_post_multiple_blocks(
    sync: bool,
    block_numbers: list[int],
    producer_details: bool = True,
) -> (
    PostMultipleBlocksResponse
    | Coroutine[None, None, PostMultipleBlocksResponse]
)

This function refers to the POST Multiple Blocks API endpoint, and it is used to get multiple blocks information from the SolanaFM API.

Parameters:

Name Type Description Default
block_numbers list[int]

The list of block numbers to get.

required

Returns:

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

Block details.

Source code in src/cyhole/solana_fm/interaction.py
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
def _post_multiple_blocks(self, sync: bool, block_numbers: list[int], producer_details: bool = True) -> PostMultipleBlocksResponse | Coroutine[None, None, PostMultipleBlocksResponse]:
    """
        This function refers to the POST **[Multiple Blocks](https://docs.solana.fm/reference/get_multiple_blocks)** API endpoint,
        and it is used to get multiple blocks information from the SolanaFM API.

        Parameters:
            block_numbers: The list of block numbers to get.

        Returns:
            Block details.
    """
    # set params
    url = self.base_v0_url + "blocks"

    headers = {
        "accept": "application/json",
        "content-type": "application/json"
    }

    json = {
        "hydration": { "accountHash": producer_details },
        "blockNumbers": block_numbers,
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.POST.value,
        url = url,
        response_model = PostMultipleBlocksResponse,
        headers = headers,
        json = json
    )

_get_solana_daily_transaction_fees

_get_solana_daily_transaction_fees(
    sync: Literal[True], dt: datetime = datetime.now()
) -> GetSolanaDailyTransactionFeesResponse
_get_solana_daily_transaction_fees(
    sync: Literal[False], dt: datetime = datetime.now()
) -> Coroutine[
    None, None, GetSolanaDailyTransactionFeesResponse
]
_get_solana_daily_transaction_fees(
    sync: bool, dt: datetime = datetime.now()
) -> (
    GetSolanaDailyTransactionFeesResponse
    | Coroutine[
        None, None, GetSolanaDailyTransactionFeesResponse
    ]
)

This function refers to the GET Solana Daily Transaction Fees API endpoint, and it is used to get the daily transaction fees for a given date on the whole Solana chain.

Observe that if the date is not provided, the current date is used and the result could change over time as the day is not finished yet.

Parameters:

Name Type Description Default
dt datetime

The date to get the transaction fees. By default, the current date is used.

datetime.now()

Returns:

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

Daily transaction fees.

Source code in src/cyhole/solana_fm/interaction.py
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
def _get_solana_daily_transaction_fees(self, sync: bool, dt: datetime = datetime.now()) -> GetSolanaDailyTransactionFeesResponse | Coroutine[None, None, GetSolanaDailyTransactionFeesResponse]:
    """
        This function refers to the GET **[Solana Daily Transaction Fees](https://docs.solana.fm/reference/get_daily_tx_fees)** API endpoint,
        and it is used to get the daily transaction fees for a given date on the whole Solana chain.

        Observe that if the date is not provided, the current date is used and the result could change over time 
        as the day is not finished yet.

        Parameters:
            dt: The date to get the transaction fees.
                By default, the current date is used.

        Returns:
            Daily transaction fees.
    """
    # set params
    url = self.base_v0_url + "stats/tx-fees"

    api_params = {
        "date": dt.strftime("%d-%m-%Y")
    }

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

_get_tagged_tokens_list

_get_tagged_tokens_list(
    sync: Literal[True],
) -> GetTaggedTokensListResponse
_get_tagged_tokens_list(
    sync: Literal[False],
) -> Coroutine[None, None, GetTaggedTokensListResponse]
_get_tagged_tokens_list(
    sync: bool,
) -> (
    GetTaggedTokensListResponse
    | Coroutine[None, None, GetTaggedTokensListResponse]
)

This function refers to the GET Tagged Tokens List API endpoint, and it is used to get the list of tagged tokens identified by the SolanaFM team (not tokens indexed on-chain).

Returns:

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

List of tagged tokens.

Source code in src/cyhole/solana_fm/interaction.py
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
def _get_tagged_tokens_list(self, sync: bool) -> GetTaggedTokensListResponse | Coroutine[None, None, GetTaggedTokensListResponse]:
    """
        This function refers to the GET **[Tagged Tokens List](https://docs.solana.fm/reference/get_tokens_by_pagination)** API endpoint,
        and it is used to get the list of tagged tokens identified by the SolanaFM team (**not tokens indexed on-chain**).

        Returns:
            List of tagged tokens.
    """
    # set params
    url = self.base_v0_url + "tokens"

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

_get_token_info_v0

_get_token_info_v0(
    sync: Literal[True], address: str
) -> GetTokenInfoV0Response
_get_token_info_v0(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetTokenInfoV0Response]
_get_token_info_v0(
    sync: bool, address: str
) -> (
    GetTokenInfoV0Response
    | Coroutine[None, None, GetTokenInfoV0Response]
)

This function refers to the GET Token Info V0 API endpoint, and it is used to get the token information for a given token address.

Info

This endpoint refers to the V0 version of the API.

Parameters:

Name Type Description Default
address str

The token address.

required

Returns:

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

Token information.

Source code in src/cyhole/solana_fm/interaction.py
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
def _get_token_info_v0(self, sync: bool, address: str) -> GetTokenInfoV0Response | Coroutine[None, None, GetTokenInfoV0Response]:
    """
        This function refers to the GET **[Token Info V0](https://docs.solana.fm/reference/get_token_by_account_hash)** API endpoint,
        and it is used to get the token information for a given token address.

        !!! info
            This endpoint refers to the **V0** version of the API.

        Parameters:
            address: The token address.

        Returns:
            Token information.
    """
    # set params
    url = self.base_v0_url + f"tokens/{address}"

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

_post_token_multiple_info_v0

_post_token_multiple_info_v0(
    sync: Literal[True], addresses: list[str]
) -> PostTokenMultipleInfoV0Response
_post_token_multiple_info_v0(
    sync: Literal[False], addresses: list[str]
) -> Coroutine[None, None, PostTokenMultipleInfoV0Response]
_post_token_multiple_info_v0(
    sync: bool, addresses: list[str]
) -> (
    PostTokenMultipleInfoV0Response
    | Coroutine[None, None, PostTokenMultipleInfoV0Response]
)

This function refers to the POST Token Multiple Info V0 API endpoint, and it is used to get the token information for multiple token addresses.

Info

This endpoint refers to the V0 version of the API.

Parameters:

Name Type Description Default
addresses list[str]

The list of token addresses.

required

Returns:

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

Token information.

Source code in src/cyhole/solana_fm/interaction.py
479
480
481
482
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
512
513
514
def _post_token_multiple_info_v0(self, sync: bool, addresses: list[str]) -> PostTokenMultipleInfoV0Response | Coroutine[None, None, PostTokenMultipleInfoV0Response]:
    """
        This function refers to the POST **[Token Multiple Info V0](https://docs.solana.fm/reference/get_tokens_by_account_hashes)** API endpoint,
        and it is used to get the token information for multiple token addresses.

        !!! info
            This endpoint refers to the **V0** version of the API.

        Parameters:
            addresses: The list of token addresses.

        Returns:
            Token information.
    """
    # set params
    url = self.base_v0_url + "tokens"

    headers = {
        "accept": "application/json",
        "content-type": "application/json"
    }

    json = {
        "hydration": { "accountHash": True },
        "tokenHashes": addresses
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.POST.value,
        url = url,
        response_model = PostTokenMultipleInfoV0Response,
        headers = headers,
        json = json
    )

_get_token_info_v1

_get_token_info_v1(
    sync: Literal[True], address: str
) -> GetTokenInfoV1Response
_get_token_info_v1(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetTokenInfoV1Response]
_get_token_info_v1(
    sync: bool, address: str
) -> (
    GetTokenInfoV1Response
    | Coroutine[None, None, GetTokenInfoV1Response]
)

This function refers to the GET Token Info V1 API endpoint, and it is used to get the token information for a given token address.

Info

This endpoint refers to the V1 version of the API.

Parameters:

Name Type Description Default
address str

The token address.

required

Returns:

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

Token information.

Source code in src/cyhole/solana_fm/interaction.py
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
def _get_token_info_v1(self, sync: bool, address: str) -> GetTokenInfoV1Response | Coroutine[None, None, GetTokenInfoV1Response]:
    """
        This function refers to the GET **[Token Info V1](https://docs.solana.fm/reference/get_one_token)** API endpoint,
        and it is used to get the token information for a given token address.

        !!! info
            This endpoint refers to the **V1** version of the API.

        Parameters:
            address: The token address.

        Returns:
            Token information.
    """
    # set params
    url = self.base_v1_url + f"tokens/{address}"

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

_post_token_multiple_info_v1

_post_token_multiple_info_v1(
    sync: Literal[True], addresses: list[str]
) -> PostTokenMultipleInfoV1Response
_post_token_multiple_info_v1(
    sync: Literal[False], addresses: list[str]
) -> Coroutine[None, None, PostTokenMultipleInfoV1Response]
_post_token_multiple_info_v1(
    sync: bool, addresses: list[str]
) -> (
    PostTokenMultipleInfoV1Response
    | Coroutine[None, None, PostTokenMultipleInfoV1Response]
)

This function refers to the POST Token Multiple Info V1 API endpoint, and it is used to get the token information for multiple token addresses.

Info

This endpoint refers to the V1 version of the API.

Parameters:

Name Type Description Default
addresses list[str]

The list of token addresses.

required

Returns:

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

Token information.

Source code in src/cyhole/solana_fm/interaction.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
def _post_token_multiple_info_v1(self, sync: bool, addresses: list[str]) -> PostTokenMultipleInfoV1Response | Coroutine[None, None, PostTokenMultipleInfoV1Response]:
    """
        This function refers to the POST **[Token Multiple Info V1](https://docs.solana.fm/reference/retrieve_multiple_tokens)** API endpoint,
        and it is used to get the token information for multiple token addresses.

        !!! info
            This endpoint refers to the **V1** version of the API.

        Parameters:
            addresses: The list of token addresses.

        Returns:
            Token information.
    """
    # set params
    url = self.base_v1_url + "tokens"

    headers = {
        "accept": "application/json",
        "content-type": "application/json"
    }

    json = {
        "tokens": addresses
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.POST.value, url, headers = headers, json = json)
        return PostTokenMultipleInfoV1Response(tokens = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.POST.value, url, headers = headers, json = json)
            return PostTokenMultipleInfoV1Response(tokens = content_raw.json())
        return async_request()

_post_user_token_accounts

_post_user_token_accounts(
    sync: Literal[True],
    address: str,
    include_sol_balance: bool = False,
    tokens: list[str] | None = None,
) -> PostUserTokenAccountsResponse
_post_user_token_accounts(
    sync: Literal[False],
    address: str,
    include_sol_balance: bool = False,
    tokens: list[str] | None = None,
) -> Coroutine[None, None, PostUserTokenAccountsResponse]
_post_user_token_accounts(
    sync: bool,
    address: str,
    include_sol_balance: bool = False,
    tokens: list[str] | None = None,
) -> (
    PostUserTokenAccountsResponse
    | Coroutine[None, None, PostUserTokenAccountsResponse]
)

This function refers to the POST User Token Accounts API endpoint, and it is used to get the token accounts for a given user address.

Parameters:

Name Type Description Default
address str

The user address.

required
include_sol_balance bool

Flag to include the Sol balance of the account.

False
tokens list[str] | None

The list of token addresses to filter the accounts.

None

Returns:

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

Token accounts.

Source code in src/cyhole/solana_fm/interaction.py
595
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
def _post_user_token_accounts(self, sync: bool, address: str, include_sol_balance: bool = False, tokens: list[str] | None = None) -> PostUserTokenAccountsResponse | Coroutine[None, None, PostUserTokenAccountsResponse]:
    """
        This function refers to the POST **[User Token Accounts](https://docs.solana.fm/reference/get_user_token_accounts)** API endpoint,
        and it is used to get the token accounts for a given user address.

        Parameters:
            address: The user address.
            include_sol_balance: Flag to include the Sol balance of the account.
            tokens: The list of token addresses to filter the accounts.

        Returns:
            Token accounts.
    """
    # set params
    url = self.base_v1_url + f"tokens/{address}/token-accounts"

    headers = {
        "accept": "application/json",
        "content-type": "application/json"
    }

    json = {
        "includeSolBalance": include_sol_balance,
        "tokenHashes": tokens
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.POST.value,
        url = url,
        response_model = PostUserTokenAccountsResponse,
        headers = headers,
        json = json
    )

_get_mint_token_accounts

_get_mint_token_accounts(
    sync: Literal[True],
    address: str,
    page: int | None = None,
    page_size: int | None = None,
) -> GetMintTokenAccountsResponse
_get_mint_token_accounts(
    sync: Literal[False],
    address: str,
    page: int | None = None,
    page_size: int | None = None,
) -> Coroutine[None, None, GetMintTokenAccountsResponse]
_get_mint_token_accounts(
    sync: bool,
    address: str,
    page: int | None = None,
    page_size: int | None = None,
) -> (
    GetMintTokenAccountsResponse
    | Coroutine[None, None, GetMintTokenAccountsResponse]
)

This function refers to the GET Mint Token Accounts API endpoint, and it is used to get the token accounts owned by a given token mint address.

Parameters:

Name Type Description Default
address str

The token address.

required
page int | None

The page number.

None
page_size int | None

The number of accounts to return per page.

None

Returns:

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

Token accounts.

Source code in src/cyhole/solana_fm/interaction.py
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
def _get_mint_token_accounts(self, sync: bool, address: str, page: int | None = None, page_size: int | None = None) -> GetMintTokenAccountsResponse | Coroutine[None, None, GetMintTokenAccountsResponse]:
    """
        This function refers to the GET **[Mint Token Accounts](https://docs.solana.fm/reference/get_token_accounts_for_token_mint)** API endpoint,
        and it is used to get the token accounts owned by a given token mint address.

        Parameters:
            address: The token address.
            page: The page number.
            page_size: The number of accounts to return per page.

        Returns:
            Token accounts.
    """
    # set params
    url = self.base_v1_url + f"tokens/{address}/holders"

    api_params = {
        "page": page,
        "pageSize": page_size
    }

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

_get_on_chain_token_data

_get_on_chain_token_data(
    sync: Literal[True], address: str
) -> GetOnChainTokenDataResponse
_get_on_chain_token_data(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetOnChainTokenDataResponse]
_get_on_chain_token_data(
    sync: bool, address: str
) -> (
    GetOnChainTokenDataResponse
    | Coroutine[None, None, GetOnChainTokenDataResponse]
)

This function refers to the GET On-Chain Token Data API endpoint, and it is used to get the token data for a given token address stored on-chain.

Parameters:

Name Type Description Default
address str

The token address.

required

Returns:

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

Token data.

Source code in src/cyhole/solana_fm/interaction.py
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
def _get_on_chain_token_data(self, sync: bool, address: str) -> GetOnChainTokenDataResponse | Coroutine[None, None, GetOnChainTokenDataResponse]:
    """
        This function refers to the GET **[On-Chain Token Data](https://docs.solana.fm/reference/get_tfi_token_data)** API endpoint,
        and it is used to get the token data for a given token address stored on-chain.

        Parameters:
            address: The token address.

        Returns:
            Token data.
    """
    # set params
    url = self.base_v1_url + f"tokens/{address}/info"

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

_get_token_supply

_get_token_supply(
    sync: Literal[True], address: str
) -> GetTokenSupplyResponse
_get_token_supply(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetTokenSupplyResponse]
_get_token_supply(
    sync: bool, address: str
) -> (
    GetTokenSupplyResponse
    | Coroutine[None, None, GetTokenSupplyResponse]
)

This function refers to the GET Token Supply API endpoint, and it is used to get the token circulating supply for a given token address.

Parameters:

Name Type Description Default
address str

The token address.

required

Returns:

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

Token supply.

Source code in src/cyhole/solana_fm/interaction.py
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
def _get_token_supply(self, sync: bool, address: str) -> GetTokenSupplyResponse | Coroutine[None, None, GetTokenSupplyResponse]:
    """
        This function refers to the GET **[Token Supply](https://docs.solana.fm/reference/get_token_circulating_supply)** API endpoint,
        and it is used to get the token circulating supply for a given token address.

        Parameters:
            address: The token address.

        Returns:
            Token supply.
    """
    # set params
    url = self.base_v1_url + f"tokens/{address}/supply"

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

_get_transfer_transactions

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

This function refers to the GET Transfer Transactions API endpoint, and it is used to get the list of transfer transactions for a given account according to input parameters.

Parameters:

Name Type Description Default
transaction str

The transaction hash.

required

Returns:

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

List of transfer transactions.

Source code in src/cyhole/solana_fm/interaction.py
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
def _get_transfer_transactions(self, sync: bool, transaction: str) -> GetTransferTransactionsResponse | Coroutine[None, None, GetTransferTransactionsResponse]:
    """
        This function refers to the GET **[Transfer Transactions](https://docs.solana.fm/reference/get_transfers)** API endpoint,
        and it is used to get the list of transfer transactions for a given account according to input parameters.

        Parameters:
            transaction: The transaction hash.

        Returns:
            List of transfer transactions.
    """
    # set params
    url = self.base_v0_url + f"transfers/{transaction}"

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

_post_multiple_transfer_transactions

_post_multiple_transfer_transactions(
    sync: Literal[True], transactions: list[str]
) -> PostMultipleTransferTransactionsResponse
_post_multiple_transfer_transactions(
    sync: Literal[False], transactions: list[str]
) -> Coroutine[
    None, None, PostMultipleTransferTransactionsResponse
]
_post_multiple_transfer_transactions(
    sync: bool, transactions: list[str]
) -> (
    PostMultipleTransferTransactionsResponse
    | Coroutine[
        None, None, PostMultipleTransferTransactionsResponse
    ]
)

This function refers to the POST Multiple Transfer Transactions API endpoint, and it is used to get multiple transfer transactions information from the SolanaFM API.

Parameters:

Name Type Description Default
transactions list[str]

The list of transaction hashes to get.

required

Returns:

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

Transfer transactions details.

Source code in src/cyhole/solana_fm/interaction.py
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
def _post_multiple_transfer_transactions(self, sync: bool, transactions: list[str]) -> PostMultipleTransferTransactionsResponse | Coroutine[None, None, PostMultipleTransferTransactionsResponse]:
    """
        This function refers to the POST **[Multiple Transfer Transactions](https://docs.solana.fm/reference/post_transfers)** API endpoint,
        and it is used to get multiple transfer transactions information from the SolanaFM API.

        Parameters:
            transactions: The list of transaction hashes to get.

        Returns:
            Transfer transactions details.
    """
    # set params
    url = self.base_v0_url + "transfers"

    headers = {
        "accept": "application/json",
        "content-type": "application/json"
    }

    json = {
        "transactionHashes": transactions
    }

    # execute request
    return  self.api_return_model(
        sync = sync,
        type = RequestType.POST.value,
        url = url,
        response_model = PostMultipleTransferTransactionsResponse,
        headers = headers,
        json = json
    )

_get_all_transfer_actions

_get_all_transfer_actions(
    sync: Literal[True],
) -> GetAllTransferActionsResponse
_get_all_transfer_actions(
    sync: Literal[False],
) -> Coroutine[None, None, GetAllTransferActionsResponse]
_get_all_transfer_actions(
    sync: bool,
) -> (
    GetAllTransferActionsResponse
    | Coroutine[None, None, GetAllTransferActionsResponse]
)

This function refers to the GET All Transfer Actions API endpoint, and it is used to get the list of all transfer actions on SolanaFM.

Returns:

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

List of all transfer actions.

Source code in src/cyhole/solana_fm/interaction.py
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
def _get_all_transfer_actions(self, sync: bool) -> GetAllTransferActionsResponse | Coroutine[None, None, GetAllTransferActionsResponse]:
    """
        This function refers to the GET **[All Transfer Actions](https://docs.solana.fm/reference/get_actions)** API endpoint,
        and it is used to get the list of all transfer actions on SolanaFM.

        Returns:
            List of all transfer actions.
    """
    # set params
    url = self.base_v1_url + "actions"

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetAllTransferActionsResponse(actions = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetAllTransferActionsResponse(actions = content_raw.json())
        return async_request()