Skip to content

微信4.x HTTP接口文档

支持版本: 4.1.5.16 / 4.1.6.14 / 4.1.6.46 / 4.1.7.30 / 4.1.8.27 / 4.1.8.28 / 4.1.8.67

基础地址: http://127.0.0.1:{port}/api/(端口为动态分配)

所有接口均为 POST 请求,参数以 JSON 格式传递。


登录相关

初始化微信

POST /api/wechat_init

登录成功后先调用,加载联系人列表和群列表

json
{}

检查登录状态

POST /api/check_login

json
{}

刷新二维码

POST /api/reflash_qrcode

json
{}

扫描二维码登录

POST /api/qrscan

参数类型必填说明
pathstring二维码图片本地路径
json
{"path": "C:\\path\\to\\qrcode.png"}

退出登录

POST /api/logout

json
{}

自动登录 4.1.7.30+

POST /api/auto_login

json
{}

获取配置路径

POST /api/get_config_path

json
{}

个人信息

获取个人信息(缓存)

POST /api/get_profile_cache

json
{}

获取个人信息(网络)

POST /api/get_profile_new

json
{}

获取个人二维码

POST /api/get_my_qrocde

参数类型必填说明
wxidstring自己的wxid
stylestring二维码风格(1-8)
opcodestring操作码
infostring说明信息
json
{"wxid": "wxid_xxx", "style": "1", "opcode": "0", "info": ""}

修改个人昵称

POST /api/mod_self_nick_name

参数类型必填说明
newNamestring新昵称
json
{"newName": "新昵称"}

修改个人签名

POST /api/mod_self_nick_signature

参数类型必填说明
newSignaturestring新个性签名
json
{"newSignature": "这是我的签名"}

修改个人头像

POST /api/upload_head_img

参数类型必填说明
filepathstring头像图片路径
json
{"filepath": "C:\\path\\to\\headimg.png"}

发送消息

发送文本消息

POST /api/send_text_msg

参数类型必填说明
wxidstring接收人wxid
msgstring消息内容
json
{"wxid": "filehelper", "msg": "Hello World!"}

发送群@消息

POST /api/send_at_text

参数类型必填说明
wxidsstring被@人的wxid,多个用逗号分隔
msgstring消息内容(需包含@昵称)
roomIdstring群聊ID

@全体成员时 wxids 传 notify@all

json
{"wxids": "wxid_xxx,wxid_yyy", "msg": "@昵称 你好", "roomId": "123456789@chatroom"}

发送图片

POST /api/send_image_msg

参数类型必填说明
wxidstring接收人wxid
filepathstring图片本地路径
json
{"wxid": "wxid_xxx", "filepath": "C:\\path\\to\\image.png"}

发送文件

POST /api/send_file_msg

参数类型必填说明
wxidstring接收人wxid
filepathstring文件本地路径
json
{"wxid": "wxid_xxx", "filepath": "C:\\path\\to\\file.txt"}

发送名片

POST /api/send_card_msg

参数类型必填说明
towxidstring接收人wxid
fromwxidstring名片对应的wxid
json
{"towxid": "wxid_xxx", "fromwxid": "wxid_yyy"}

发送语音

POST /api/send_voice

参数类型必填说明
toWxidstring接收人wxid
silkPathstringsilk格式语音文件路径
json
{"toWxid": "wxid_xxx", "silkPath": "C:\\path\\to\\voice.silk"}

发送拍一拍

POST /api/send_pat

参数类型必填说明
roomIdstring群聊ID
wxidstring被拍人wxid
json
{"roomId": "123456789@chatroom", "wxid": "wxid_xxx"}

发送位置消息

POST /api/send_location_msg

参数类型必填说明
wxidstring接收人wxid
labelstring位置名称
poinamestring详细地址
xstring经度
ystring纬度
json
{"wxid": "wxid_xxx", "label": "位置名称", "poiname": "详细地址", "x": "116.3975", "y": "39.9087"}

发送链接卡片

POST /api/send_xml

参数类型必填说明
wxidstring接收人wxid
titlestring文章标题
descriptionstring文章描述
thumbUrlstring封面图URL
urlstring文章链接
json
{"wxid": "wxid_xxx", "title": "标题", "description": "描述", "thumbUrl": "https://example.com/thumb.jpg", "url": "https://example.com"}

发送引用消息 不支持4.1.5.16

POST /api/send_quote

参数类型必填说明
sendtostring接收人wxid或群聊ID
fromUsrstring被引用消息的发送者wxid
referContentstring被引用的消息内容
msgSourcestring消息来源XML
newmsgidstring被引用消息的newMsgId
createTimenumber被引用消息的创建时间戳
replystring回复内容
json
{
    "sendto": "wxid_xxx",
    "fromUsr": "wxid_yyy",
    "referContent": "引用内容",
    "msgSource": "[msg_source_xml]",
    "newmsgid": "1234567890123456789",
    "createTime": 1700000000,
    "reply": "回复内容"
}

好友管理

获取好友列表

POST /api/get_frien_lists

json
{}

获取联系人信息

POST /api/get_contact

