getProvidersByProductType
getProvidersByProductType(
client,options):Promise<OutputType>
Defined in: packages/synapse-core/src/sp-registry/get-providers-by-product-type.ts:83
Get one bounded page of providers offering a product type.
Pass the returned nextCursor back as cursor; treat it as opaque. Use
paginate to traverse every page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain> | The client to use to get the providers. |
options | OptionsType | getProvidersByProductType.OptionsType |
Returns
Section titled “Returns”The paginated providers result getProvidersByProductType.OutputType
Throws
Section titled “Throws”Errors getProvidersByProductType.ErrorType
Examples
Section titled “Examples”Read the first page
import { getProvidersByProductType } from '@filoz/synapse-core/sp-registry'import { createPublicClient, http } from 'viem'import { calibration } from '@filoz/synapse-core/chains'
const client = createPublicClient({ chain: calibration, transport: http(),})
const page = await getProvidersByProductType(client, { productType: 0, // ProductType.PDP onlyActive: true,})console.log(page.items, page.nextCursor)Iterate over every page
import { paginate } from '@filoz/synapse-core'import { getProvidersByProductType } from '@filoz/synapse-core/sp-registry'
for await (const provider of paginate(({ cursor }) => getProvidersByProductType(client, { productType: 0, // ProductType.PDP onlyActive: true, cursor, }))) { console.log(provider.providerId)}