DTMWiki 编曲中文百科
首页 chevron_right 百科 chevron_right 接口文档

接口文档

person authentik Default Admin schedule 更新于 2025-05-21

WikiJS API接口文档

WikiJS提供了一套完整的GraphQL API,可用于查询和修改系统中的各种资源。本文档将对主要的API模块进行解析并提供调用示例。

目录

基础知识

GraphQL端点

WikiJS的GraphQL API端点通常为:

https://<your-wiki-domain>/graphql

身份验证

大多数API请求需要身份验证,通过以下两种方式之一:

  1. JWT令牌:通过登录API获取JWT令牌,然后在请求头中添加:

    Authorization: Bearer <your-jwt-token>
    
  2. API密钥:通过管理界面创建API密钥,然后在请求头中添加:

    Authorization: Bearer <your-api-key>
    

基本curl请求格式

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "YOUR_GRAPHQL_QUERY"}' \
  https://your-wiki-domain/graphql

身份验证 (Authentication)

查询当前身份验证策略

query {
  authentication {
    strategies {
      key
      title
      description
      isAvailable
    }
    apiState
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "query { authentication { strategies { key title description isAvailable } apiState } }"}' \
  https://your-wiki-domain/graphql

获取活跃的身份验证策略

query {
  authentication {
    activeStrategies(enabledOnly: true) {
      key
      displayName
      order
      isEnabled
      strategy {
        key
        title
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { authentication { activeStrategies(enabledOnly: true) { key displayName order isEnabled strategy { key title } } } }"}' \
  https://your-wiki-domain/graphql

登录

mutation {
  authentication {
    login(
      username: "your-username"
      password: "your-password"
      strategy: "local"
    ) {
      responseResult {
        succeeded
        errorCode
        slug
        message
      }
      jwt
      mustChangePwd
      mustProvideTFA
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { authentication { login(username: \"your-username\", password: \"your-password\", strategy: \"local\") { responseResult { succeeded errorCode slug message } jwt mustChangePwd mustProvideTFA } } }"}' \
  https://your-wiki-domain/graphql

注册新用户

mutation {
  authentication {
    register(
      email: "new.user@example.com"
      password: "SecurePassword123"
      name: "New User"
    ) {
      responseResult {
        succeeded
        errorCode
        slug
        message
      }
      jwt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { authentication { register(email: \"new.user@example.com\", password: \"SecurePassword123\", name: \"New User\") { responseResult { succeeded errorCode slug message } jwt } } }"}' \
  https://your-wiki-domain/graphql

忘记密码

mutation {
  authentication {
    forgotPassword(
      email: "user@example.com"
    ) {
      responseResult {
        succeeded
        errorCode
        slug
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { authentication { forgotPassword(email: \"user@example.com\") { responseResult { succeeded errorCode slug message } } } }"}' \
  https://your-wiki-domain/graphql

双因素认证登录

mutation {
  authentication {
    loginTFA(
      continuationToken: "token-from-login-response"
      securityCode: "123456"
      setup: false
    ) {
      responseResult {
        succeeded
        errorCode
        slug
        message
      }
      jwt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { authentication { loginTFA(continuationToken: \"token-from-login-response\", securityCode: \"123456\", setup: false) { responseResult { succeeded errorCode slug message } jwt } } }"}' \
  https://your-wiki-domain/graphql

登录时更改密码

mutation {
  authentication {
    loginChangePassword(
      continuationToken: "token-from-login-response"
      newPassword: "NewSecurePassword123"
    ) {
      responseResult {
        succeeded
        errorCode
        slug
        message
      }
      jwt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "mutation { authentication { loginChangePassword(continuationToken: \"token-from-login-response\", newPassword: \"NewSecurePassword123\") { responseResult { succeeded errorCode slug message } jwt } } }"}' \
  https://your-wiki-domain/graphql

创建API密钥

mutation {
  authentication {
    createApiKey(
      name: "My API Key"
      expiration: "2025-12-31"
      fullAccess: true
    ) {
      responseResult {
        succeeded
      }
      key
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{"query": "mutation { authentication { createApiKey(name: \"My API Key\", expiration: \"2025-12-31\", fullAccess: true) { responseResult { succeeded } key } } }"}' \
  https://your-wiki-domain/graphql

吊销API密钥

mutation {
  authentication {
    revokeApiKey(id: 1) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { authentication { revokeApiKey(id: 1) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

设置API状态

mutation {
  authentication {
    setApiState(enabled: true) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { authentication { setApiState(enabled: true) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

更新身份验证策略

mutation {
  authentication {
    updateStrategies(
      strategies: [
        {
          key: "local"
          strategyKey: "local"
          displayName: "本地账户"
          order: 1
          isEnabled: true
          selfRegistration: true
          domainWhitelist: []
          autoEnrollGroups: [2]
          config: []
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { authentication { updateStrategies(strategies: [{key: \"local\", strategyKey: \"local\", displayName: \"本地账户\", order: 1, isEnabled: true, selfRegistration: true, domainWhitelist: [], autoEnrollGroups: [2], config: []}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

重新生成证书

mutation {
  authentication {
    regenerateCertificates {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { authentication { regenerateCertificates { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

重置访客用户

mutation {
  authentication {
    resetGuestUser {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { authentication { resetGuestUser { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

用户管理 (Users)

获取用户列表

query {
  users {
    list {
      id
      name
      email
      providerKey
      isActive
      createdAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { users { list { id name email providerKey isActive createdAt } } }"}' \
  https://your-wiki-domain/graphql

搜索用户

query {
  users {
    search(query: "john") {
      id
      name
      email
      isActive
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { users { search(query: \"john\") { id name email isActive } } }"}' \
  https://your-wiki-domain/graphql

获取单个用户

query {
  users {
    single(id: 1) {
      id
      name
      email
      isActive
      isVerified
      location
      jobTitle
      timezone
      dateFormat
      providerKey
      tfaIsActive
      lastLoginAt
      groups {
        id
        name
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { users { single(id: 1) { id name email isActive isVerified location jobTitle timezone dateFormat providerKey tfaIsActive lastLoginAt groups { id name } } } }"}' \
  https://your-wiki-domain/graphql

获取当前用户资料

query {
  users {
    profile {
      id
      name
      email
      location
      jobTitle
      timezone
      dateFormat
      appearance
      groups
      pagesTotal
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { users { profile { id name email location jobTitle timezone dateFormat appearance groups pagesTotal } } }"}' \
  https://your-wiki-domain/graphql

获取最近登录用户

query {
  users {
    lastLogins {
      id
      name
      lastLoginAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { users { lastLogins { id name lastLoginAt } } }"}' \
  https://your-wiki-domain/graphql

创建用户

mutation {
  users {
    create(
      email: "new.user@example.com"
      name: "New User"
      passwordRaw: "SecurePassword123"
      providerKey: "local"
      groups: [1, 2]
      mustChangePassword: true
      sendWelcomeEmail: true
    ) {
      responseResult {
        succeeded
        message
      }
      user {
        id
        name
        email
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { create(email: \"new.user@example.com\", name: \"New User\", passwordRaw: \"SecurePassword123\", providerKey: \"local\", groups: [1, 2], mustChangePassword: true, sendWelcomeEmail: true) { responseResult { succeeded message } user { id name email } } } }"}' \
  https://your-wiki-domain/graphql

更新用户

mutation {
  users {
    update(
      id: 1
      email: "updated.email@example.com"
      name: "Updated Name"
      groups: [1, 3, 5]
      location: "北京"
      jobTitle: "开发工程师"
      timezone: "Asia/Shanghai"
      dateFormat: "YYYY/MM/DD"
      appearance: "dark"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { update(id: 1, email: \"updated.email@example.com\", name: \"Updated Name\", groups: [1, 3, 5], location: \"北京\", jobTitle: \"开发工程师\", timezone: \"Asia/Shanghai\", dateFormat: \"YYYY/MM/DD\", appearance: \"dark\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

删除用户

mutation {
  users {
    delete(
      id: 5
      replaceId: 1
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { delete(id: 5, replaceId: 1) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

验证用户

mutation {
  users {
    verify(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { verify(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

激活用户

mutation {
  users {
    activate(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { activate(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

停用用户

mutation {
  users {
    deactivate(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { deactivate(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

启用双因素认证

mutation {
  users {
    enableTFA(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { enableTFA(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

禁用双因素认证

mutation {
  users {
    disableTFA(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { disableTFA(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

重置用户密码

mutation {
  users {
    resetPassword(id: 5) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { resetPassword(id: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

更新当前用户资料

mutation {
  users {
    updateProfile(
      name: "My Name"
      location: "上海"
      jobTitle: "产品经理"
      timezone: "Asia/Shanghai"
      dateFormat: "YYYY-MM-DD"
      appearance: "light"
    ) {
      responseResult {
        succeeded
        message
      }
      jwt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { updateProfile(name: \"My Name\", location: \"上海\", jobTitle: \"产品经理\", timezone: \"Asia/Shanghai\", dateFormat: \"YYYY-MM-DD\", appearance: \"light\") { responseResult { succeeded message } jwt } } }"}' \
  https://your-wiki-domain/graphql

修改当前用户密码

mutation {
  users {
    changePassword(
      current: "CurrentPassword123"
      new: "NewPassword456"
    ) {
      responseResult {
        succeeded
        message
      }
      jwt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { users { changePassword(current: \"CurrentPassword123\", new: \"NewPassword456\") { responseResult { succeeded message } jwt } } }"}' \
  https://your-wiki-domain/graphql

页面管理 (Pages)

获取页面列表

query {
  pages {
    list(
      limit: 20
      orderBy: UPDATED
      orderByDirection: DESC
    ) {
      id
      path
      title
      description
      updatedAt
      createdAt
      isPublished
      tags
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { list(limit: 20, orderBy: UPDATED, orderByDirection: DESC) { id path title description updatedAt createdAt isPublished tags } } }"}' \
  https://your-wiki-domain/graphql

获取单个页面

query {
  pages {
    single(id: 123) {
      id
      path
      title
      description
      content
      render
      isPublished
      updatedAt
      tags {
        id
        tag
        title
      }
      authorName
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { single(id: 123) { id path title description content render isPublished updatedAt tags { id tag title } authorName } } }"}' \
  https://your-wiki-domain/graphql

通过路径获取页面

query {
  pages {
    singleByPath(
      path: "/path/to/page"
      locale: "zh"
    ) {
      id
      title
      description
      content
      render
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { singleByPath(path: \"/path/to/page\", locale: \"zh\") { id title description content render } } }"}' \
  https://your-wiki-domain/graphql

获取页面历史

query {
  pages {
    history(
      id: 123
      offsetPage: 0
      offsetSize: 10
    ) {
      total
      trail {
        versionId
        versionDate
        authorId
        authorName
        actionType
        valueBefore
        valueAfter
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { history(id: 123, offsetPage: 0, offsetSize: 10) { total trail { versionId versionDate authorId authorName actionType valueBefore valueAfter } } } }"}' \
  https://your-wiki-domain/graphql

获取特定版本的页面

query {
  pages {
    version(
      pageId: 123
      versionId: 5
    ) {
      action
      authorId
      authorName
      content
      contentType
      versionDate
      description
      title
      path
      tags
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { version(pageId: 123, versionId: 5) { action authorId authorName content contentType versionDate description title path tags } } }"}' \
  https://your-wiki-domain/graphql

搜索页面

query {
  pages {
    search(
      query: "关键词"
      path: "/folder"
      locale: "zh"
    ) {
      results {
        id
        title
        description
        path
        locale
      }
      suggestions
      totalHits
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { search(query: \"关键词\", path: \"/folder\", locale: \"zh\") { results { id title description path locale } suggestions totalHits } } }"}' \
  https://your-wiki-domain/graphql

获取所有标签

query {
  pages {
    tags {
      id
      tag
      title
      createdAt
      updatedAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { tags { id tag title createdAt updatedAt } } }"}' \
  https://your-wiki-domain/graphql

搜索标签

query {
  pages {
    searchTags(query: "doc") 
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { searchTags(query: \"doc\") } }"}' \
  https://your-wiki-domain/graphql

获取页面树结构

query {
  pages {
    tree(
      path: "/docs"
      mode: ALL
      locale: "zh"
      includeAncestors: true
    ) {
      id
      path
      depth
      title
      isPrivate
      isFolder
      pageId
      locale
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { tree(path: \"/docs\", mode: ALL, locale: \"zh\", includeAncestors: true) { id path depth title isPrivate isFolder pageId locale } } }"}' \
  https://your-wiki-domain/graphql

获取所有页面链接

query {
  pages {
    links(locale: "zh") {
      id
      path
      title
      links
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { links(locale: \"zh\") { id path title links } } }"}' \
  https://your-wiki-domain/graphql

检查页面冲突

query {
  pages {
    checkConflicts(
      id: 123
      checkoutDate: "2023-08-15T12:00:00Z"
    )
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { checkConflicts(id: 123, checkoutDate: \"2023-08-15T12:00:00Z\") } }"}' \
  https://your-wiki-domain/graphql

获取最新冲突内容

query {
  pages {
    conflictLatest(id: 123) {
      id
      authorId
      authorName
      content
      createdAt
      updatedAt
      description
      title
      path
      tags
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { conflictLatest(id: 123) { id authorId authorName content createdAt updatedAt description title path tags } } }"}' \
  https://your-wiki-domain/graphql

创建页面

mutation {
  pages {
    create(
      content: "# Hello World\nThis is my new page content."
      description: "A sample page description"
      editor: "markdown"
      isPublished: true
      isPrivate: false
      locale: "zh"
      path: "/sample/new-page"
      tags: ["sample", "documentation"]
      title: "My New Page"
    ) {
      responseResult {
        succeeded
        message
      }
      page {
        id
        path
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { create(content: \"# Hello World\\nThis is my new page content.\", description: \"A sample page description\", editor: \"markdown\", isPublished: true, isPrivate: false, locale: \"zh\", path: \"/sample/new-page\", tags: [\"sample\", \"documentation\"], title: \"My New Page\") { responseResult { succeeded message } page { id path } } } }"}' \
  https://your-wiki-domain/graphql

更新页面

mutation {
  pages {
    update(
      id: 123
      content: "# Updated Content\nThis page has been updated."
      description: "Updated description"
      isPublished: true
      tags: ["updated", "documentation"]
      title: "Updated Page Title"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { update(id: 123, content: \"# Updated Content\\nThis page has been updated.\", description: \"Updated description\", isPublished: true, tags: [\"updated\", \"documentation\"], title: \"Updated Page Title\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

转换页面编辑器

mutation {
  pages {
    convert(
      id: 123
      editor: "html"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { convert(id: 123, editor: \"html\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

移动页面

mutation {
  pages {
    move(
      id: 123
      destinationPath: "/new/location"
      destinationLocale: "zh"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { move(id: 123, destinationPath: \"/new/location\", destinationLocale: \"zh\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

删除页面

mutation {
  pages {
    delete(id: 123) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { delete(id: 123) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

删除标签

mutation {
  pages {
    deleteTag(id: 45) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { deleteTag(id: 45) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

更新标签

mutation {
  pages {
    updateTag(
      id: 45
      tag: "documentation"
      title: "文档"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { updateTag(id: 45, tag: \"documentation\", title: \"文档\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

刷新缓存

mutation {
  pages {
    flushCache {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { flushCache { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

迁移到不同语言

mutation {
  pages {
    migrateToLocale(
      sourceLocale: "en"
      targetLocale: "zh"
    ) {
      responseResult {
        succeeded
        message
      }
      count
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { migrateToLocale(sourceLocale: \"en\", targetLocale: \"zh\") { responseResult { succeeded message } count } } }"}' \
  https://your-wiki-domain/graphql

重建页面树

mutation {
  pages {
    rebuildTree {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { rebuildTree { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

渲染页面

mutation {
  pages {
    render(id: 123) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { render(id: 123) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

恢复页面到特定版本

mutation {
  pages {
    restore(
      pageId: 123
      versionId: 5
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { restore(pageId: 123, versionId: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

清除历史记录

mutation {
  pages {
    purgeHistory(
      olderThan: "30d"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { pages { purgeHistory(olderThan: \"30d\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

资源管理 (Assets)

获取资源列表

query {
  assets {
    list(folderId: 0, kind: ALL) {
      id
      filename
      ext
      kind
      mime
      fileSize
      createdAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { assets { list(folderId: 0, kind: ALL) { id filename ext kind mime fileSize createdAt } } }"}' \
  https://your-wiki-domain/graphql

获取文件夹列表

query {
  assets {
    folders(parentFolderId: 0) {
      id
      slug
      name
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { assets { folders(parentFolderId: 0) { id slug name } } }"}' \
  https://your-wiki-domain/graphql

创建文件夹

mutation {
  assets {
    createFolder(
      parentFolderId: 0
      slug: "images"
      name: "图片资源"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { assets { createFolder(parentFolderId: 0, slug: \"images\", name: \"图片资源\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

重命名资源

mutation {
  assets {
    renameAsset(
      id: 123
      filename: "renamed-image.jpg"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { assets { renameAsset(id: 123, filename: \"renamed-image.jpg\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

删除资源

mutation {
  assets {
    deleteAsset(id: 123) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { assets { deleteAsset(id: 123) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

导航管理 (Navigation)

获取导航树

query {
  navigation {
    tree {
      locale
      items {
        id
        kind
        label
        icon
        targetType
        target
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { navigation { tree { locale items { id kind label icon targetType target } } } }"}' \
  https://your-wiki-domain/graphql

更新导航树

mutation {
  navigation {
    updateTree(
      tree: [
        {
          locale: "zh"
          items: [
            {
              id: "home"
              kind: "link"
              label: "首页"
              icon: "home"
              targetType: "page"
              target: "/"
              visibilityMode: "all"
            },
            {
              id: "docs"
              kind: "link"
              label: "文档"
              icon: "book"
              targetType: "page"
              target: "/docs"
              visibilityMode: "all"
            }
          ]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { navigation { updateTree(tree: [{locale: \"zh\", items: [{id: \"home\", kind: \"link\", label: \"首页\", icon: \"home\", targetType: \"page\", target: \"/\", visibilityMode: \"all\"}, {id: \"docs\", kind: \"link\", label: \"文档\", icon: \"book\", targetType: \"page\", target: \"/docs\", visibilityMode: \"all\"}]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

群组管理 (Groups)

获取群组列表

query {
  groups {
    list {
      id
      name
      isSystem
      userCount
      createdAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { groups { list { id name isSystem userCount createdAt } } }"}' \
  https://your-wiki-domain/graphql

获取单个群组

query {
  groups {
    single(id: 1) {
      id
      name
      permissions
      pageRules {
        id
        deny
        match
        roles
        path
        locales
      }
      users {
        id
        name
        email
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { groups { single(id: 1) { id name permissions pageRules { id deny match roles path locales } users { id name email } } } }"}' \
  https://your-wiki-domain/graphql

创建群组

mutation {
  groups {
    create(name: "编辑团队") {
      responseResult {
        succeeded
        message
      }
      group {
        id
        name
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { create(name: \"编辑团队\") { responseResult { succeeded message } group { id name } } } }"}' \
  https://your-wiki-domain/graphql

更新群组

mutation {
  groups {
    update(
      id: 2
      name: "高级编辑"
      redirectOnLogin: "/dashboard"
      permissions: ["read:pages", "write:pages", "manage:pages"]
      pageRules: [
        {
          id: "rule1",
          deny: false,
          match: START,
          roles: ["read:pages"],
          path: "/docs",
          locales: ["zh"]
        },
        {
          id: "rule2",
          deny: true,
          match: REGEX,
          roles: ["write:pages"],
          path: "^/admin/.*$",
          locales: ["zh", "en"]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { update(id: 2, name: \"高级编辑\", redirectOnLogin: \"/dashboard\", permissions: [\"read:pages\", \"write:pages\", \"manage:pages\"], pageRules: [{id: \"rule1\", deny: false, match: START, roles: [\"read:pages\"], path: \"/docs\", locales: [\"zh\"]}, {id: \"rule2\", deny: true, match: REGEX, roles: [\"write:pages\"], path: \"^/admin/.*$\", locales: [\"zh\", \"en\"]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

为用户分配群组

mutation {
  groups {
    assignUser(
      groupId: 2
      userId: 5
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { assignUser(groupId: 2, userId: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

从群组中移除用户

mutation {
  groups {
    unassignUser(
      groupId: 2
      userId: 5
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { unassignUser(groupId: 2, userId: 5) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

删除群组

mutation {
  groups {
    delete(id: 3) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { delete(id: 3) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

权限管理

WikiJS的权限系统基于用户组和权限规则。下面介绍一些核心权限相关的操作:

查看可用权限

您可以通过查询单个群组来查看其拥有的权限:

query {
  groups {
    single(id: 1) {
      permissions
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { groups { single(id: 1) { permissions } } }"}' \
  https://your-wiki-domain/graphql

设置用户组权限

在更新用户组时,您可以设置该组的权限:

mutation {
  groups {
    update(
      id: 2
      name: "内容编辑"
      permissions: [
        "read:pages",
        "write:pages",
        "manage:pages",
        "read:assets",
        "upload:assets"
      ]
      pageRules: []
    ) {
      responseResult {
        succeeded
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { update(id: 2, name: \"内容编辑\", permissions: [\"read:pages\", \"write:pages\", \"manage:pages\", \"read:assets\", \"upload:assets\"], pageRules: []) { responseResult { succeeded } } } }"}' \
  https://your-wiki-domain/graphql

设置页面访问规则

页面规则允许您为特定路径和语言设置详细的访问控制:

mutation {
  groups {
    update(
      id: 2
      pageRules: [
        {
          id: "confidential",
          deny: true,
          match: START,
          roles: ["read:pages"],
          path: "/confidential",
          locales: ["zh", "en"]
        },
        {
          id: "projects",
          deny: false,
          match: REGEX,
          roles: ["write:pages"],
          path: "^/projects/.*$",
          locales: ["zh"]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { groups { update(id: 2, pageRules: [{id: \"confidential\", deny: true, match: START, roles: [\"read:pages\"], path: \"/confidential\", locales: [\"zh\", \"en\"]}, {id: \"projects\", deny: false, match: REGEX, roles: [\"write:pages\"], path: \"^/projects/.*$\", locales: [\"zh\"]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

页面规则匹配类型说明

页面规则的match属性支持以下匹配模式:

  • START: 匹配以指定路径开头的页面
  • EXACT: 精确匹配指定路径的页面
  • END: 匹配以指定路径结尾的页面
  • REGEX: 使用正则表达式匹配路径
  • TAG: 匹配包含指定标签的页面

评论管理 (Comments)

获取评论提供者

query {
  comments {
    providers {
      key
      title
      isEnabled
      description
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { comments { providers { key title isEnabled description } } }"}' \
  https://your-wiki-domain/graphql

获取页面评论列表

query {
  comments {
    list(
      locale: "zh"
      path: "/path/to/page"
    ) {
      id
      content
      render
      authorName
      createdAt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { comments { list(locale: \"zh\", path: \"/path/to/page\") { id content render authorName createdAt } } }"}' \
  https://your-wiki-domain/graphql

创建评论

mutation {
  comments {
    create(
      pageId: 123
      content: "这是一条评论内容。"
    ) {
      responseResult {
        succeeded
        message
      }
      id
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { comments { create(pageId: 123, content: \"这是一条评论内容。\") { responseResult { succeeded message } id } } }"}' \
  https://your-wiki-domain/graphql

本地化 (Localization)

获取可用语言

query {
  localization {
    locales {
      code
      name
      nativeName
      isInstalled
      isRTL
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { localization { locales { code name nativeName isInstalled isRTL } } }"}' \
  https://your-wiki-domain/graphql

获取翻译配置

query {
  localization {
    config {
      locale
      autoUpdate
      namespacing
      namespaces
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { localization { config { locale autoUpdate namespacing namespaces } } }"}' \
  https://your-wiki-domain/graphql

获取翻译内容

query {
  localization {
    translations(
      locale: "zh"
      namespace: "common"
    ) {
      key
      value
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { localization { translations(locale: \"zh\", namespace: \"common\") { key value } } }"}' \
  https://your-wiki-domain/graphql

分析模块 (Analytics)

获取分析提供商列表

query {
  analytics {
    providers(isEnabled: true) {
      isEnabled
      key
      title
      description
      isAvailable
      website
      config {
        key
        value
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { analytics { providers(isEnabled: true) { isEnabled key title description isAvailable website config { key value } } } }"}' \
  https://your-wiki-domain/graphql

更新分析提供商配置

mutation {
  analytics {
    updateProviders(
      providers: [
        {
          isEnabled: true
          key: "google"
          config: [
            {
              key: "trackingId"
              value: "UA-XXXXXXXX-X"
            }
          ]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { analytics { updateProviders(providers: [{isEnabled: true, key: \"google\", config: [{key: \"trackingId\", value: \"UA-XXXXXXXX-X\"}]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

贡献者模块 (Contribute)

获取贡献者列表

query {
  contribute {
    contributors {
      id
      source
      name
      joined
      website
      twitter
      avatar
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { contribute { contributors { id source name joined website twitter avatar } } }"}' \
  https://your-wiki-domain/graphql

日志模块 (Logging)

获取日志记录器列表

query {
  logging {
    loggers {
      isEnabled
      key
      title
      description
      level
      config {
        key
        value
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { logging { loggers { isEnabled key title description level config { key value } } } }"}' \
  https://your-wiki-domain/graphql

更新日志记录器配置

mutation {
  logging {
    updateLoggers(
      loggers: [
        {
          isEnabled: true
          key: "console"
          level: "info"
          config: []
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { logging { updateLoggers(loggers: [{isEnabled: true, key: \"console\", level: \"info\", config: []}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

实时日志订阅

WikiJS支持通过WebSocket订阅实时日志:

subscription {
  loggingLiveTrail {
    level
    output
    timestamp
  }
}

注意: 订阅查询不能通过curl直接执行,需要使用支持WebSocket的GraphQL客户端。

邮件模块 (Mail)

获取邮件配置

query {
  mail {
    config {
      senderName
      senderEmail
      host
      port
      name
      secure
      verifySSL
      useDKIM
      dkimDomainName
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { mail { config { senderName senderEmail host port name secure verifySSL useDKIM dkimDomainName } } }"}' \
  https://your-wiki-domain/graphql

发送测试邮件

mutation {
  mail {
    sendTest(
      recipientEmail: "test@example.com"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { mail { sendTest(recipientEmail: \"test@example.com\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

更新邮件配置

mutation {
  mail {
    updateConfig(
      senderName: "WikiJS"
      senderEmail: "wiki@example.com"
      host: "smtp.example.com"
      port: 587
      name: "wiki-smtp"
      secure: true
      verifySSL: true
      user: "smtp-user"
      pass: "smtp-password"
      useDKIM: false
      dkimDomainName: ""
      dkimKeySelector: ""
      dkimPrivateKey: ""
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { mail { updateConfig(senderName: \"WikiJS\", senderEmail: \"wiki@example.com\", host: \"smtp.example.com\", port: 587, name: \"wiki-smtp\", secure: true, verifySSL: true, user: \"smtp-user\", pass: \"smtp-password\", useDKIM: false, dkimDomainName: \"\", dkimKeySelector: \"\", dkimPrivateKey: \"\") { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

渲染模块 (Rendering)

获取渲染器列表

query {
  rendering {
    renderers {
      isEnabled
      key
      title
      description
      icon
      dependsOn
      input
      output
      config {
        key
        value
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { rendering { renderers { isEnabled key title description icon dependsOn input output config { key value } } } }"}' \
  https://your-wiki-domain/graphql

更新渲染器配置

mutation {
  rendering {
    updateRenderers(
      renderers: [
        {
          isEnabled: true
          key: "markdown"
          config: [
            {
              key: "mathjax"
              value: "true"
            }
          ]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { rendering { updateRenderers(renderers: [{isEnabled: true, key: \"markdown\", config: [{key: \"mathjax\", value: \"true\"}]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

存储模块 (Storage)

获取存储目标列表

query {
  storage {
    targets {
      isEnabled
      key
      title
      description
      isAvailable
      mode
      hasSchedule
      syncInterval
      config {
        key
        value
      }
      actions {
        handler
        label
        hint
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { storage { targets { isEnabled key title description isAvailable mode hasSchedule syncInterval config { key value } actions { handler label hint } } } }"}' \
  https://your-wiki-domain/graphql

获取存储状态

query {
  storage {
    status {
      key
      title
      status
      message
      lastAttempt
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { storage { status { key title status message lastAttempt } } }"}' \
  https://your-wiki-domain/graphql

更新存储目标配置

mutation {
  storage {
    updateTargets(
      targets: [
        {
          isEnabled: true
          key: "git"
          mode: "sync"
          syncInterval: "PT1H"
          config: [
            {
              key: "repoUrl"
              value: "https://github.com/your-username/your-repo.git"
            },
            {
              key: "branch"
              value: "main"
            }
          ]
        }
      ]
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { storage { updateTargets(targets: [{isEnabled: true, key: \"git\", mode: \"sync\", syncInterval: \"PT1H\", config: [{key: \"repoUrl\", value: \"https://github.com/your-username/your-repo.git\"}, {key: \"branch\", value: \"main\"}]}]) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

执行存储操作

mutation {
  storage {
    executeAction(
      targetKey: "git"
      handler: "syncNow"
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { storage { executeAction(targetKey:

### 站点配置

```graphql
query {
  site {
    config {
      title
      description
      host
      company
      contentLicense
      logoUrl
      featurePageComments
      featurePageRatings
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { site { config { title description host company contentLicense logoUrl featurePageComments featurePageRatings } } }"}' \
  https://your-wiki-domain/graphql

更新站点配置

mutation {
  site {
    updateConfig(
      title: "我的知识库"
      description: "团队协作知识管理系统"
      company: "我的公司"
      featurePageComments: true
      featurePageRatings: true
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { site { updateConfig(title: \"我的知识库\", description: \"团队协作知识管理系统\", company: \"我的公司\", featurePageComments: true, featurePageRatings: true) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

主题配置

query {
  theming {
    themes {
      key
      title
      author
    }
    config {
      theme
      darkMode
      iconset
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { theming { themes { key title author } config { theme darkMode iconset } } }"}' \
  https://your-wiki-domain/graphql

设置主题

mutation {
  theming {
    setConfig(
      theme: "default"
      iconset: "material-icons"
      darkMode: true
    ) {
      responseResult {
        succeeded
        message
      }
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "mutation { theming { setConfig(theme: \"default\", iconset: \"material-icons\", darkMode: true) { responseResult { succeeded message } } } }"}' \
  https://your-wiki-domain/graphql

搜索引擎配置

query {
  search {
    searchEngines {
      key
      title
      isEnabled
      description
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { search { searchEngines { key title isEnabled description } } }"}' \
  https://your-wiki-domain/graphql

搜索页面

query {
  pages {
    search(
      query: "wiki"
      locale: "zh"
    ) {
      results {
        id
        title
        description
        path
        locale
      }
      totalHits
    }
  }
}

curl示例:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"query": "query { pages { search(query: \"wiki\", locale: \"zh\") { results { id title description path locale } totalHits } } }"}' \
  https://your-wiki-domain/graphql
search Ctrl K ESC
manage_search 输入关键词开始搜索