Networking & Services
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
An object containing filter criteria.
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
An object containing filter criteria for which notifications to mark as read.
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
An object containing filter criteria for the send log.
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
An object containing filter criteria for receivers.
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
An object containing filter criteria.
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
An object containing the details for the resend operation.
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
An object containing filter criteria.
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
An object containing filter criteria.
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
An object containing the snapshot 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
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
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
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
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
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
Returns
Returns a Promise that resolves to a ResponseGetWebhookEndpoints object.
getWebhookEndpoint#
Retrieves a single webhook endpoint by its ID.
Parameters
Returns
Returns a Promise that resolves to a ResponseGetWebhookEndpoint object.
getWebhookAttempts#
Retrieves the delivery attempt history for a specific webhook event.
Parameters
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.