> ## Documentation Index
> Fetch the complete documentation index at: https://dev.marginnote.com.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取运行状态

> 返回 App 名称与版本、接口版本、注册的路由条数、路由目录校验值，以及运行规程的版本与哈希。

校验值变了就说明接口变了。把本地的路由清单和校验值存下来，启动时比对一次，
就能判断要不要重新获取 `GET /capabilities`。




## OpenAPI

````yaml /openapi/plugin-api.yaml get /status
openapi: 3.1.0
info:
  title: 场景插件 API
  summary: 场景插件在网页面板里可以调用的接口。
  description: >
    场景插件的面板是一个网页。页面里向 `/bridge/v1` 发请求，就能读写 MarginNote 里的数据。

    请求由 MarginNote 处理，与外部命令行工具共用同一套处理代码。外部工具要带令牌，面板不必带。

    面板页面从 `mnpanel://panel/index.html` 加载，因此 `fetch('/bridge/v1' + path)`
    属于同源请求。


    面板调用受这些条件约束：


    - 请求不带令牌，本文件也不声明安全方案。

    - 页面能调用哪些接口，取决于两份名单。模板里的 `plugins` 名单和沉浸态决定面板能不能建好，
      网页面板白名单决定页面能调哪些接口。不在白名单里的请求返回 `403`，
      错误码为 `IN_PROCESS_NOT_ALLOWED`。
    - `GET /capabilities` 里的 `requiresMax` 只约束外部 Agent。面板的请求在 MarginNote 进程内处理，
      不受令牌、订阅状态与跨设备批准的限制，能否调用只看该路径是否在白名单内。
    - 写操作里的 `addon`，MarginNote 会改写为当前面板所属插件的 id；`confirm` 由 MarginNote 补上。
      页面填的值不会生效。

    用 `mn.api(path, opts)` 读取数据。该方法始终将 Response Body 按 JSON 解析，相当于

    `fetch('/bridge/v1' + path, opts).then(r => r.json())`。


    响应的内容不是 JSON 的接口，改用 `fetch`：


    - `GET /guide` 返回 Markdown 正文。

    - `GET /notes/{noteid}/render` 返回卡片长图或 PDF。

    - `GET /documents/{bookmd5}/pages/{index}/content/{contentId}` 返回图片。

    - `GET /bundles/{bundleId}/files` 带 `?path=` 时返回该文件的原始字节。


    调用失败时 Promise 不会进入 reject。MarginNote 把错误对象

    `{"error":{"code":"…","message":"…"}}` 当作 Response Body 返回，因此结果落在 resolve 里。

    判断调用结果看响应里是否带 `error`，写操作另看响应里的 `persisted`。


    接口清单、各项上限与 Request Body 结构随 MarginNote 的版本变化，运行时以 `GET /capabilities` 与

    `GET /guide` 返回的内容为准。
  version: '0.91'
servers: []
security: []
tags:
  - name: 能力与状态
    description: 读取 MarginNote 的能力、版本与当前上下文。调用其他接口之前先读这组。
  - name: 卡片与摘录
    description: 卡片的读取与写入、摘录的创建、批注、标签、元数据与留白。
  - name: 手写会话
    description: 手写层、作答纸、练习准备清单与会话记录的读取与提交。
  - name: 学习集与卡组
    description: 学习集结构、脑图树、子脑图、色板、快照与复习卡组。
  - name: 文档与页面
    description: 文档目录、页文本、页内注释面、摘录清单与同步诊断。
  - name: 导出与 Anki
    description: 文档导出计划、导出文件、Anki 导出能力、作业与产物。
  - name: 查找
    description: 跨库搜索、文件夹列表与学习集列表。
  - name: 界面与模板
    description: 读取当前界面状态与沉浸模板。
  - name: 插件辅助
    description: 面板辅助脚本、已配对设备与本机 helper 信息。
  - name: 任务包与同步诊断
    description: 拆书任务包与旧 CloudKit 同步诊断。
