> ## Documentation Index
> Fetch the complete documentation index at: https://yumebox.yumeyuka.moe/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取连接信息

> 获取连接信息.GET / WebSocket 均按 interval（毫秒，默认 1000）持续推送连接快照.



## OpenAPI

````yaml /api/openapi.json get /connections
openapi: 3.1.0
info:
  title: Mihomo 外部控制器 API
  version: 1.1.0
  description: >-
    Mihomo（clash.meta）内核通过外部控制器（external-controller）暴露的 RESTful
    API，可用于查询状态、切换节点、测试延迟、管理连接与 provider 等.TCP / TLS 外部控制器在配置了 secret 时需要携带
    Authorization: Bearer ${secret}；Unix socket / Windows named pipe 访问不会校验
    secret.鉴权与路径以 MetaCubeX mihomo hub/route 实现为准；可在右侧 Try it 面板中修改 host/port（示例
    external-controller: 0.0.0.0:9093）.
servers:
  - url: http://{host}:{port}
    variables:
      host:
        default: 127.0.0.1
        description: 外部控制器监听地址 / mihomo 后端的局域网 IP.
      port:
        default: '9093'
        description: '外部控制器监听端口；默认值对齐 mihomo 示例配置 external-controller: 0.0.0.0:9093.'
security:
  - bearerAuth: []
tags:
  - name: 日志
    description: 实时日志流.
  - name: 流量信息
    description: 实时上下行流量统计.
  - name: 内存信息
    description: 实时内存占用统计.
  - name: 版本信息
    description: 内核版本信息.
  - name: 缓存
    description: FakeIP / DNS 缓存清理.
  - name: 运行配置
    description: 运行配置的读取、重载与修改.
  - name: 更新
    description: 内核、面板与 GEO 数据库的更新.
  - name: 策略组
    description: 策略组的查询与延迟测试.
  - name: 代理
    description: 代理节点的查询、选择与延迟测试.
  - name: 代理集合
    description: 代理集合（proxy provider）的查询、更新与健康检查.
  - name: 规则
    description: 规则的查询与临时禁用.
  - name: 规则集合
    description: 规则集合（rule provider）的查询与更新.
  - name: 连接
    description: 连接信息的查询与关闭.
  - name: 域名查询
    description: 通过内核 DNS 进行域名解析.
  - name: 存储
    description: 内核键值存储的读写.
  - name: DEBUG
    description: 调试相关端点（需内核日志级别为 debug）.
paths:
  /connections:
    get:
      tags:
        - 连接
      summary: 获取连接信息
      description: 获取连接信息.GET / WebSocket 均按 interval（毫秒，默认 1000）持续推送连接快照.
      operationId: getConnections
      parameters:
        - name: interval
          in: query
          required: false
          description: GET / WebSocket 推送间隔（毫秒），默认 1000.
          schema:
            type: integer
            example: 1000
      responses:
        '200':
          description: 连接信息.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionSnapshot'
              example:
                downloadTotal: 0
                uploadTotal: 0
                memory: 0
                connections:
                  - id: ''
                    metadata: {}
                    upload: 0
                    download: 0
                    start: ''
                    chains: []
                    providerChains: []
                    rule: ''
                    rulePayload: ''
components:
  schemas:
    ConnectionSnapshot:
      type: object
      properties:
        downloadTotal:
          type: integer
        uploadTotal:
          type: integer
        memory:
          type: integer
          description: 当前内存使用量（字节）.
        connections:
          type: array
          items:
            $ref: '#/components/schemas/ConnectionInfo'
    ConnectionInfo:
      type: object
      properties:
        id:
          type: string
        metadata:
          type: object
          additionalProperties: true
          description: 源/目标地址、协议、进程名称等.
        upload:
          type: integer
          description: 该连接已上传字节数.
        download:
          type: integer
          description: 该连接已下载字节数.
        start:
          type: string
          description: 连接建立时间.
        chains:
          type: array
          items:
            type: string
          description: 代理链路.
        providerChains:
          type: array
          items:
            type: string
          description: provider 代理链路.
        rule:
          type: string
          description: 命中规则类型.
        rulePayload:
          type: string
          description: 命中规则内容.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        在请求头中携带 Authorization: Bearer ${secret}，其中 secret 对应配置中的 secret 字段.若未设置
        secret 可省略，但强烈建议设置.

````