Skip to content

Commit 4e9ef49

Browse files
committed
Add new marketplace-sdk hooks documentation
Added documentation pages for the following new hooks in the marketplace-sdk: useConfig, useCountListingsForCollectible, useCountOffersForCollectible, useCurrency, useFilters, useFloorOrder, useGetCountOfFilteredOrders and useGetCountOfPrimarySaleItems.
1 parent 08251e3 commit 4e9ef49

File tree

9 files changed

+357
-1
lines changed

9 files changed

+357
-1
lines changed

docs.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@
414414
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListListingsForCollectible",
415415
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListOffersForCollectible",
416416
"sdk/web/marketplace-sdk/hooks/marketplace-data/useCountOfCollectables",
417+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useGetCountOfFilteredOrders",
418+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useGetCountOfPrimarySaleItems",
419+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useCountListingsForCollectible",
420+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useCountOffersForCollectible",
417421
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListCollectibles",
418422
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListCollectiblesPaginated",
419423
"sdk/web/marketplace-sdk/hooks/marketplace-data/useMarketplaceConfig",
@@ -425,7 +429,11 @@
425429
"sdk/web/marketplace-sdk/hooks/marketplace-data/useLowestListing",
426430
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListPrimarySaleItems",
427431
"sdk/web/marketplace-sdk/hooks/marketplace-data/useListCollections",
428-
"sdk/web/marketplace-sdk/hooks/marketplace-data/useHighestOffer"
432+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useHighestOffer",
433+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useFloorOrder",
434+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useFilters",
435+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useCurrency",
436+
"sdk/web/marketplace-sdk/hooks/marketplace-data/useConfig"
429437
]
430438
}
431439
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: useConfig
3+
description: Retrieves the marketplace SDK configuration from the provider context This hook provides access to the core SDK configuration that was passed to the MarketplaceSdkProvider. It includes API endpoints, chain configurations, and other SDK-wide settings needed by child components and hooks
4+
sidebarTitle: useConfig
5+
---
6+
7+
## Returns
8+
9+
The complete SDK configuration object from the provider context
10+
11+
## Example
12+
13+
Basic usage:
14+
15+
```typescript
16+
const config = useConfig();
17+
console.log(config.marketplaceApiUrl);
18+
console.log(config.projectId);
19+
```
20+
21+
Using config for API calls:
22+
```typescript
23+
const config = useConfig();
24+
25+
const response = await fetch(`${config.marketplaceApiUrl}/collections`, {
26+
headers: {
27+
'X-Project-ID': config.projectId
28+
}
29+
});
30+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: useCountListingsForCollectible
3+
description: Hook to get the count of listings for a specific collectible Counts the number of active listings for a given collectible in the marketplace. Useful for displaying listing counts in UI components
4+
sidebarTitle: useCountListingsForCollectible
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.config` | `SdkConfig` | Configuration parameters |
12+
| `params.chainId` | `number` | The chain ID (must be a number, e.g., 1 for Ethereum, 137 for Polygon) |
13+
| `params.collectionAddress` | `string` | The collection contract address |
14+
| `params.collectibleId` | `string` | The specific collectible/token ID |
15+
| `params.filter` | `OrdersFilter` | Optional filter criteria for listings |
16+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
17+
18+
## Returns
19+
20+
Query result containing the count of listings
21+
22+
## Example
23+
24+
Basic usage:
25+
26+
```typescript
27+
const { data: listingCount, isLoading } = useCountListingsForCollectible({
28+
chainId: 137,
29+
collectionAddress: '0x...',
30+
collectibleId: '123'
31+
});
32+
```
33+
34+
With filter:
35+
36+
```typescript
37+
const { data: filteredCount } = useCountListingsForCollectible({
38+
chainId: 137,
39+
collectionAddress: '0x...',
40+
collectibleId: '123',
41+
filter: {
42+
priceRange: { min: '1000000000000000000' }
43+
}
44+
});
45+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: useCountOffersForCollectible
3+
description: Hook to get the count of offers for a specific collectible Counts the number of active offers for a given collectible in the marketplace. Useful for displaying offer counts in UI components
4+
sidebarTitle: useCountOffersForCollectible
5+
---
6+
7+
## Parameters
8+
| Name | Type | Description |
9+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
10+
| `params.config` | `SdkConfig` | Configuration parameters |
11+
| `params.chainId` | `number` | The chain ID (must be a number, e.g., 1 for Ethereum, 137 for Polygon) |
12+
| `params.collectionAddress` | `string` | The collection contract address |
13+
| `params.collectibleId` | `string` | The specific collectible/token ID |
14+
| `params.filter` | `OrdersFilter` | Optional filter criteria for offers |
15+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
16+
17+
## Returns
18+
19+
Query result containing the count of offers
20+
21+
## Example
22+
23+
Basic usage:
24+
25+
```typescript
26+
const { data: offerCount, isLoading } = useCountOffersForCollectible({
27+
chainId: 137,
28+
collectionAddress: '0x...',
29+
collectibleId: '123'
30+
});
31+
```
32+
33+
With filter:
34+
35+
```typescript
36+
const { data: filteredCount } = useCountOffersForCollectible({
37+
chainId: 137,
38+
collectionAddress: '0x...',
39+
collectibleId: '123',
40+
filter: {
41+
priceRange: { min: '1000000000000000000' }
42+
}
43+
});
44+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: useCurrency
3+
description: Hook to fetch currency details from the marketplace Retrieves detailed information about a specific currency by its contract address. The currency data is cached from previous currency list calls when possible
4+
sidebarTitle: useCurrency
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.config` | `SdkConfig` | Configuration parameters |
12+
| `params.chainId` | `number` | The chain ID (must be a number, e.g., 1 for Ethereum, 137 for Polygon) |
13+
| `params.currencyAddress` | `string` | The currency contract address |
14+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
15+
16+
## Returns
17+
18+
Query result containing currency details
19+
20+
## Example
21+
22+
Basic usage:
23+
```typescript
24+
const { data, isLoading } = useCurrency({
25+
chainId: 137,
26+
currencyAddress: '0x...'
27+
});
28+
```
29+
30+
With custom query options:
31+
32+
```typescript
33+
const { data, isLoading } = useCurrency({
34+
chainId: 1,
35+
currencyAddress: '0x...',
36+
query: {
37+
enabled: true
38+
}
39+
});
40+
```
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: useFilters
3+
description: Hook to fetch metadata filters for a collection Retrieves property filters for a collection from the metadata service, with support for marketplace-specific filter configuration including exclusion rules and custom ordering
4+
sidebarTitle: useFilters
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|--------------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.config` | `SdkConfig` | Configuration parameters |
12+
| `params.chainId` | `number` | The chain ID (must be a number, e.g., 1 for Ethereum, 137 for Polygon) |
13+
| `params.collectionAddress` | `string` | The collection contract address to fetch filters for |
14+
| `params.showAllFilters` | `boolean` | Whether to show all filters or apply marketplace filtering |
15+
| `params.excludePropertyValues` | `boolean` | Whether to exclude property values from the response |
16+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
17+
18+
## Returns
19+
20+
Query result containing property filters for the collection
21+
22+
## Example
23+
24+
Basic usage:
25+
```typescript
26+
const { data: filters, isLoading } = useFilters({
27+
chainId: 137,
28+
collectionAddress: '0x1234...'
29+
});
30+
31+
if (filters) {
32+
console.log(`Found ${filters.length} filters`);
33+
filters.forEach(filter => {
34+
console.log(`${filter.name}: ${filter.values?.join(', ')}`);
35+
});
36+
}
37+
```
38+
39+
With marketplace filtering disabled:
40+
```typescript
41+
const { data: allFilters } = useFilters({
42+
chainId: 1,
43+
collectionAddress: '0x5678...',
44+
showAllFilters: true, // Bypass marketplace filter rules
45+
query: {
46+
enabled: Boolean(selectedCollection),
47+
staleTime: 300000 // Cache for 5 minutes
48+
}
49+
});
50+
```
51+
52+
Exclude property values for faster loading:
53+
```typescript
54+
const { data: filterNames } = useFilters({
55+
chainId: 137,
56+
collectionAddress: collectionAddress,
57+
excludePropertyValues: true, // Only get filter names, not values
58+
query: {
59+
enabled: Boolean(collectionAddress)
60+
}
61+
})
62+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: useFloorOrder
3+
description: Hook to fetch the floor order for a collection Retrieves the lowest priced order (listing) currently available for any token in the specified collection from the marketplace
4+
sidebarTitle: useFloorOrder
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.config` | `SdkConfig` | Configuration parameters |
12+
| `params.chainId` | `number` | The chain ID (must be a number, e.g., 1 for Ethereum, 137 for Polygon) |
13+
| `params.collectionAddress` | `string` | The collection contract address |
14+
| `params.filter` | `OrdersFilter` | Optional filter criteria for collectibles |
15+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
16+
17+
## Returns
18+
19+
Query result containing the floor order data for the collection
20+
21+
## Example
22+
23+
Basic usage:
24+
25+
```typescript
26+
const { data, isLoading } = useFloorOrder({
27+
chainId: 137,
28+
collectionAddress: '0x...'
29+
});
30+
```
31+
32+
With filters and custom query options:
33+
34+
```typescript
35+
const { data, isLoading } = useFloorOrder({
36+
chainId: 1,
37+
collectionAddress: '0x...',
38+
filter: {
39+
minPrice: '1000000000000000000' // 1 ETH in wei
40+
},
41+
query: {
42+
refetchInterval: 30000,
43+
enabled: hasCollectionAddress
44+
}
45+
});
46+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: useGetCountOfFilteredOrders
3+
description: The useGetCountOfFilteredOrders hook returns the number of filtered orders in a collection
4+
sidebarTitle: useGetCountOfFilteredOrders
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.chainId` | `number` | The chain ID (e.g., 1 for Ethereum, 137 for Polygon) |
12+
| `params.collectionAddress` | `string` | The collection contract address |
13+
| `params.config` | `SdkConfig` | Optional SDK configuration parameters |
14+
| `params.side` | `OrderSide` | The order side to count (listing or offer) |
15+
| `params.filter` | `OrdersFilter` | Optional filter for the orders |
16+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
17+
18+
## Returns
19+
20+
Query result containing a number of filtered orders in a collection
21+
22+
## Import
23+
24+
```typescript
25+
import { useGetCountOfFilteredOrders } from "@0xsequence/marketplace-sdk/react";
26+
```
27+
28+
## Example
29+
30+
Basic usage:
31+
32+
```typescript
33+
const { data: countOfOrders } = useGetCountOfFilteredOrders({
34+
chainId,
35+
collectionAddress,
36+
side: OrderSide.listing,
37+
filter: {
38+
searchText,
39+
properties: filterOptions,
40+
}
41+
});
42+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: useGetCountOfPrimarySaleItems
3+
description: The useGetCountOfPrimarySaleItems hook returns the number of filtered primary sale items in a collection
4+
sidebarTitle: useGetCountOfPrimarySaleItems
5+
---
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|----------------------------|-----------------------------|----------------------------------------------------------------------------------------------|
11+
| `params.chainId` | `number` | The chain ID (e.g., 1 for Ethereum, 137 for Polygon) |
12+
| `params.collectionAddress` | `string` | The collection contract address |
13+
| `params.config` | `SdkConfig` | Optional SDK configuration parameters |
14+
| `params.side` | `OrderSide` | The order side to count (listing or offer) |
15+
| `params.filter` | `OrdersFilter` | Optional filter for the orders |
16+
| `params.query` | `StandardQueryOptions` | Optional React Query configuration (from TanStack Query) |
17+
18+
## Returns
19+
20+
A query result containing an object with a `count` property representing the number of filtered primary sale items in a collection.
21+
22+
## Import
23+
24+
```typescript
25+
import { useGetCountOfPrimarySaleItems } from "@0xsequence/marketplace-sdk/react";
26+
```
27+
28+
## Example
29+
30+
Basic usage:
31+
32+
```typescript
33+
const { data: countOfPrimarySalesItems } = useGetCountOfPrimarySaleItems({
34+
chainId: 1,
35+
primarySaleContractAddress: "0x00"
36+
});
37+
38+
console.log(countOfPrimarySalesItems?.count);
39+
```

0 commit comments

Comments
 (0)