参数类型必填说明
wxidstring联系人wxid
json
{"wxid": "wxid_xxx"}

搜索好友

POST /api/net_scene_search_contact

参数类型必填说明
searchstring搜索关键词
json
{"search": "微信号或手机号"}

添加好友

POST /api/add_friend

参数类型必填说明
v3stringv3数据
v4stringv4数据
scenestring添加来源场景值
friendFlagstring好友标志
verifyContentstring验证消息
json
{"v3": "v3_xxx@stranger", "v4": "v4_xxx@stranger", "scene": "3", "friendFlag": "0", "verifyContent": "你好"}

通过好友验证

POST /api/verify_friend

参数类型必填说明
v3stringv3数据
v4stringv4数据
scenestring添加来源场景值
json
{"v3": "v3_xxx@stranger", "v4": "v4_xxx", "scene": "3"}

删除联系人

POST /api/del_contact

参数类型必填说明
wxidstring要删除的联系人wxid
json
{"wxid": "wxid_xxx"}

设置联系人备注

POST /api/remark_contact

参数类型必填说明
wxidstring联系人wxid
remarkstring备注名
json
{"wxid": "wxid_xxx", "remark": "备注名"}

群聊管理

获取群聊列表

POST /api/get_chatroom_list

json
{}

获取群聊信息

POST /api/get_chatroom_info

参数类型必填说明
roomIdstring群聊ID
json
{"roomId": "123456789@chatroom"}

获取群成员列表

POST /api/get_room_members

参数类型必填说明
room_idstring群聊ID
json
{"room_id": "123456789@chatroom"}

创建群聊

POST /api/creat_chat_room

参数类型必填说明
wxidsstring成员wxid,多个用逗号分隔(至少2人)
json
{"wxids": "wxid_xxx,wxid_yyy"}

添加群成员

POST /api/add_member_to_chat_room

参数类型必填说明
room_idstring群聊ID
wxid_liststring要添加的wxid
json
{"room_id": "123456789@chatroom", "wxid_list": "wxid_xxx"}

移除群成员

POST /api/del_member_from_chat_room

参数类型必填说明
wxid_liststring要移除的wxid
room_idstring群聊ID
json
{"wxid_list": "wxid_xxx", "room_id": "123456789@chatroom"}

设置群公告

POST /api/set_room_announcement_pb

参数类型必填说明
roomIdstring群聊ID
announcementstring公告内容
json
{"roomId": "123456789@chatroom", "announcement": "这是群公告内容"}

修改群名称

POST /api/mod_chatroom_topic

参数类型必填说明
wxidstring群聊ID
topicstring新群名称
json
{"wxid": "123456789@chatroom", "topic": "新群名称"}

聊天设置

置顶聊天

POST /api/set_top

参数类型必填说明
wxidstring联系人或群聊wxid
json
{"wxid": "filehelper"}

取消置顶

POST /api/cancel_top

参数类型必填说明
wxidstring联系人或群聊wxid
json
{"wxid": "filehelper"}

消息免打扰

POST /api/set_mute_user

参数类型必填说明
wxidstring联系人wxid
json
{"wxid": "filehelper"}

加入黑名单

POST /api/black_user

参数类型必填说明
wxidstring联系人wxid
json
{"wxid": "wxid_xxx"}

红包/转账

确认转账

POST /api/ten_pay_trans_fer_confirm

参数类型必填说明
transferidstring转账交易ID
invalid_timenumber过期时间戳
json
{"transferid": "[transfer_id]", "invalid_time": 1700000000}

退还转账

POST /api/un_ten_pay_trans_fer_confirm

参数类型必填说明
transferidstring转账交易ID
invalid_timenumber过期时间戳
json
{"transferid": "[transfer_id]", "invalid_time": 1700000000}

数据库操作

获取数据库句柄

POST /api/get_db_handle

json
{}

执行SQL语句

POST /api/sqlite3_exec

参数类型必填说明
db_namestring数据库名称
sql_fmtstringSQL语句
json
{"db_name": "contact.db", "sql_fmt": "SELECT name FROM sqlite_master WHERE type='table';"}

CDN下载

POST /api/cdn_download

imgType: 1=高清图片 2=普通图片 3=略缩图 4=视频 5=文件

参数类型必填说明
fileidstringCDN文件ID
imgTypestring文件类型
asekeystringAES解密密钥
outstring文件保存路径
json
{"fileid": "[file_id]", "imgType": "5", "asekey": "[aes_key]", "out": "C:\\path\\to\\save\\file.xlsx"}

其他功能

获取A8Key

POST /api/get_a8key

参数类型必填说明
urlstring目标URL
urlTypestringURL类型
scenestring场景值
json
{"url": "https://...", "urlType": "0", "scene": "0"}

获取小程序登录码

POST /api/js_login

参数类型必填说明
waIdstring小程序AppID
json
{"waId": "wx1234567890abcdef"}

防撤回开关

POST /api/anti_revoke

参数类型必填说明
swtichstring开关("true"=开启, "false"=关闭)
json
{"swtich": "true"}

基于 MIT 许可发布