百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

WeixinBot

> 包管理
开源

网页版微信API,包含终端版微信及微信机器人

7.4K stars0 点赞13 次浏览
访问官网GitHub

工具介绍

网页版微信API,包含终端版微信及微信机器人

WeixinBot

网页版微信API,包含终端版微信及微信机器人

Contents

  • Demo
  • Web Weixin Pipeline
  • Web Weixin API
  • Discussion Group
  • Recent Update

Demo

为了确保能正常运行示例脚本,请安装所需的第三方包。

bash
pip install -r requirements.txt

注:下面演示的图片与功能可能不是最新的,具体请看源码。

按照操作指示在手机微信上扫描二维码然后登录,你可以选择是否开启自动回复模式。

开启自动回复模式后,如果接收到的是文字消息就会自动回复,包括群消息。

名片,链接,动画表情和地址位置消息。

网页版上有的功能目前基本上都能支持。

Web Weixin Pipeline

…

Web Weixin API

登录

API 获取 UUID
url https://login.weixin.qq.com/jslogin
method POST
data URL Encode
params appid: 应用ID
fun: new 应用类型
lang: zh_CN 语言
_: 时间戳

返回数据(String):

window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"

注:这里的appid就是在微信开放平台注册的应用的AppID。网页版微信有两个AppID,早期的是wx782c26e4c19acffb,在微信客户端上显示为应用名称为Web微信;现在用的是wxeb7ec651dd0aefa9,显示名称为微信网页版。


API 绑定登陆(webwxpushloginurl)
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxpushloginurl
method GET
params uin: xxx

返回数据(String):

{'msg': 'all ok', 'uuid': 'xxx', 'ret': '0'}

通过这种方式可以省掉扫二维码这步操作,更加方便

API 生成二维码
url https://login.weixin.qq.com/l/ uuid
method GET

API 二维码扫描登录
url https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login
method GET
params tip: 1 未扫描 0 已扫描
uuid: xxx
_: 时间戳

返回数据(String):

window.code=xxx;

xxx:
	408 登陆超时
	201 扫描成功
	200 确认登录

当返回200时,还会有
window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";

API webwxnewloginpage
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage
method GET
params ticket: xxx
uuid: xxx
lang: zh_CN 语言
scan: xxx
fun: new

返回数据(XML):

<error>
	<ret>0</ret>
	<message>OK</message>
	<skey>xxx</skey>
	<wxsid>xxx</wxsid>
	<wxuin>xxx</wxuin>
	<pass_ticket>xxx</pass_ticket>
	<isgrayscale>1</isgrayscale>
</error>

微信初始化

API webwxinit
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?pass_ticket=xxx&skey=xxx&r=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: {
         Uin: xxx,
         Sid: xxx,
         Skey: xxx,
         DeviceID: xxx,
     }
}

返回数据(JSON):

…

API webwxstatusnotify
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?lang=zh_CN&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Code: 3,
     FromUserName: 自己ID,
     ToUserName: 自己ID,
     ClientMsgId: 时间戳
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	...
}

获取联系人信息

API webwxgetcontact
url https://wx.qq.com/cgi-bin/mmwebwx-bin//webwxgetcontact?pass_ticket=xxx&skey=xxx&r=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8

返回数据(JSON):

…

API webwxbatchgetcontact
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r=xxx&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Count: 群数量,
     List: [
         { UserName: 群ID, EncryChatRoomId: "" },
         ...
     ],
}

返回数据(JSON)同上

同步刷新

API synccheck
protocol https
host webpush.weixin.qq.com
webpush.wx2.qq.com
webpush.wx8.qq.com
webpush.wx.qq.com
webpush.web2.wechat.com
webpush.web.wechat.com
path /cgi-bin/mmwebwx-bin/synccheck
method GET
data URL Encode
params r: 时间戳
sid: xxx
uin: xxx
skey: xxx
deviceid: xxx
synckey: xxx
_: 时间戳

返回数据(String):

window.synccheck={retcode:"xxx",selector:"xxx"}

retcode:
	0 正常
	1100 失败/登出微信
selector:
	0 正常
	2 新的消息
	7 进入/离开聊天界面

API webwxsync
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=xxx&skey=xxx&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     SyncKey: xxx,
     rr: 时间戳取反
}

返回数据(JSON):

…

消息接口

API webwxsendmsg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Msg: {
         Type: 1 文字消息,
         Content: 要发送的消息,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	...
}
API webwxrevokemsg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxrevokemsg
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     SvrMsgId: msg_id,
     ToUserName: user_id,
     ClientMsgId: local_msg_id
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	}
}

发送表情

