Content Watcher Service
The Content Watcher Service monitors and retrieves the latest feed state, including content updates, reactions, and other user interactions on the Frequency network. It ensures that applications can stay up-to-date with the latest content and user activity.
API Reference
Path Table
Method | Path | Description |
---|---|---|
POST | /v1/scanner/reset | Reset blockchain scan to a specific block number or offset from the current position |
GET | /v1/scanner/options | Get the current watch options for the blockchain content event scanner |
POST | /v1/scanner/options | Set watch options to filter the blockchain content scanner by schemas or MSA Ids |
POST | /v1/scanner/pause | Pause the blockchain scanner |
POST | /v1/scanner/start | Resume the blockchain content event scanner |
POST | /v1/search | Search for DSNP content by id, start/end block, and filters |
PUT | /v1/webhooks | Register a webhook to be called when new content is encountered on the chain |
DELETE | /v1/webhooks | Clear all previously registered webhooks |
GET | /v1/webhooks | Get the list of currently registered webhooks |
GET | /healthz | Check the health status of the service |
GET | /livez | Check the live status of the service |
GET | /readyz | Check the ready status of the service |
Reference Table
Name | Path | Description |
---|---|---|
ResetScannerDto | #/components/schemas/ResetScannerDto | |
ChainWatchOptionsDto | #/components/schemas/ChainWatchOptionsDto | |
ContentSearchRequestDto | #/components/schemas/ContentSearchRequestDto | |
AnnouncementTypeName | #/components/schemas/AnnouncementTypeName | Announcement types to send to the webhook |
WebhookRegistrationDto | #/components/schemas/WebhookRegistrationDto |
Path Details
[POST]/v1/scanner/reset
- Summary
Reset blockchain scan to a specific block number or offset from the current position
RequestBody
- application/json
{
// The block number to reset the scanner to
blockNumber?: number
// Number of blocks to rewind the scanner to (from `blockNumber` if supplied; else from latest block)
rewindOffset?: number
// Whether to schedule the new scan immediately or wait for the next scheduled interval
immediate?: boolean
}
Responses
- 201
[GET]/v1/scanner/options
- Summary
Get the current watch options for the blockchain content event scanner
Responses
- 200
application/json
{
schemaIds?: number[]
dsnpIds?: string[]
}
[POST]/v1/scanner/options
- Summary
Set watch options to filter the blockchain content scanner by schemas or MSA Ids
RequestBody
- application/json
{
schemaIds?: number[]
dsnpIds?: string[]
}
Responses
- 201
[POST]/v1/scanner/pause
- Summary
Pause the blockchain scanner
Responses
- 201
[POST]/v1/scanner/start
- Summary
Resume the blockchain content event scanner
Parameters(Query)
immediate?: boolean
Responses
- 201
[POST]/v1/search
- Summary
Search for DSNP content by id, start/end block, and filters
RequestBody
- application/json
{
// An optional client-supplied reference ID by which it can identify the result of this search
clientReferenceId?: string
// The block number to search (backward) from
startBlock?: number
// The number of blocks to scan (backwards)
blockCount: number
// The schemaIds/dsnpIds to filter by
filters?: #/components/schemas/ChainWatchOptionsDto
// A webhook URL to be notified of the results of this search
webhookUrl: string
}
Responses
- 200 Returns a jobId to be used to retrieve the results
application/json
{
"type": "string"
}
[PUT]/v1/webhooks
- Summary
Register a webhook to be called when new content is encountered on the chain
RequestBody
- application/json
{
// Webhook URL
url: string
// Announcement types to send to the webhook
announcementTypes?: enum[tombstone, broadcast, reply, reaction, profile, update][]
}
Responses
- 200
[DELETE]/v1/webhooks
- Summary
Clear all previously registered webhooks
Responses
- 200
[GET]/v1/webhooks
- Summary
Get the list of currently registered webhooks
Responses
- 200 Returns a list of registered webhooks
application/json
{
// Webhook URL
url: string
// Announcement types to send to the webhook
announcementTypes?: enum[tombstone, broadcast, reply, reaction, profile, update][]
}[]
[GET]/healthz
- Summary
Check the health status of the service
Responses
- 200 Service is healthy
[GET]/livez
- Summary
Check the live status of the service
Responses
- 200 Service is live
[GET]/readyz
- Summary
Check the ready status of the service
Responses
- 200 Service is ready
References
#/components/schemas/ResetScannerDto
{
// The block number to reset the scanner to
blockNumber?: number
// Number of blocks to rewind the scanner to (from `blockNumber` if supplied; else from latest block)
rewindOffset?: number
// Whether to schedule the new scan immediately or wait for the next scheduled interval
immediate?: boolean
}
#/components/schemas/ChainWatchOptionsDto
{
schemaIds?: number[]
dsnpIds?: string[]
}
#/components/schemas/ContentSearchRequestDto
{
// An optional client-supplied reference ID by which it can identify the result of this search
clientReferenceId?: string
// The block number to search (backward) from
startBlock?: number
// The number of blocks to scan (backwards)
blockCount: number
// The schemaIds/dsnpIds to filter by
filters?: #/components/schemas/ChainWatchOptionsDto
// A webhook URL to be notified of the results of this search
webhookUrl: string
}
#/components/schemas/AnnouncementTypeName
{
"type": "string",
"description": "Announcement types to send to the webhook",
"enum": [
"tombstone",
"broadcast",
"reply",
"reaction",
"profile",
"update"
]
}
#/components/schemas/WebhookRegistrationDto
{
// Webhook URL
url: string
// Announcement types to send to the webhook
announcementTypes?: enum[tombstone, broadcast, reply, reaction, profile, update][]
}
Configuration
ℹ️ Feel free to adjust your environment variables to taste. This application recognizes the following environment variables:
Name | Description | Range/Type | Required? | Default |
---|---|---|---|---|
API_PORT | HTTP port that the application listens on | 1025 - 65535 | 3000 | |
BLOCKCHAIN_SCAN_INTERVAL_SECONDS | How many seconds to delay between successive scans of the chain for new content (after end of chain is reached) | > 0 | 12 | |
CACHE_KEY_PREFIX | Prefix to use for Redis cache keys | string | content-watcher: | |
FREQUENCY_URL | Blockchain node address | http(s): or ws(s): URL | Y | |
IPFS_BASIC_AUTH_SECRET | If required for read requests, put Infura auth token here, or leave blank for default Kubo RPC | string | N | blank |
IPFS_BASIC_AUTH_USER | If required for read requests, put Infura Project ID here, or leave blank for default Kubo RPC | string | N | blank |
IPFS_ENDPOINT | URL to IPFS endpoint | URL | Y | |
IPFS_GATEWAY_URL | IPFS gateway URL '[CID]' is a token that will be replaced with an actual content ID | URL template | Y | |
QUEUE_HIGH_WATER | Max number of jobs allowed on the queue before blockchain scan will be paused to allow queue to drain | >= 100 | 1000 | |
REDIS_URL | Connection URL for Redis | URL | Y | |
STARTING_BLOCK | Block number from which the service will start scanning the chain | > 0 | 1 | |
WEBHOOK_FAILURE_THRESHOLD | Number of failures allowed in the provider webhook before the service is marked down | > 0 | 3 | |
WEBHOOK_RETRY_INTERVAL_SECONDS | Number of seconds between provider webhook retry attempts when failing | > 0 | 10 |
Best Practices
- Efficient Polling: Implement efficient polling mechanisms to minimize load on the service.
- Webhook Security: Secure webhooks by verifying the source of incoming requests.
- Rate Limiting: Apply rate limiting to prevent abuse and ensure fair usage of the service.