Skip to content

Commit e0a9b52

Browse files
authored
fix(unisat): cursor fix
1 parent 7a2579e commit e0a9b52

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

blockapi/v2/api/nft/unisat.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ class UnisatApi(BlockchainApi, INftParser, INftProvider):
5656
'get_collection_stats': 'v3/market/collection/auction/collection_statistic',
5757
}
5858

59-
def __init__(self, api_key: str, sleep_provider: Optional[ISleepProvider] = None, limit: Optional[int] = 10000):
59+
def __init__(
60+
self,
61+
api_key: str,
62+
sleep_provider: Optional[ISleepProvider] = None,
63+
limit: Optional[int] = 10000,
64+
):
6065
"""
6166
Initialize the Unisat API client
6267
@@ -93,12 +98,12 @@ def fetch_nfts(
9398
"""
9499
if not address:
95100
raise ValueError("Address is required")
96-
101+
97102
# set size to self.limit based on the following heuristic:
98103
# Bottom line 1–2 NFTs per wallet is the norm. Hundreds (100–999) is rare but possible for active collectors. Low-thousands (1 000–1 999) exist only among the most hardcore or institutional actors. 10 000+ in a single non-contract wallet? Essentially never for an individual.
99104
# for simplicity, we will always set size to self.limit
100105
size = self.limit
101-
106+
102107
# allow pagination cursor as string or int, convert to int, and set to 0 to avoid skipping any NFTS
103108
params = {'size': size, 'cursor': 0}
104109

@@ -509,7 +514,7 @@ def fetch_offers(
509514
f"Unisat API limit is 500. You tried to fetch {limit} items. Truncating to 499."
510515
)
511516
limit = 499
512-
517+
513518
request_body = {
514519
"filter": filter_dict,
515520
"start": 0,
@@ -613,4 +618,4 @@ def _yield_parsed_offers(
613618
pay_ident=None,
614619
pay_amount=price,
615620
pay_coin=self.coin,
616-
)
621+
)

0 commit comments

Comments
 (0)