This section provides a detailed reference for all GraphQL queries related to networking and services on the Blocklet Server. These methods allow you to fetch data and configurations for routing, domains, certificates, webhooks, and notifications. For operations that modify these settings, please see the Networking & Services Mutations section.
Notifications
Queries for managing and retrieving notifications.
getNotifications
Retrieves a list of notifications based on specified filters.
Parameters
- input
RequestGetNotificationsInput(required) — An object containing filter criteria.- receiver
string— Filter by notification receiver DID. - sender
string— Filter by notification sender DID. - read
boolean— Filter by read status. - paging
PagingInput— Pagination options. - teamDid
string— The DID of the team/blocklet. - severity
string[]— Filter by severity levels (e.g., 'info', 'error'). - componentDid
string[]— Filter by component DID. - entityId
string[]— Filter by entity ID. - source
string[]— Filter by source (e.g., 'system', 'component').
- receiver
Returns
Returns a Promise that resolves to a ResponseGetNotifications object containing the list of notifications and pagination details.
Request Example
getNotifications Example
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchUnreadNotifications() {
try {
const response = await client.getNotifications({
input: {
read: false,
paging: { pageSize: 10, page: 1 },
},
});
console.log('Unread notifications:', response.list);
console.log('Unread count:', response.unreadCount);
} catch (error) {
console.error('Error fetching notifications:', error);
}
}
fetchUnreadNotifications();Response Example
Response
{
"code": "ok",
"list": [
{
"id": "...",
"title": "New Update Available",
"description": "A new version of your blocklet is ready to be installed.",
"read": false,
"createdAt": 1678886400
}
],
"paging": {
"total": 5,
"pageSize": 10,
"pageCount": 1,
"page": 1
},
"unreadCount": 5
}makeAllNotificationsAsRead
Marks all notifications that match the given criteria as read.
Parameters
- input
RequestMakeAllNotificationsAsReadInput(required) — An object containing filter criteria for which notifications to mark as read.- receiver
string(required) — The DID of the notification receiver. - teamDid
string— The DID of the team/blocklet. - severity
string— (Optional) Filter by a specific severity level. - componentDid
string— (Optional) Filter by a specific component DID. - entityId
string— (Optional) Filter by a specific entity ID. - source
string— (Optional) Filter by a specific source.
- receiver
Returns
Returns a Promise that resolves to a ResponseMakeAllNotificationsAsRead object indicating the number of notifications affected.
Request Example
makeAllNotificationsAsRead Example
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function markAllAsRead() {
try {
const response = await client.makeAllNotificationsAsRead({
input: { receiver: 'z8iZ...aYp' },
});
console.log(`Marked ${response.data.numAffected} notifications as read.`);
} catch (error) {
console.error('Error marking notifications as read:', error);
}
}
markAllAsRead();Response Example
Response
{
"code": "ok",
"data": {
"numAffected": 5,
"notificationIds": ["...", "..."]
}
}getNotificationSendLog
Retrieves the send log for notifications, allowing you to track delivery status across different channels.
Parameters
- input
RequestNotificationSendLogInput(required) — An object containing filter criteria for the send log.- teamDid
string(required) — The DID of the team/blocklet. - dateRange
string[]— Filter logs within a specific date range (e.g., ['2023-01-01', '2023-01-31']). - paging
PagingInput— Pagination options. - source
string— Filter by notification source. - componentDids
string[]— Filter by an array of component DIDs. - severities
string[]— Filter by an array of severity levels.
- teamDid
Returns
Returns a Promise that resolves to a ResponseNotificationSendLog object containing the list of notification logs and pagination details.
getReceivers
Retrieves a list of notification receivers based on various filter criteria, such as their send status for different channels.
Parameters
- input
RequestReceiversInput(required) — An object containing filter criteria for receivers.- teamDid
string(required) — The DID of the team/blocklet. - notificationId
string— Filter receivers for a specific notification. - userName
string— Search for receivers by their name. - userDid
string— Filter by a specific user DID. - walletSendStatus
number[]— Filter by wallet send status codes. - pushKitSendStatus
number[]— Filter by push notification send status codes. - emailSendStatus
number[]— Filter by email send status codes. - dateRange
string[]— Filter receivers within a specific date range. - paging
PagingInput— Pagination options.
- teamDid
Returns
Returns a Promise that resolves to a ResponseReceivers object containing the list of receivers and pagination details.
getNotificationComponents
Retrieves a list of component DIDs that have sent notifications.
Parameters
- input
RequestNotificationComponentsInput(required) — An object containing filter criteria.- teamDid
string(required) — The DID of the team/blocklet. - receiver
string— Filter by the DID of the notification receiver.
- teamDid
Returns
Returns a Promise that resolves to a ResponseNotificationComponents object containing an array of component DIDs.
resendNotification
Triggers a resend of a specific notification to designated receivers and channels.
Parameters
- input
RequestResendNotificationInput(required) — An object containing the details for the resend operation.- teamDid
string(required) — The DID of the team/blocklet. - notificationId
string(required) — The ID of the notification to resend. - receivers
string[]— A list of user DIDs to resend the notification to. - channels
string[]— A list of channels to use for resending (e.g., 'wallet', 'email'). - webhookUrls
string[]— A list of specific webhook URLs to resend to. - resendFailedOnly
boolean— If true, only resends to receivers who previously failed to receive the notification.
- teamDid
Returns
Returns a Promise that resolves to a ResponseResendNotification object.
Routing & Domains
Queries for managing routing rules and domain configurations.
getRoutingSites
Retrieves the list of all configured routing sites.
Parameters
- input
RequestGetRoutingSitesInput— An object containing filter criteria.- snapshotHash
string— (Optional) If provided, retrieves the routing sites from a specific historical snapshot.
- snapshotHash
Returns
Returns a Promise that resolves to a ResponseGetRoutingSites object containing an array of RoutingSite objects.
Request Example
getRoutingSites Example
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchRoutingSites() {
try {
const response = await client.getRoutingSites();
console.log('Routing sites:', response.sites);
} catch (error) {
console.error('Error fetching routing sites:', error);
}
}
fetchRoutingSites();Response Example
Response
{
"code": "ok",
"sites": [
{
"id": "...",
"domain": "example.com",
"domainAliases": [{"value": "www.example.com"}],
"rules": [/* ... */]
}
]
}getRoutingSnapshots
Retrieves a list of historical snapshots of the routing configuration.
Parameters
- input
RequestGetRoutingSnapshotsInput— An object containing filter criteria.- limit
number— The maximum number of snapshots to return.
- limit
Returns
Returns a Promise that resolves to a ResponseGetRoutingSnapshots object containing an array of RoutingSnapshot objects.
getSnapshotSites
Retrieves the routing sites from a specific snapshot hash.
Parameters
- input
RequestGetSnapshotSitesInput(required) — An object containing the snapshot hash.- hash
string(required) — The hash of the snapshot to retrieve.
- hash
Returns
Returns a Promise that resolves to a ResponseGetSnapshotSites object containing an array of RoutingSite objects from that snapshot.
getRoutingProviders
Retrieves a list of available routing providers (e.g., Nginx) and their current status.
Returns
Returns a Promise that resolves to a ResponseGetRoutingProviders object containing an array of RoutingProvider objects.
isDidDomain
Checks if a given domain is a DID-based domain.
Parameters
- input
RequestIsDidDomainInput(required)- domain
string(required) — The domain to check.
- domain
Returns
Returns a Promise that resolves to a ResponseIsDidDomain object with a boolean value indicating the result.
getDomainDNS
Checks the DNS resolution status for a given domain, verifying if it points correctly to the Blocklet Server.
Parameters
- input
RequestDomainDNSInput(required)- teamDid
string(required) — The DID of the team/blocklet associated with the domain. - domain
string(required) — The domain to check.
- teamDid
Returns
Returns a Promise that resolves to a ResponseDomainDNS object detailing the DNS status.
Certificates
Queries for managing SSL/TLS certificates.
getCertificates
Retrieves all SSL certificates installed on the node.
Returns
Returns a Promise that resolves to a ResponseGetCertificates object containing an array of Certificate objects.
Request Example
getCertificates Example
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function listCertificates() {
try {
const response = await client.getCertificates();
console.log('Installed certificates:', response.certificates);
} catch (error) {
console.error('Error fetching certificates:', error);
}
}
listCertificates();Response Example
Response
{
"code": "ok",
"certificates": [
{
"id": "...",
"name": "example.com-cert",
"domain": "example.com",
"source": "letsencrypt",
"status": "valid"
}
]
}findCertificateByDomain
Finds a specific certificate by its associated domain name.
Parameters
- input
RequestFindCertificateByDomainInput(required)- domain
string(required) — The domain name associated with the certificate. - did
string— (Optional) The DID of the blocklet to narrow down the search.
- domain
Returns
Returns a Promise that resolves to a ResponseFindCertificateByDomain object containing the Certificate if found.
checkDomains
Checks the status and validity of multiple domains at once, often used before issuing certificates.
Parameters
- input
RequestCheckDomainsInput(required)- domains
string[](required) — An array of domain names to check. - did
string— (Optional) The DID of the blocklet.
- domains
Returns
Returns a Promise that resolves to a ResponseCheckDomains object indicating the status of the check.
Webhooks
Queries for managing webhooks and their senders.
getWebHooks
Retrieves a list of all configured webhooks.
Returns
Returns a Promise that resolves to a ResponseWebHooks object containing an array of WebHook objects.
Request Example
getWebHooks Example
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function listWebhooks() {
try {
const response = await client.getWebHooks();
console.log('Configured webhooks:', response.webhooks);
} catch (error) {
console.error('Error fetching webhooks:', error);
}
}
listWebhooks();Response Example
Response
{
"code": "ok",
"webhooks": [
{
"id": "...",
"type": "slack",
"params": [{"name": "url", "value": "https://hooks.slack.com/..."}]
}
]
}getWebhookSenders
Retrieves a list of available webhook sender types (e.g., Slack, API) and their required parameters.
Returns
Returns a Promise that resolves to a ResponseSenderList object containing an array of WebHookSender objects.
sendTestMessage
Sends a test message to a specified webhook to verify its configuration.
Parameters
- input
RequestSendMsgInput(required)- webhookId
string(required) — The ID of the webhook to test. - message
string(required) — The test message content.
- webhookId
Returns
Returns a Promise that resolves to a ResponseSendMsg object indicating the result of the operation.
getWebhookEndpoints
Retrieves a paginated list of configured webhook endpoints.
Parameters
- input
RequestGetWebhookEndpointsInput(required)- teamDid
string(required) — The DID of the team/blocklet. - paging
PagingInput— Pagination options.
- teamDid
Returns
Returns a Promise that resolves to a ResponseGetWebhookEndpoints object.
getWebhookEndpoint
Retrieves a single webhook endpoint by its ID.
Parameters
- input
RequestGetWebhookEndpointInput(required)- teamDid
string(required) — The DID of the team/blocklet. - id
string(required) — The ID of the webhook endpoint.
- teamDid
Returns
Returns a Promise that resolves to a ResponseGetWebhookEndpoint object.
getWebhookAttempts
Retrieves the delivery attempt history for a specific webhook event.
Parameters
- input
RequestGetWebhookAttemptsInput(required)- teamDid
string(required) — The DID of the team/blocklet. - input
RequestAttemptIdInput(required) — Object containing the eventId and webhookId.- eventId
string(required) — The ID of the event. - webhookId
string(required) — The ID of the webhook.
- eventId
- paging
PagingInput— Pagination options.
- teamDid
Returns
Returns a Promise that resolves to a ResponseGetWebhookAttempts object.
You have now reviewed the queries for managing networking and services. To explore how to fetch data related to backups, logs, and analytics, proceed to the Data & Operations section.