FilBeamService
Defined in: packages/synapse-sdk/src/filbeam/service.ts:56
Service for interacting with FilBeam infrastructure and APIs.
Example
Section titled “Example”// Create service with network detectionconst synapse = await Synapse.create({ privateKey, rpcURL })const stats = await synapse.filbeam.getDataSetStats(12345)
// Monitor remaining pay-per-byte quotasconst service = new FilBeamService('mainnet')const stats = await service.getDataSetStats(12345)console.log('Remaining CDN Egress (cache hits):', stats.cdnEgressQuota)console.log('Remaining Cache Miss Egress:', stats.cacheMissEgressQuota)Remarks
Section titled “Remarks”All quota values are returned as BigInt for precision when handling large byte values.
FilBeam Documentation for detailed API specifications and usage guides
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FilBeamService(network, fetchImpl): FilBeamService;Defined in: packages/synapse-sdk/src/filbeam/service.ts:60
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
network | FilecoinNetworkType | undefined |
fetchImpl | (input, init?) => Promise<Response> | globalThis.fetch |
Returns
Section titled “Returns”FilBeamService
Methods
Section titled “Methods”getDataSetStats()
Section titled “getDataSetStats()”getDataSetStats(dataSetId): Promise<DataSetStats>;Defined in: packages/synapse-sdk/src/filbeam/service.ts:130
Retrieves remaining pay-per-byte statistics for a specific data set from FilBeam.
Fetches the remaining CDN and cache miss egress quotas for a data set. These quotas track how many bytes can still be retrieved through FilBeam’s trusted measurement layer before needing to add more credits:
- CDN Egress Quota: Remaining bytes that can be served from FilBeam’s cache (fast, direct delivery)
- Cache Miss Egress Quota: Remaining bytes that can be retrieved from storage providers (triggers caching)
Both types of egress are billed at approximately 0.014 USDFC per GiB, with storage providers receiving 7 USDFC per TiB for data served to FilBeam.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | string | number | The unique identifier of the data set to query |
Returns
Section titled “Returns”A promise that resolves to the data set statistics with remaining quotas as BigInt values
Throws
Section titled “Throws”Throws an error if:
- The data set is not found (404)
- The API returns an invalid response format
- Network or other HTTP errors occur
Example
Section titled “Example”try { const stats = await service.getDataSetStats('my-dataset-123')
// Display remaining quotas console.log(`Remaining CDN Egress: ${stats.cdnEgressQuota} bytes`) console.log(`Remaining Cache Miss: ${stats.cacheMissEgressQuota} bytes`)} catch (error) { console.error('Failed to get stats:', error.message)}