Library / SDK
silenceper/wechat avatar
silenceper/wechat

silenceper/wechat: a Go SDK for the WeChat platform's server-side APIs

WeChat SDK for Go (微信SDK:简单、易用)

5,306 stars1,139 forksGoApache-2.0

At a glance

What is it?
The v2 module wraps official accounts, mini programs, mini games, WeChat Pay, the open platform and WeCom behind one Go package tree. It is a server-side toolkit, not a WeChat client, and the documentation is mostly Chinese.
Who is it for?
Adopt silenceper/wechat if you are writing Go on the server side against official accounts, mini programs, mini games, WeChat Pay, the open platform or WeCom, and you want those APIs behind one module instead of hand-rolled HTTP and crypto. Do not adopt it if you need a WeChat desktop or web client, if you are not writing Go, or if you need English documentation and an English-language support channel.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What silenceper/wechat actually is, and who it is for

This is a Go module, not an application. It has no binary, no daemon and no user interface. You import it into a Go service, and it gives you typed wrappers over the server-side APIs of the WeChat platform: official accounts, mini programs, mini games, WeChat Pay, the open platform and WeCom. The README states the goal in one line: "使用Golang开发的微信SDK,简单、易用" (a WeChat SDK developed in Go, simple and easy to use).

The intended reader is a backend engineer building the server half of a WeChat integration. That means handling inbound messages from an official account, calling mini program APIs, or signing and verifying WeChat Pay requests. The top-level directories map directly onto those product lines: officialaccount, miniprogram, minigame, pay, openplatform, work, plus aispeech for conversational interfaces. Two supporting directories, cache and credential, hold the pieces that every one of those product lines needs: an access token store and the HTTP credential plumbing.

If you are looking for a WeChat desktop client, a web client, or anything that logs into WeChat as a person, this is the wrong repository. Several of the related search phrases people use around this name (wechat download, wechat desktop, wechat login, how to install wechat on laptop) describe Tencent's consumer applications, not this SDK. Nothing in the README or the repository layout suggests the project implements a personal-account client.

How the SDK is structured: one entry point, per-product configs, pluggable cache

The README's example is the clearest statement of the architecture. You call wechat.NewWechat() to get a top-level value, then ask it for a product-specific client via methods such as GetOfficialAccount(cfg). Each product gets its own config struct, and the official account config shown in the README carries AppID, AppSecret, Token, an optional EncodingAESKey, and a Cache field.

That Cache field is the interesting part. Access tokens are not stateless: WeChat issues them per app and they expire, so a process that fetches a fresh token on every call will hit rate limits, and a process that caches them in memory will fight with its own replicas. The README example injects cache.NewMemory() from the cache package, and the surrounding comment says a memory cache, Redis, or a custom cache can be used. The go.mod file confirms the Redis path: go-redis/redis/v8 and bradfitz/gomemcache are direct dependencies, so Redis and memcached are first-class options rather than afterthoughts.

The message-handling flow is callback-shaped. You pass the incoming http.Request and the http.ResponseWriter into GetServer, register a handler with SetMessageHandler that receives a *message.MixMessage and returns a *message.Reply, then call Serve() and Send(). The handler in the README builds a text reply from the incoming content, which is the minimum viable echo bot. The presence of a MixMessage type rather than separate types per message kind tells you the SDK normalizes the inbound XML into one struct and leaves dispatch to your handler.

The dependency list is deliberately small. Beyond the cache backends, go.mod pulls in structs, logrus, cast, gjson and x/crypto. There is no web framework and no ORM. That is a design choice worth noting: the SDK expects you to bring your own router and your own storage, and it will not dictate either.

Installing silenceper/wechat and handling your first official account message

The module path is versioned, and the default branch is v2, so the import carries the /v2 suffix. Add it with go get, then import it. The README shows the import line as the first step of the quick start.

bash
go get github.com/silenceper/wechat/v2
go
import "github.com/silenceper/wechat/v2"

The go.mod file in the repository declares go 1.16, so a toolchain at least that old is required. The README does not state a minimum Go version beyond what go.mod implies.

With the module in place, the smallest real use is an official account endpoint that receives a message and replies. The README gives this example, and every field name below comes from it.

go
wc := wechat.NewWechat()
memory := cache.NewMemory()
cfg := &offConfig.Config{
    AppID:     "xxx",
    AppSecret: "xxx",
    Token:     "xxx",
    // EncodingAESKey: "xxxx",
    Cache: memory,
}
officialAccount := wc.GetOfficialAccount(cfg)

The AppID, AppSecret and Token come from the official account console. EncodingAESKey is shown commented out, which reflects that it is only needed when the account is configured for encrypted message mode. The Cache value is what the SDK will use to hold the access token.

The second half wires the HTTP handler. You pass the request and response writer in, register a callback, then serve and send.

go
server := officialAccount.GetServer(req, rw)
server.SetMessageHandler(func(msg *message.MixMessage) *message.Reply {
    text := message.NewText(msg.Content)
    return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
})

err := server.Serve()
if err != nil {
    fmt.Println(err)
    return
}
server.Send()

What you should see is the account echoing back whatever the user sent, because the handler wraps msg.Content in a text reply. Register the URL and Token in the official account console so WeChat's verification request reaches this handler. Note that the README does not show the router wiring around req and rw, which is the part you supply.

Where the SDK stops helping: token storage, documentation language and unimplemented endpoints