API webwxsendmsgemotion
url https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendemoticon?fun=sys&f=json&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Msg: {
         Type: 47 emoji消息,
         EmojiFlag: 2,
         MediaId: 表情上传后的媒体ID,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

图片接口

API webwxgeticon
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgeticon
method GET
params seq: 数字,可为空
username: ID
skey: xxx

API webwxgetheadimg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetheadimg
method GET
params seq: 数字,可为空
username: 群ID
skey: xxx

API webwxgetmsgimg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmsgimg
method GET
params MsgID: 消息ID
type: slave 略缩图 or 为空时加载原图
skey: xxx

多媒体接口

API webwxgetvideo
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvideo
method GET
params msgid: 消息ID
skey: xxx

API webwxgetvoice
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvoice
method GET
params msgid: 消息ID
skey: xxx

账号类型

类型 说明
个人账号 以@开头,例如:@xxx
群聊 以@@开头,例如:@@xxx
公众号/服务号 以@开头,但其VerifyFlag & 8 != 0

VerifyFlag:
         一般个人公众号/服务号:8
         一般企业的服务号:24
         微信官方账号微信团队:56
特殊账号 像文件传输助手之类的账号,有特殊的ID,目前已知的有:
filehelper, newsapp, fmessage, weibo, qqmail, tmessage, qmessage, qqsync, floatbottle, lbsapp, shakeapp, medianote, qqfriend, readerapp, blogapp, facebookapp, masssendapp, meishiapp, feedsapp, voip, blogappweixin, weixin, brandsessionholder, weixinreminder, officialaccounts, notification_messages, wxitil, userexperience_alarm, notification_messages

消息类型

消息一般格式:

{
	"FromUserName": "",
	"ToUserName": "",
	"Content": "",
	"StatusNotifyUserName": "",
	"ImgWidth": 0,
	"PlayLength": 0,
	"RecommendInfo": {...},
	"StatusNotifyCode": 4,
	"NewMsgId": "",
	"Status": 3,
	"VoiceLength": 0,
	"ForwardFlag": 0,
	"AppMsgType": 0,
	"Ticket": "",
	"AppInfo": {...},
	"Url": "",
	"ImgStatus": 1,
	"MsgType": 1,
	"ImgHeight": 0,
	"MediaId": "",
	"MsgId": "",
	"FileName": "",
	"HasProductId": 0,
	"FileSize": "",
	"CreateTime": 1454602196,
	"SubMsgType": 0
}

MsgType 说明
1 文本消息
3 图片消息
34 语音消息
37 好友确认消息
40 POSSIBLEFRIEND_MSG
42 共享名片
43 视频消息
47 动画表情
48 位置消息
49 分享链接
50 VOIPMSG
51 微信初始化消息
52 VOIPNOTIFY
53 VOIPINVITE
62 小视频
9999 SYSNOTICE
10000 系统消息
10002 撤回消息

微信初始化消息

…

文本消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: 消息内容

图片消息

xml
MsgType: 3
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取图片
Content:
	<msg>
		
		<commenturl></commenturl>
	</msg>

小视频消息

xml
MsgType: 62
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取小视频
Content:
	<msg>
		
		<commenturl></commenturl>
	</msg>

地理位置消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: http://weixin.qq.com/cgi-bin/redirectforward?args=xxx
// 属于文本消息,只不过内容是一个跳转到地图的链接

名片消息

…

语音消息

xml
MsgType: 34
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取语音
Content:
	<msg>
		<voicemsg endflag="1" cancelflag="0" forwardflag="0" voiceformat="4" voicelength="1580" length="2026" bufid="216825389722501519" clientmsgid="49efec63a9774a65a932a4e5fcd4e923filehelper174_1454602489" fromusername="" />
	</msg>

动画表情

…

普通链接或应用分享消息

xml
MsgType: 49
AppMsgType: 5
FromUserName: 发送方ID
ToUserName: 接收方ID
Url: 链接地址
FileName: 链接标题
Content:
	<msg>
		<appmsg appid=""  sdkver="0">
			<title></title>
			<des></des>
			<type>5</type>
			<content></content>
			<url></url>
			<thumburl></thumburl>
			...
		</appmsg>
		<appinfo>
			<version></vers

Issues· 199 开放

查看全部 Issues在 GitHub 打开
  • #307

    [安全性] 任何端点都无需身份验证 — 完全接管帐户、大量垃圾邮件、私人聊天数据泄露

    更新于 2026年6月21日
  • #293

    是否存在封号风险?

    更新于 2025年1月9日
  • #303

    扫码登录失败报错

    更新于 2024年9月14日
  • #305

    音乐加载失败,显示的 XML 标签不是预期的音乐名片

    更新于 2024年6月12日
  • #199

    如何获取一个微信号(已有对方手机号码,但不是好友)的 UserName 值?

    更新于 2024年4月17日
  • #301

    刚开始扫码登录时出现异常

    更新于 2023年12月29日
  • #295

    扫描二维码无法登录

    更新于 2023年5月16日
  • #269

    [*] 正在登录 ... 失败

    更新于 2023年5月7日
  • #300

    发生异常: OSError

    更新于 2023年4月24日
  • #252

    https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage 返回问题

    更新于 2023年4月14日

> 标签

Pythonapiweb-weixin-pipelinewechatweixinbot

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年10月2日
分类包管理
定价开源

> 相关工具

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image