Skip to content

Statistics ​

Tools for viewing operation statistics and logs.

xhs_get_account_stats ​

Get aggregated statistics for an account's operations.

Parameters ​

ParameterTypeRequiredDescription
accountstringYesAccount name or ID

Response ​

json
{
  "totalOperations": 150,
  "successfulOperations": 145,
  "failedOperations": 5,
  "successRate": 96.67,
  "operationsByAction": {
    "search": 50,
    "get_note": 40,
    "like": 30,
    "favorite": 15,
    "comment": 10,
    "publish_content": 5
  },
  "lastOperation": "2024-01-15T12:30:00Z"
}

Fields ​

FieldTypeDescription
totalOperationsnumberTotal operations performed
successfulOperationsnumberNumber of successful operations
failedOperationsnumberNumber of failed operations
successRatenumberSuccess rate percentage
operationsByActionobjectBreakdown by action type
lastOperationstringTimestamp of last operation

xhs_get_operation_logs ​

Query operation history for an account.

Parameters ​

ParameterTypeRequiredDescription
accountstringYesAccount name or ID
actionstringNoFilter by action type
limitnumberNoMax results (default: 50, max: 500)
offsetnumberNoSkip first N results

Example ​

Get all operations:

json
{
  "account": "my-account",
  "limit": 100
}

Get only search operations:

json
{
  "account": "my-account",
  "action": "search",
  "limit": 20
}

Paginate results:

json
{
  "account": "my-account",
  "limit": 50,
  "offset": 50
}

Response ​

json
{
  "logs": [
    {
      "id": 1234,
      "accountId": "uuid",
      "action": "search",
      "targetId": null,
      "params": { "keyword": "美食" },
      "result": { "count": 20 },
      "success": true,
      "error": null,
      "durationMs": 3500,
      "createdAt": "2024-01-15T12:30:00Z"
    },
    {
      "id": 1233,
      "accountId": "uuid",
      "action": "like",
      "targetId": "note-123",
      "params": { "noteId": "note-123" },
      "result": { "action": "like", "noteId": "note-123" },
      "success": true,
      "error": null,
      "durationMs": 2100,
      "createdAt": "2024-01-15T12:28:00Z"
    },
    {
      "id": 1232,
      "accountId": "uuid",
      "action": "publish_content",
      "targetId": null,
      "params": { "title": "My Post" },
      "result": null,
      "success": false,
      "error": "Upload failed",
      "durationMs": 15000,
      "createdAt": "2024-01-15T12:25:00Z"
    }
  ],
  "total": 150,
  "hasMore": true
}

Log Fields ​

FieldTypeDescription
idnumberLog entry ID
accountIdstringAccount UUID
actionstringAction type
targetIdstring?Target resource ID (e.g., note ID)
paramsobjectOperation parameters
resultobject?Operation result
successbooleanWhether operation succeeded
errorstring?Error message if failed
durationMsnumberOperation duration in milliseconds
createdAtstringTimestamp

Action Types ​

ActionDescription
searchSearch for notes
get_noteFetch note details
user_profileFetch user profile
list_feedsGet homepage feeds
likeLike a note
unlikeUnlike a note
favoriteFavorite a note
unfavoriteUnfavorite a note
commentPost a comment
replyReply to a comment
publish_contentPublish image note
publish_videoPublish video note
download_imagesDownload images
download_videoDownload video

Use Cases ​

Monitor Success Rate ​

Track account health:

json
xhs_get_account_stats({ account: "my-account" })

A declining success rate may indicate:

  • Session expiration
  • Rate limiting
  • Platform changes

Debug Failed Operations ​

Find failed operations:

json
xhs_get_operation_logs({
  account: "my-account",
  limit: 100
})

Then filter for success: false to investigate errors.

Audit Activity ​

Review all interactions with a specific note:

json
xhs_get_operation_logs({
  account: "my-account",
  action: "like"
})

Released under the MIT License.