Loading...
Loading...
WeChat automation operations. Implement functions including sending messages, fetching chat records, listening to messages, and friend management via the wxautox4 RESTful API. Use when: (1) Send WeChat messages to friends or group chats, (2) Read WeChat chat records, (3) Listen to new messages, (4) Fetch friend list or group chat list, (5) Accept friend requests, (6) Switch chat windows and other WeChat operations.
npx skill4agent add cluic/wxauto-skill wxautoimport platform
print(platform.system()) # Returns 'Windows' / 'Darwin' / 'Linux'The wxautox4 service can only run on Windows, do not attempt to install or start the service on the current device.
Question 1: Please provide the wxauto-restful-api service address (e.g. http://192.168.1.100:8000)
Question 2: Please provide the service's Bearer Token (see auth.token in the server-side config.yaml, default value is token)GET /v1/wechat/status~/.wxautox/service_status.jsonauth.tokenconfig.yamltoken~/.wxautox/service_status.jsonpython scripts/wxapi.py --base-url "http://192.168.1.100:8000" --token "my-token" send "Friend" "Message"# General (macOS/Linux/Windows)
export WXAPI_BASE_URL="http://192.168.1.100:8000"
export WXAPI_TOKEN="my-token"
# Windows PowerShell
$env:WXAPI_BASE_URL = "http://192.168.1.100:8000"
$env:WXAPI_TOKEN = "my-token"http://localhost:8000tokenWXAPI_SERVICE_DIRservice_dir~/.wxautox/service_status.json../wxauto-restful-api~/wxauto-restful-apimacOS / Linux users do not need to perform this section, just use the remote service address directly.
pip install wxautox4Requires Windows system, Python 3.9–3.12 64-bit
wxautox4 -a your-activation-codeGet activation code: https://docs.wxauto.org/plus
# Enter the service directory
cd C:\path\to\wxauto-restful-api
# Start the service
python run.pyStart-Process python -ArgumentList "run.py" -WorkingDirectory "C:\path\to\wxauto-restful-api" -WindowStyle Hiddenpython scripts/wxapi.py send "Friend" "Message"python scripts/wxapi.py --help# Initialize WeChat instance
python scripts/wxapi.py init
# Get service status
python scripts/wxapi.py status
# Check if online
python scripts/wxapi.py online
# Get my information
python scripts/wxapi.py myinfo# Send from main window
python scripts/wxapi.py send "Friend Name" "Message Content"
# Exact match
python scripts/wxapi.py send "Friend Name" "Message Content" --exact
# @Group members
python scripts/wxapi.py send "Group Name" "Meeting starts" --at "Zhang San,Li Si"
# Send from sub-window
python scripts/wxapi.py send-chat "Friend Name" "Message Content"# Get chat records (main window)
python scripts/wxapi.py getmsg "Friend Name"
# Get chat records (sub-window)
python scripts/wxapi.py getmsg-chat "Friend Name"
# Get historical messages
python scripts/wxapi.py history "Friend Name" --count 100
# Get new messages (main window polling)
python scripts/wxapi.py newmsg
# Get new messages (sub-window)
python scripts/wxapi.py newmsg-chat "Friend Name"# Add monitoring (open sub-window)
python scripts/wxapi.py listen "Friend Name"# Get session list
python scripts/wxapi.py session
# Get all sub-windows
python scripts/wxapi.py windows
# Switch chat window
python scripts/wxapi.py chatwith "Friend Name" --exact# Friend list
python scripts/wxapi.py friends
# Group chat list
python scripts/wxapi.py groups# Switch to chat page
python scripts/wxapi.py switch-chat
# Switch to contacts page
python scripts/wxapi.py switch-contactpython scripts/wxapi.py --help| Interface | Description |
|---|---|
| Initialize WeChat instance |
| Get WeChat status |
| Send messages |
| Send files |
| Send URL cards |
| Get messages from current window |
| Get historical messages |
| Get new messages |
| Get session list |
| Get specified sub-window |
| Get all sub-windows |
| Switch chat window |
| Get friend list |
| Get my information |
| Get group chat list |
| Switch to chat page |
| Switch to contacts page |
| Check online status |
| Interface | Description |
|---|---|
| Send messages from sub-window |
| Get all messages from sub-window |
| Get new messages from sub-window |
| Send quoted messages |
| Close sub-window |
import requests
headers = {"Authorization": "Bearer token", "Content-Type": "application/json"}
body = {"who": "Friend Name", "msg": "Message Content"}
resp = requests.post("http://localhost:8000/v1/wechat/send", headers=headers, json=body)
print(resp.json()){
"success": true,
"message": "Operation succeeded",
"data": { ... }
}http://192.168.1.100:8000auth.tokenconfig.yamltokenservice_dir~/.wxautox/service_status.jsonservice_status.json# 1. Clone the project to the user directory
cd ~
git clone https://github.com/cluic/wxauto-restful-api.git
# 2. Create virtual environment
cd wxauto-restful-api
python -m venv .venv
# 3. Activate virtual environment and install dependencies
.venv\Scripts\activate
pip install -r requirements.txt
# 4. Start service in background
python run.pyauth.tokenconfig.yaml