The cache decision is the first real operational constraint. The README example uses an in-memory cache, which is fine for a single process and wrong the moment you run two replicas behind a load balancer. Each replica would hold its own access token, and depending on how WeChat rate-limits token issuance for your app, you can end up with replicas invalidating each other's tokens. The cache package offers Redis and memcached options, and the README's comment explicitly points at Redis and custom caches, but the choice and its consequences are yours to reason about. The README does not document token refresh timing or what happens on a concurrent refresh.

The second constraint is documentation language. The README is in Chinese, the documentation site at silenceper.com/wechat is the "Wechat SDK 2.0 文档", and the API list lives under doc/api in the repository. There is a pkg.go.dev reference linked from the badges, but the prose documentation, examples and contribution guide are Chinese-first. If your team cannot read Chinese, budget time for that, because the SDK's behaviour on edge cases is not going to be explained in English anywhere in this repository.

The third is coverage. The contribution section is explicit that not every API is implemented: it tells contributors to check the API list to see which APIs are missing, then open an issue describing what they want to add. That is an honest statement of scope, and it means you should check doc/api for your specific endpoint before you plan around this library. An endpoint that is absent means writing the HTTP call and signature yourself.

The README also does not document rollback, versioning policy or a support channel beyond GitHub issues and pull requests. Release tags exist (v2.1.14 on 2026-07-20, v2.1.13 on 2026-05-08, v2.1.12 on 2026-02-11), so pinning a tag is possible, but there is no stated compatibility promise between minor versions.

How it compares to calling the WeChat APIs directly, or to go-wechat-style wrappers

The real alternative is not another library so much as writing the integrations yourself against Tencent's HTTP APIs. The difference is concentrated in three places: token lifecycle, message crypto, and type definitions.

If you call the APIs directly, you own the access token cache and its refresh logic, you implement the signature and AES decryption for encrypted callbacks, and you define your own structs for every request and response. That is more code, but it is code you fully understand, and it has no dependency surface beyond the standard library. This SDK replaces that with the cache package, the credential package, and the per-product type definitions. The trade-off is that when WeChat changes a field or adds an endpoint, you wait for a release or you fork.

Among Go wrappers, the meaningful distinction here is breadth. This module covers official accounts, mini programs, mini games, WeChat Pay, the open platform, WeCom and aispeech under one module path, with a shared cache and credential layer. A narrower library that only handles, say, WeChat Pay would have a smaller dependency graph and a smaller blast radius on upgrade. If you only need one of these product lines, a single-purpose library or a hand-rolled client is a defensible choice; if you need three of them in one service, the shared plumbing here is the reason to pick it.

One more comparison point that matters for evaluation: because the module is versioned as /v2 and the default branch is v2, older v1 code will not compile against it. Any migration from v1 is a rewrite of import paths and, presumably, call sites.

Licence and the cost of keeping it current

The repository ships an Apache-2.0 licence, and the README's final section states "Apache License, Version 2.0". Apache-2.0 is a permissive licence that includes an explicit patent grant and requires you to preserve notices. It does not impose copyleft obligations on your application. That is a summary of the licence text, not legal advice; if your organisation has a licence review process, run the LICENSE file through it.

Upgrade cost is the practical question. The release cadence visible in the tags is roughly every two to three months through 2026: v2.1.12 on 2026-02-11, v2.1.13 on 2026-05-08, v2.1.14 on 2026-07-20. The repository is not archived, and the last push was on 2026-07-20. There is no changelog in the README and no documented deprecation policy, so the way to judge an upgrade is to read the diff between tags or the release notes for the version you are moving to.

Because the dependency list is short and pinned in go.mod, most upgrades will be a single go get of the new tag plus a build. The risk concentrates in the cache and credential packages, since those sit under every product line, and in any per-product config struct that gained or lost a field. Pin a tag in go.mod rather than tracking the v2 branch, and read the release diff before moving.

Editorial conclusion

Adopt silenceper/wechat if you are writing Go on the server side against official accounts, mini programs, mini games, WeChat Pay, the open platform or WeCom, and you want those APIs behind one module instead of hand-rolled HTTP and crypto. Do not adopt it if you need a WeChat desktop or web client, if you are not writing Go, or if you need English documentation and an English-language support channel. Before committing, verify three things: that the specific endpoint you need is implemented under doc/api, that the credential and cache wiring you plan to use is supported by the cache package, and that the module version you pin still builds against your Go toolchain. The last push to the repository was on 2026-07-20, so pin a tag rather than tracking the branch.

Frequently asked questions

Is silenceper/wechat a WeChat client I can install on my laptop?

No. It is a Go SDK that you import into a server-side Go service, with no binary and no user interface. The directories cover official accounts, mini programs, mini games, WeChat Pay, the open platform and WeCom APIs.

How do I install silenceper/wechat?

Add the versioned module path with go get github.com/silenceper/wechat/v2 and import github.com/silenceper/wechat/v2 in your Go code. The repository's go.mod declares go 1.16.

Does silenceper/wechat cover every WeChat API?

No. The contribution section tells contributors to check the API list to see which APIs are not yet implemented, which means coverage is incomplete and you should verify your endpoint under doc/api before planning around the SDK.

Where do I store the access token when using silenceper/wechat?

The official account config takes a Cache field. The README example passes cache.NewMemory(), and its comment notes that Redis or a custom cache can be used instead, with go-redis/redis/v8 and gomemcache among the module's dependencies.

What licence is silenceper/wechat released under?

Apache-2.0. The repository contains a LICENSE file and the README's final section states Apache License, Version 2.0.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. README
  4. Releases
  5. silenceper/wechat on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/silenceper-wechat.svg)](https://hysenlabs.com/projects/silenceper-wechat)