paths:
  /status:
    get:
      tags:
        - 能力与状态
      summary: 获取运行状态
      description: |
        返回 App 名称与版本、接口版本、注册的路由条数、路由目录校验值，以及运行规程的版本与哈希。

        校验值变了就说明接口变了。把本地的路由清单和校验值存下来，启动时比对一次，
        就能判断要不要重新获取 `GET /capabilities`。
      operationId: getStatus
      responses:
        '200':
          description: 版本与校验值。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusResponse'
              examples:
                recorded:
                  summary: 真机实录（MarginNote 0.61，2026-09-18 录制）
                  value:
                    routeCount: 87
                    appVersion: 4.5.0
                    enabled: true
                    app: MarginNote 4
                    instanceNonce: QqWKCQYQS08cMi3tPkB2fA
                    guideVersion: '0.61'
                    authorized: true
                    guide:
                      sha256: >-
                        c58ca54dfa21245e25cd863c5cbc2084f94d69c188e15f22fa86bbfd4809512a
                      refreshPolicy: fetch_at_session_start_when_version_or_sha256_differs
                      rotatesToken: false
                      usesExistingBearer: true
                      installRequired: false
                      version: '0.61'
                      route: /guide
                    guideHash: >-
                      c58ca54dfa21245e25cd863c5cbc2084f94d69c188e15f22fa86bbfd4809512a
                    apiFingerprint: 17b754d41172
                    bridgeApiVersion: '0.61'
                measured:
                  summary: 实测于 2026-10-07，App 0.91
                  value:
                    guide:
                      sha256: >-
                        43463f3690bf9d9ef78111e33cb77df6261fdba0a67f4cb6a81cc06c8d3403b2
                      refreshPolicy: fetch_at_session_start_when_version_or_sha256_differs
                      rotatesToken: false
                      usesExistingBearer: true
                      installRequired: false
                      version: '0.91'
                      route: /guide
                    apiFingerprint: d165ea64cae5
                    bridgeApiVersion: '0.91'
                    skill:
                      sha256: >-
                        315db09b91ec8414a12a6d486d38e7634d70b6027a5a49d50fbb688b944a3453
                      rotatesToken: false
                      backsUpReplacedFiles: true
                      bootstrapVersion: 1
                      refreshShRoute: /skill/refresh.sh
                      refreshPowerShellRoute: /skill/refresh.ps1
                      refreshScope: existing_mn_bridge_skill_files_only
                      usesExistingBearer: true
                      guidePolicy: fetch_runtime_guide_each_session
                      route: /skill
                    guideVersion: '0.91'
                    authorized: false
                    guideHash: >-
                      43463f3690bf9d9ef78111e33cb77df6261fdba0a67f4cb6a81cc06c8d3403b2
                    app: MarginNote 4
                    enabled: true
                    appVersion: 4.5.0
                    instanceNonce: cbPw0gbdv1HgfJDkZCEjPw
                    routeCount: 145
      x-codeSamples:
        - lang: javascript
          label: 比对路由校验值
          source: |
            const st = await mn.api('/status');
            if (st.apiFingerprint !== cachedFingerprint) {
              // 校验值变了，本地保存的接口清单和字段都要重新核对
            }
components:
  schemas:
    StatusResponse:
      type: object
      description: 当前 MarginNote 的能力快照。
      properties:
        app:
          type: string
          description: App 名称。
        appVersion:
          type: string
          description: App 版本号。
        enabled:
          type: boolean
          description: 接口服务是否可用。
        authorized:
          type: boolean
          description: 本次请求是否带有效令牌。面板走进程内的路径，该项的意义有限。
        bridgeApiVersion:
          type: string
          description: 接口版本，也是本分组 `info.version` 的取值来源。
        routeCount:
          type: number
          description: MarginNote 注册的路由条数。
        apiFingerprint:
          type: string
          description: 路由目录校验值。校验值不同就说明接口变了，据此判断本地的清单是否还有效。
        guideVersion:
          type: string
          description: 运行规程的版本号。
        guideHash:
          type: string
          description: 运行规程正文的 SHA-256。版本号相同而哈希不同，说明正文改过，按哈希缓存才可靠。
        instanceNonce:
          type: string
          description: 本次运行的身份串，用于判断发现文件是否过期。
        guide:
          $ref: '#/components/schemas/GuideInfo'
    GuideInfo:
      type: object
      description: 运行规程的元信息。
      properties:
        version:
          type: string
        sha256:
          type: string
          description: 规程正文的哈希。
        route:
          type: string
        refreshPolicy:
          type: string
          description: MarginNote 建议的抓取时机。
        usesExistingBearer:
          type: boolean
        installRequired:
          type: boolean
        rotatesToken:
          type: boolean

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.