This section provides detailed references for GraphQL queries used to fetch operational data from your Blocklet Server. These queries are essential for monitoring system health, managing backups, auditing activities, and gaining insights into traffic patterns. For mutations related to data and operations, see the Data & Operations Mutations section.
Backups
Manage and monitor blocklet backup records.
getBlockletBackups
Retrieves a list of backup records for a specific blocklet, optionally filtered by a time range.
Parameters
- input
RequestGetBlockletBackupsInput(required) — An object containing the query parameters.- did
string(required) — The DID of the blocklet to retrieve backups for. - startTime
string— The start of the time range for the backup records. - endTime
string— The end of the time range for the backup records.
- did
Example Usage
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const backups = await client.getBlockletBackups({
input: { did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC' }
});
console.log(backups);Example Response
{
"code": "ok",
"backups": [
{
"appPid": "z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC",
"userDid": "z1...",
"strategy": 1,
"sourceUrl": "/path/to/backup",
"target": "disk",
"targetName": "Local Disk",
"targetUrl": "/path/to/backup/target",
"createdAt": 1678886400,
"updatedAt": 1678886400,
"status": 1,
"message": "Backup completed successfully",
"progress": 100,
"metadata": {}
}
]
}getBlockletBackupSummary
Retrieves a summary of backup activities, including success and error counts, for a blocklet within a specified time range, grouped by date.
Parameters
- input
RequestGetBlockletBackupSummaryInput(required) — An object containing the query parameters.- did
string(required) — The DID of the blocklet. - startTime
string— The start of the time range for the backup summary. - endTime
string— The end of the time range for the backup summary.
- did
Example Usage
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const summary = await client.getBlockletBackupSummary({
input: { did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC' }
});
console.log(summary);Example Response
{
"code": "ok",
"summary": [
{
"date": "2023-03-15",
"successCount": 5,
"errorCount": 1
}
]
}Logs
Access audit and activity logs for monitoring and troubleshooting.
getAuditLogs
Fetches a paginated list of audit logs, allowing you to track activities across the node. You can filter logs by scope, category, and content.
Parameters
- input
RequestGetAuditLogsInput— An object containing the query parameters.- paging
PagingInput— Pagination options. - scope
string— Filter by scope (e.g., 'node', 'z8ia...'). - category
string— Filter by category (e.g., 'user', 'blocklet'). - actionOrContent
string— Search string for action or content fields.
- paging
Example Usage
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const logs = await client.getAuditLogs({
input: {
paging: { page: 1, pageSize: 10 },
category: 'user'
}
});
console.log(logs);Example Response
{
"code": "ok",
"list": [
{
"id": "...",
"scope": "node",
"category": "user",
"action": "login",
"content": "User z1... logged in",
"actor": {
"did": "z1...",
"role": "owner",
"fullName": "Alice"
},
"env": {},
"createdAt": 1678886400,
"ip": "127.0.0.1",
"ua": "Mozilla/5.0..."
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}getPassportLogs
Retrieves activity logs for a specific passport, tracking actions such as issuance, revocation, and usage.
Parameters
- input
RequestPassportLogInput(required) — An object containing the query parameters.- teamDid
string(required) — The DID of the team or blocklet. - query
PassportLogQueryInput(required) — Query filters.- passportId
string(required) — The ID of the passport to retrieve logs for.
- passportId
- paging
PagingInput— Pagination options.
- teamDid
Example Usage
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const logs = await client.getPassportLogs({
input: {
teamDid: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC',
query: { passportId: 'zpassport_...' },
paging: { page: 1, pageSize: 10 }
}
});
console.log(logs);Example Response
{
"passportLogs": [
{
"id": 1,
"passportId": "zpassport_...",
"action": "issued",
"operatorIp": "127.0.0.1",
"operatorUa": "Mozilla/5.0...",
"operatorDid": "z1...",
"metadata": {},
"createdAt": 1678886400
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}Analytics & Insights
Gain insights into blocklet performance and usage.
getTrafficInsights
Provides traffic analytics for a specific blocklet, including request counts, unique visitors, and bandwidth usage within a specified date range.
Parameters
- input
RequestGetTrafficInsightsInput(required) — An object containing the query parameters.- did
string(required) — The DID of the blocklet. - startDate
string— Start date for the analytics period (e.g., 'YYYY-MM-DD'). - endDate
string— End date for the analytics period (e.g., 'YYYY-MM-DD'). - paging
PagingInput— Pagination options.
- did
Example Usage
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const insights = await client.getTrafficInsights({
input: {
did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC',
startDate: '2023-01-01',
endDate: '2023-01-31'
}
});
console.log(insights);Example Response
{
"code": "ok",
"list": [
{
"did": "z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC",
"date": "2023-01-15",
"totalRequests": 1500,
"uniqueVisitors": 200,
"bandwidth": 512000000
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}You now have the tools to query operational data from your Blocklet Server. To learn how to manage publishing workflows and project resources, proceed to the Publishing & Projects section.