Wechat Work/Wecom/企业微信 Golang SDK
530+ APIs across 37 categories, auto-generated from official WeChat Work API documentation.
- 530+ API methods auto-generated from official docs with Chinese comments
- Self-built app support (AccessToken)
- Third-party app support (AuthCorpAccessToken, SuiteToken, ProviderToken)
- WebSocket bot client for 智能机器人长连接 (streaming support)
- Robot webhook support
- Token caching with custom storage (memory, database, etc.)
- Auto pre-fetch tokens at 80% expiry
- wwcrypt - callback encryption (same as sbzhu/weworkapi_golang)
- Session archive (会话存档) with C SDK binding
- API + Event mock testing with serialization verification
- No internal state or goroutines
client := wecom.NewClient(wecom.Conf{
CorpID: "CORPID",
AgentID: 1000002,
CorpSecret: "SECRET",
})
// Auto-fetches and caches access_token
user, err := client.GetUser(&wecom.GetUserRequest{
UserID: "zhangsan",
})store := &wecom.SyncMapStore{}
// Restore from file
if bytes, err := os.ReadFile("wecom-cache.json"); err == nil {
_ = store.Restore(bytes)
}
// Auto-save on change
store.OnChange = func(s *wecom.SyncMapStore) {
_ = os.WriteFile("wecom-cache.json", s.Dump(), 0o600)
}
client := wecom.NewClient(wecom.Conf{
CorpID: "CORPID",
AgentID: 1000002,
CorpSecret: "SECRET",
TokenProvider: &wecom.TokenCache{Store: store},
})wecom.WebhookSend(&wecom.WebhookSendRequest{
Key: "KEY",
Content: wecom.SendTextContent{Content: "Hello"},
})client := wecom.NewClient(wecom.Conf{
CorpID: "CORPID",
ProviderSecret: "PROVIDER_SECRET",
AuthCorpID: "AUTH_CORPID",
AuthCorpPermanentCode: "PERM_CODE",
SuiteID: "SUITE_ID",
SuiteSecret: "SUITE_SECRET",
SuiteTicket: "SUITE_TICKET",
})530+ APIs across 37 categories, generated from official documentation:
| Category | APIs | Category | APIs |
|---|---|---|---|
| Meeting (会议) | 102 | WeDoc (文档) | 45 |
| Contacts (通讯录) | 36 | WeDrive (微盘) | 27 |
| School (家校沟通) | 25 | ExMail (邮件) | 24 |
| External Contact (客户联系) | 20 | Gov (政民沟通) | 20 |
| KF (微信客服) | 17 | Corp Group (上下游) | 14 |
| School App (家校应用) | 13 | Checkin (打卡) | 12 |
| Approval (审批) | 11 | Data Intelligence | 11 |
| Pay (企业支付) | 11 | Message (消息) | 10 |
| Security (安全管理) | 9 | Schedule (日程) | 6 |
| Agent (应用管理) | 4 | + 18 more categories | ... |
All APIs include:
- Typed request/response structs with
jsontags - Chinese documentation comments from official docs
validate:"required"tags for required parameters- Links to official documentation
Note
- Session archive data retained for 5 days
- Pull from Sequence+1 (exclusive)
- Max limit: 1000
- Formats: jpg (image), amr (audio), mp4 (video)
- MediaData MD5 may mismatch, retry is OK
- MediaData max 512K per response
make bin
cp .env.example .env
./bin/wwfinance-libs # extract C SDK
LD_LIBRARY_PATH=/tmp/wwf/libs ./bin/wwfinance-poller
# Docker
docker run --rm -it -v $PWD/.env:/app/.env -v $PWD/data:/app/data wener/go-wecomclient, err := WeWorkFinanceSDK.NewClientFromEnv()
data, err := client.GetChatData(WeWorkFinanceSDK.GetChatDataOptions{
Limit: 10,
Timeout: 5,
})
for _, v := range data {
fmt.Println(v.Message)
}API code is auto-generated from official WeChat Work documentation:
Official Docs (955 pages) → LLM extraction → JSON specs (531) → Go code (530+ methods)
Generated files use client_gen_*.go prefix with // Code generated ... DO NOT EDIT. header.
Hand-written code in client_*.go takes precedence and is never overwritten.
- wenerme/go-req - HTTP request library
- xen0n/go-workwx - Another Go WeChat Work SDK
- sbzhu/weworkapi_golang - Official crypto library