// Get metadata for a specific badgeconstbadgeMetadata=collection.getBadgeMetadata(1n);// Get collection-level metadataconstcollectionMetadata=collection.getCollectionMetadata();
Checking Balances
// Get total supplyconsttotalSupply=collection.getBadgeBalances('Total');// Get specific address balanceconstuserBalance=collection.getBadgeBalances('bb1234...');// Get full balance info including approvalsconstbalanceInfo=collection.getBadgeBalanceInfo('bb1234...');
Pagination and Views
Views are used to fetch paginated data like transfer history and owner lists. Each view uses a bookmark system for pagination.
// Fetch owners with paginationconstviewRequest= { viewType:'owners', viewId:'owners-list', bookmark:'',// Empty for first page};// Fetch first pageawaitcollection.fetchNextForView(BitBadgesApi,'owners','owners-list');// Check if more pages existconsthasMore=collection.viewHasMore('owners-list');// Get next bookmarkconstnextBookmark=collection.getViewBookmark('owners-list');
Content Warnings
Collections can be flagged as NSFW or reported. These flags will be present in the response:
// Check if a request would fetch new dataconstisRedundant=collection.isRedundantRequest({ collectionId:1n, metadataToFetch: { badgeIds: [{ start:1n, end:10n }] },});// Only fetch new badge IDsawaitcollection.fetchMetadata(BitBadgesApi, { metadataToFetch: { badgeIds: [{ start:11n, end:20n }],// New range },});