Skip to content

实例、登录与二维码 ​

实例状态 ​

GET /v2/status 无参数。用于连接后核对 PID、正在运行的 DLL 版本、登录状态和能力。在多开场景下,用 PID 和 session 区分实例。

JSON
{3 项}
"ok": true,
"data": {11 项},
"state": "ready",
"pid": 12345,
"session": "12345-example",
"wechat_version": "4.2.0.13",
"dll_version": "1.1.9-dev",
"dll_name": "YunKeWX_hook_4.2.0.13.dll",
"dll_build_id": "20261202T020000Z",
"login": {3 项},
"state": "logged_in",
"source": "native_account",
"reason": "native_login_flag_true"
},
"capabilities": {2 项},
"messages.send_text": true,
"events.subscribe": true
},
"limits": {3 项},
"text_bytes": 2048,
"file_bytes": 20971520,
"voice_ms": 60000
},
"audio_conversion_available": true
},
"meta": {2 项}
"request_id": "req_1",
"api_version": "2"
}
}

示例节选了能力字段。实际响应还会提供以下范围对象。

data 字段类型含义
statestringready 服务可访问,faulted 原生服务出现故障。
pid、sessioninteger、string本机进程 ID 和本次服务会话。
wechat_version、dll_version、dll_name、dll_build_idstring微信版本、Hook 版本、DLL 文件名、UTC 构建号。
loginobject当前登录快照,字段同本人资料。
capabilitiesobject功能名到布尔值的映射。
limits.text_bytes、file_bytes、voice_msinteger文本及文件字节上限、语音毫秒上限。
audio_conversion_availableboolean本机语音转码能力。
gif_scopeobjecttargets 目标类型,sources 来源,input_max_pending 并发上限,body_bytes 请求上限,max_dimension 最大边长。
reference_scopeobjecttargets、message_id_source 事件 ID 字段、lookup 查询来源、account_bound 账号绑定、max_pending、query_timeout_ms。
share_scopeobjecttargets、thumbnail_sources、local_thumbnail,以及 title_bytes、description_bytes、url_bytes、max_pending。
applet_scopeobjecttargets、metadata_sources,以及 thumbnail_sources、local_thumbnail、local_thumbnail_bytes、max_pending。
chatlog_scopeobjecttargets、item_types、max_items、item_text_bytes、total_text_bytes、raw_xml、max_pending。
card_scopeobjecttargets、profile_source、contact_id_required、xml_input、max_pending、native_type、native_subtype。
location_scopeobjecttargets、fields、extra_xml_metadata、xml_bytes、max_pending。
xml_scopeobjecttypes、raw_passthrough、external_thumbnail、xml_bytes、chatlog_items。

能力包括 account.self、login.qr.read、events.subscribe、events.structured、contacts.read、contacts.refresh、groups.members.read,以及下列功能组。

前缀功能名后缀
messages.send_text、send_text2、send_file、send_voice、send_image、send_gif、send_reference、send_share、send_applet、send_music、send_chatlog、send_cards、send_location、send_xml
official_accounts.search_local、search_global、received_articles。当前全局搜索为 false。
articles.read_public_page
payments.accept_transfer、open_group_red_packet。以当前构建实际返回为准。

本人资料 ​

GET /v2/account/self 无参数。用于账号列表、头像显示、更新登录状态。优先使用已核对 PID 和 session 的最新快照。

JSON
{7 项}
"pid": 12345,
"session": "12345-example",
"login": {3 项},
"state": "logged_in",
"source": "native_account",
"reason": "native_login_flag_true"
},
"user": {6 项},
"wxid": "wxid_example",
"alias": "example",
"nickname": "示例账号",
"avatar_url": "",
"avatar_source": "unavailable",
"source": "native_profile"
},
"network_state": "unknown",
"observed_at_ms": 1796176800000,
"stale": false
}
data 字段类型含义
pid、sessioninteger、string所属进程及服务会话。
login.statestringlogged_in 已登录,logged_out 未登录,unknown 读取失败或过期。
login.source、login.reasonstring登录状态来源和诊断原因。
userobject 或 null未登录或未知时为 null。
user.wxid、alias、nicknamestring原始账号 ID、微信号、昵称。
user.avatar_url、avatar_source、sourcestring本人头像地址、头像来源、资料来源。头像缺失时地址为空。
network_statestring当前为 unknown。
observed_at_ms、staleinteger、boolean采样时间及是否超过 5 秒。

收到 account.changed 可刷新资料。进程退出时 HTTP 将不可用,用进程生命周期或桌面列表确认退出。

登录二维码 ​

GET /v2/login/qr 无参数。先启动并接入未登录微信,然后向该实例的 Hook 端口请求。接口读取微信登录窗口已生成的短期二维码链接。新建实例与扫码登录

data 字段类型含义
statestring成功时为 ready。
qr_urlstring本次登录二维码链接,使用者可用它生成扫码图片。
sourcestring二维码采集来源。
observed_at_msinteger捕获时间,Unix 毫秒。
expires_in_msinteger剩余有效毫秒,最长约 120 秒。
http
GET /v2/login/qr
Authorization: Bearer <token>
JSON
{3 项}
"ok": true,
"data": {5 项},
"state": "ready",
"qr_url": "https://weixin.qq.com/x/example",
"source": "native_login_task",
"observed_at_ms": 1796176800000,
"expires_in_ms": 115000
},
"meta": {2 项}
"api_version": "2",
"request_id": "req_2"
}
}

等待原生二维码生成或过期时收到 404 not_found。需要新码时,在微信登录窗口触发刷新,再查询同一实例。扫码后使用 GET /v2/account/self 确认登录结果。